Title: [137397] trunk/Source/WebCore
Revision
137397
Author
[email protected]
Date
2012-12-11 17:35:42 -0800 (Tue, 11 Dec 2012)

Log Message

WebGL: Avoid unnecessary memory copy or conversion in texImage2D and texSubImage2D for HTMLVideoElement
https://bugs.webkit.org/show_bug.cgi?id=102161

Patch by Jun Jiang <[email protected]> on 2012-12-11
Reviewed by Kenneth Russell.

There are several memory copy or conversions in the texImage2D and texSubImage2D for HTMLVideoElement which may be avoided. This patch removes the redundant BackingStore copy if the corresponding Graphics port supports the DontCopyBackingStore behavior. Moreover, it optimizes the AlphaOp if the Image source is from HTMLVideoElement to avoid unnecessary Unmultiply or Premultiply operation in unpack/pack.

Already covered by current tests.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::texImage2DImpl):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::videoFrameToImage): add a parameter to choose BackingStore copy behavior.
(WebCore::WebGLRenderingContext::texSubImage2DImpl):
(WebCore::WebGLRenderingContext::texSubImage2D):
* html/canvas/WebGLRenderingContext.h:
(WebGLRenderingContext):
* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::ImageExtractor):
* platform/graphics/GraphicsContext3D.h:
(ImageExtractor):
(WebCore::GraphicsContext3D::ImageExtractor::imageSourceUnpackAlignment):
(WebCore::GraphicsContext3D::ImageExtractor::imageHtmlDomSource):
* platform/graphics/ImageBuffer.h:
(ImageBuffer):
* platform/graphics/cairo/GraphicsContext3DCairo.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage): optimize the AlphaOp for HTMLVideoElement input.
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::fastCopyImageMode):
(WebCore):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::fastCopyImageMode):
(WebCore):
* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::ImageBuffer::fastCopyImageMode):
(WebCore):
* platform/graphics/skia/GraphicsContext3DSkia.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage): optimize the AlphaOp for HTMLVideoElement input.
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::fastCopyImageMode):
(WebCore):
* platform/graphics/wince/ImageBufferWinCE.cpp:
(WebCore::ImageBuffer::fastCopyImageMode):
(WebCore):
* platform/graphics/wx/ImageBufferWx.cpp:
(WebCore::ImageBuffer::fastCopyImageMode):
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (137396 => 137397)


--- trunk/Source/WebCore/ChangeLog	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/ChangeLog	2012-12-12 01:35:42 UTC (rev 137397)
@@ -1,3 +1,54 @@
+2012-12-11  Jun Jiang  <[email protected]>
+
+        WebGL: Avoid unnecessary memory copy or conversion in texImage2D and texSubImage2D for HTMLVideoElement
+        https://bugs.webkit.org/show_bug.cgi?id=102161
+
+        Reviewed by Kenneth Russell.
+
+        There are several memory copy or conversions in the texImage2D and texSubImage2D for HTMLVideoElement which may be avoided. This patch removes the redundant BackingStore copy if the corresponding Graphics port supports the DontCopyBackingStore behavior. Moreover, it optimizes the AlphaOp if the Image source is from HTMLVideoElement to avoid unnecessary Unmultiply or Premultiply operation in unpack/pack. 
+
+        Already covered by current tests. 
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContext::texImage2DImpl):
+        (WebCore::WebGLRenderingContext::texImage2D):
+        (WebCore::WebGLRenderingContext::videoFrameToImage): add a parameter to choose BackingStore copy behavior.
+        (WebCore::WebGLRenderingContext::texSubImage2DImpl):
+        (WebCore::WebGLRenderingContext::texSubImage2D):
+        * html/canvas/WebGLRenderingContext.h:
+        (WebGLRenderingContext):
+        * platform/graphics/GraphicsContext3D.cpp:
+        (WebCore::GraphicsContext3D::ImageExtractor::ImageExtractor):
+        * platform/graphics/GraphicsContext3D.h:
+        (ImageExtractor):
+        (WebCore::GraphicsContext3D::ImageExtractor::imageSourceUnpackAlignment):
+        (WebCore::GraphicsContext3D::ImageExtractor::imageHtmlDomSource):
+        * platform/graphics/ImageBuffer.h:
+        (ImageBuffer):
+        * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
+        (WebCore::GraphicsContext3D::ImageExtractor::extractImage): optimize the AlphaOp for HTMLVideoElement input.
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode):
+        (WebCore):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode):
+        (WebCore):
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode):
+        (WebCore):
+        * platform/graphics/skia/GraphicsContext3DSkia.cpp:
+        (WebCore::GraphicsContext3D::ImageExtractor::extractImage): optimize the AlphaOp for HTMLVideoElement input.
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode):
+        (WebCore):
+        * platform/graphics/wince/ImageBufferWinCE.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode):
+        (WebCore):
+        * platform/graphics/wx/ImageBufferWx.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode):
+        (WebCore):
+
 2012-12-11  Viatcheslav Ostapenko  <[email protected]>
 
         [EFL] Missing implementation of GraphicsContext3DPrivate::platformLayerSize()

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (137396 => 137397)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -3609,15 +3609,13 @@
     cleanupAfterGraphicsCall(false);
 }
 
