ImageBuffer::draw should deep copy if drawing to an accelerated context
authormdelaney@apple.com <mdelaney@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2012 07:23:22 +0000 (07:23 +0000)
committermdelaney@apple.com <mdelaney@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jan 2012 07:23:22 +0000 (07:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77185

Reviewed by Simon Fraser.

No new tests since any test for this issue would be flaky at best.

* platform/graphics/cg/ImageBufferCG.cpp: Deep copy when drawing ourself into
    an accelerated context for both draw and drawPattern.
(WebCore::ImageBuffer::draw):
(WebCore::ImageBuffer::drawPattern):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106095 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp

index 04a8b8a..d172906 100644 (file)
@@ -1,3 +1,17 @@
+2012-01-26  Matthew Delaney  <mdelaney@apple.com>
+
+        ImageBuffer::draw should deep copy if drawing to an accelerated context
+        https://bugs.webkit.org/show_bug.cgi?id=77185
+
+        Reviewed by Simon Fraser.
+
+        No new tests since any test for this issue would be flaky at best.
+
+        * platform/graphics/cg/ImageBufferCG.cpp: Deep copy when drawing ourself into
+            an accelerated context for both draw and drawPattern.
+        (WebCore::ImageBuffer::draw):
+        (WebCore::ImageBuffer::drawPattern):
+
 2012-01-26  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Unreviewed. Build fixes.
index 355f475..25493b3 100644 (file)
@@ -241,7 +241,7 @@ void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace,
     ColorSpace colorSpace = (destContext == m_context) ? ColorSpaceDeviceRGB : styleColorSpace;
 
     RetainPtr<CGImageRef> image;
-    if (destContext == m_context)
+    if (destContext == m_context || destContext->isAcceleratedContext())
         image.adoptCF(copyNativeImage(CopyBackingStore)); // Drawing into our own buffer, need to deep copy.
     else
         image.adoptCF(copyNativeImage(DontCopyBackingStore));
@@ -249,19 +249,19 @@ void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace,
     destContext->drawNativeImage(image.get(), m_size, colorSpace, destRect, srcRect, op);
 }
 
-void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
 {
     if (!m_context->isAcceleratedContext()) {
-        if (context == m_context) {
+        if (destContext == m_context || destContext->isAcceleratedContext()) {
             RefPtr<Image> copy = copyImage(CopyBackingStore); // Drawing into our own buffer, need to deep copy.
-            copy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
+            copy->drawPattern(destContext, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
         } else {
             RefPtr<Image> imageForRendering = copyImage(DontCopyBackingStore);
-            imageForRendering->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
+            imageForRendering->drawPattern(destContext, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
         }
     } else {
         RefPtr<Image> copy = copyImage(CopyBackingStore);
-        copy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
+        copy->drawPattern(destContext, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
     }
 }