-void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat,
-                                           GC3Denum format, GC3Denum type, Image* image,
-                                           bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
 {
     ec = 0;
     if (!validateSettableTexFormat("texImage2D", internalformat))
         return;
     Vector<uint8_t> data;
-    GraphicsContext3D::ImageExtractor imageExtractor(image, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
+    GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
     if (!imageExtractor.extractSucceeded()) {
         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data");
         return;
@@ -3702,8 +3700,7 @@
         return;
     }
 
-    texImage2DImpl(target, level, internalformat, format, type, image->cachedImage()->imageForRenderer(image->renderer()),
-                   m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+    texImage2DImpl(target, level, internalformat, format, type, image->cachedImage()->imageForRenderer(image->renderer()), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
 }
 
 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
@@ -3741,12 +3738,11 @@
     if (imageData)
         texImage2D(target, level, internalformat, format, type, imageData.get(), ec);
     else
-        texImage2DImpl(target, level, internalformat, format, type, canvas->copiedImage(),
-                       m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+        texImage2DImpl(target, level, internalformat, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
 }
 
 #if ENABLE(VIDEO)
-PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* video, ExceptionCode& ec)
+PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy, ExceptionCode& ec)
 {
     if (!video || !video->videoWidth() || !video->videoHeight()) {
         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "no video");
@@ -3765,7 +3761,7 @@
     IntRect destRect(0, 0, size.width(), size.height());
     // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
     video->paintCurrentFrameInContext(buf->context(), destRect);
-    return buf->copyImage(CopyBackingStore);
+    return buf->copyImage(backingStoreCopy);
 }
 
 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
@@ -3774,10 +3770,10 @@
     ec = 0;
     if (isContextLost())
         return;
-    RefPtr<Image> image = videoFrameToImage(video, ec);
+    RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode(), ec);
     if (!image)
         return;
-    texImage2DImpl(target, level, internalformat, format, type, image.get(), m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+    texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
 }
 #endif
 
@@ -3857,15 +3853,13 @@
     cleanupAfterGraphicsCall(false);
 }
 
-void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
-                                              GC3Denum format, GC3Denum type,
-                                              Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
 {
     ec = 0;
     if (isContextLost())
         return;
     Vector<uint8_t> data;
-    GraphicsContext3D::ImageExtractor imageExtractor(image, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);  
+    GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);  
     if (!imageExtractor.extractSucceeded()) {
         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image");
         return;
@@ -3948,8 +3942,7 @@
         ec = SECURITY_ERR;
         return;
     }
-    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image->cachedImage()->imageForRenderer(image->renderer()),
-                      m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image->cachedImage()->imageForRenderer(image->renderer()), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
 }
 
 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
@@ -3970,8 +3963,7 @@
     if (imageData)
         texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get(), ec);
     else
-        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(),
-                          m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
 }
 
 #if ENABLE(VIDEO)
@@ -3981,10 +3973,10 @@
     ec = 0;
     if (isContextLost())
         return;
-    RefPtr<Image> image = videoFrameToImage(video, ec);
+    RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode(), ec);
     if (!image)
         return;
-    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+    texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
 }
 #endif
 

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (137396 => 137397)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2012-12-12 01:35:42 UTC (rev 137397)
@@ -29,6 +29,7 @@
 #include "CanvasRenderingContext.h"
 #include "DrawingBuffer.h"
 #include "GraphicsContext3D.h"
+#include "ImageBuffer.h"
 #include "Timer.h"
 #include "WebGLGetInfo.h"
 
@@ -372,7 +373,7 @@
     void addCompressedTextureFormat(GC3Denum);
 
 #if ENABLE(VIDEO)
-    PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, ExceptionCode&);
+    PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy, ExceptionCode&);
 #endif
 
     RefPtr<GraphicsContext3D> m_context;
@@ -531,13 +532,9 @@
     void restoreStateAfterClear();
 
     void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&);
-    void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat,
-                        GC3Denum format, GC3Denum type, Image*,
-                        bool flipY, bool premultiplyAlpha, ExceptionCode&);
+    void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&);
     void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&);
-    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
-                           GC3Denum format, GC3Denum type,
-                           Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&);
+    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&);
 
     void handleNPOTTextures(const char*, bool);
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -168,9 +168,10 @@
     return GraphicsContext3D::NO_ERROR;
 }
 
-GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, ImageHtmlDomSource imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
 {
     m_image = image;
+    m_imageHtmlDomSource = imageHtmlDomSource;
     m_extractSucceeded = extractImage(premultiplyAlpha, ignoreGammaAndColorProfile);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-12-12 01:35:42 UTC (rev 137397)
@@ -875,6 +875,13 @@
         AlphaDoUnmultiply = 2
     };
 
+    enum ImageHtmlDomSource {
+        HtmlDomImage = 0,
+        HtmlDomCanvas = 1,
+        HtmlDomVideo = 2,
+        HtmlDomNone = 3
+    };
+
     // Packs the contents of the given Image which is passed in |pixels| into the passed Vector
     // according to the given format and type, and obeying the flipY and AlphaOp flags.
     // Returns true upon success.
@@ -882,7 +889,7 @@
 
     class ImageExtractor {
     public:
-        ImageExtractor(Image*, bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
+        ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
 
         // Each platform must provide an implementation of this method to deallocate or release resources
         // associated with the image if needed.
@@ -894,7 +901,8 @@
         unsigned imageHeight() { return m_imageHeight; }
         SourceDataFormat imageSourceFormat() { return m_imageSourceFormat; }
         AlphaOp imageAlphaOp() { return m_alphaOp; }
-        unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignment; } 
+        unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignment; }
+        ImageHtmlDomSource imageHtmlDomSource() { return m_imageHtmlDomSource; }
     private:
         // Each platform must provide an implementation of this method.
         // Extracts the image and keeps track of its status, such as width, height, Source Alignment, format and AlphaOp etc,
@@ -915,6 +923,7 @@
         QImage m_qtImage;
 #endif
         Image* m_image;
+        ImageHtmlDomSource m_imageHtmlDomSource;
         bool m_extractSucceeded;
         const void* m_imagePixelData;
         unsigned m_imageWidth;

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2012-12-12 01:35:42 UTC (rev 137397)
@@ -104,6 +104,9 @@
         GraphicsContext* context() const;
 
         PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavior = Scaled) const;
+        // Give hints on the faster copyImage Mode, return DontCopyBackingStore if it supports the DontCopyBackingStore behavior
+        // or return CopyBackingStore if it doesn't.  
+        static BackingStoreCopy fastCopyImageMode();
 
         enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSystem };
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -189,7 +189,11 @@
     } else {
         NativeImageCairo* nativeImage = m_image->nativeImageForCurrentFrame();
         m_imageSurface = (nativeImage) ? nativeImage->surface() : 0;
-        if (!premultiplyAlpha)
+        // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value is 0xFF for each pixel,
+        // which is true at present and may be changed in the future and needs adjustment accordingly.
+        // 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port, 
+        // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to false.
+        if (!premultiplyAlpha && m_imageHtmlDomSource != HtmlDomVideo)
             m_alphaOp = AlphaDoUnmultiply;
     }
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -91,6 +91,11 @@
     return BitmapImage::create(cairo_surface_reference(m_data.m_surface));
 }
 
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return DontCopyBackingStore;
+}
+
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& maskRect) const
 {
     context->platformContext()->pushImageMask(m_data.m_surface, maskRect);

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -231,6 +231,11 @@
     return BitmapImage::create(image.get());
 }
 
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return DontCopyBackingStore;
+}
+
 NativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
 {
     CGImageRef image = 0;

Modified: trunk/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -125,6 +125,11 @@
     return StillImage::createForRendering(&m_data.m_pixmap);
 }
 
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return DontCopyBackingStore;
+}
+
 void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
     CompositeOperator op, BlendMode, bool useLowQualityScale)
 {

Modified: trunk/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -78,8 +78,14 @@
         m_skiaImage = m_nativeImage.get();
         if (hasAlpha && premultiplyAlpha)
             m_alphaOp = AlphaDoPremultiply;
-    } else if (!premultiplyAlpha && hasAlpha)
-        m_alphaOp = AlphaDoUnmultiply;
+    } else if (!premultiplyAlpha && hasAlpha) {
+        // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value for each pixel is 0xFF
+        // which is true at present and may be changed in the future and needs adjustment accordingly.
+        // 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port,
+        // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to false.
+        if (m_imageHtmlDomSource != HtmlDomVideo)
+            m_alphaOp = AlphaDoUnmultiply;
+    }
     if (!m_skiaImage)
         return false;
 

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -201,6 +201,11 @@
     return BitmapImageSingleFrameSkia::create(*m_data.m_platformContext.bitmap(), copyBehavior == CopyBackingStore, m_resolutionScale);
 }
 
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return DontCopyBackingStore;
+}
+
 PlatformLayer* ImageBuffer::platformLayer() const
 {
     return m_data.m_layerBridge ? m_data.m_layerBridge->layer() : 0;

Modified: trunk/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -100,6 +100,11 @@
     return adoptRef(new BufferedImage(&m_data));
 }
 
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return CopyBackingStore;
+}
+
 void ImageBuffer::clip(GraphicsContext*, const FloatRect&) const
 {
     notImplemented();

Modified: trunk/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp (137396 => 137397)


--- trunk/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp	2012-12-12 01:30:47 UTC (rev 137396)
+++ trunk/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp	2012-12-12 01:35:42 UTC (rev 137397)
@@ -152,6 +152,11 @@
     return img.release();
 }
 
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+    return CopyBackingStore;
+}
+
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
 {
     context->clip(rect);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to