[Cairo] Implement ImageBuffer::copyImage for BackingStoreCopy == DontCopyBackingStore
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 May 2012 23:07:54 +0000 (23:07 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 May 2012 23:07:54 +0000 (23:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85728

Reviewed by Alejandro G. Castro.

No new tests. This should not change functionality, only increase performance.

* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::copyImage): Add an implementation that knows how to avoid copying the backing store.
(WebCore::ImageBuffer::draw): Use the copyImage constructor now that it knows how to
avoid copying the backing store.
(WebCore::ImageBuffer::drawPattern): Ditto.
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::updateBackingStore): Use DontCopyBackingStore for Cairo
as well.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

index 778a05c..50d1b2c 100644 (file)
@@ -1,3 +1,21 @@
+2012-05-06  Martin Robinson  <mrobinson@igalia.com>
+
+        [Cairo] Implement ImageBuffer::copyImage for BackingStoreCopy == DontCopyBackingStore
+        https://bugs.webkit.org/show_bug.cgi?id=85728
+
+        Reviewed by Alejandro G. Castro.
+
+        No new tests. This should not change functionality, only increase performance.
+
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::copyImage): Add an implementation that knows how to avoid copying the backing store.
+        (WebCore::ImageBuffer::draw): Use the copyImage constructor now that it knows how to
+        avoid copying the backing store.
+        (WebCore::ImageBuffer::drawPattern): Ditto.
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::updateBackingStore): Use DontCopyBackingStore for Cairo
+        as well.
+
 2012-05-07  Noel Gordon  <noel.gordon@gmail.com>
 
         [CG] Separate image encoding from dataURL construction
index af157a2..2ed6bd6 100644 (file)
@@ -84,9 +84,11 @@ GraphicsContext* ImageBuffer::context() const
 
 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior) const
 {
-    ASSERT(copyBehavior == CopyBackingStore);
+    if (copyBehavior == CopyBackingStore)
+        return BitmapImage::create(copyCairoImageSurface(m_data.m_surface).leakRef());
+
     // BitmapImage will release the passed in surface on destruction
-    return BitmapImage::create(copyCairoImageSurface(m_data.m_surface).leakRef());
+    return BitmapImage::create(cairo_surface_reference(m_data.m_surface));
 }
 
 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& maskRect) const
@@ -97,16 +99,14 @@ void ImageBuffer::clip(GraphicsContext* context, const FloatRect& maskRect) cons
 void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
                        CompositeOperator op , bool useLowQualityScale)
 {
-    // BitmapImage will release the passed in surface on destruction
-    RefPtr<Image> image = BitmapImage::create(cairo_surface_reference(m_data.m_surface));
+    RefPtr<Image> image = copyImage(DontCopyBackingStore);
     context->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
 }
 
 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
                               const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
 {
-    // BitmapImage will release the passed in surface on destruction
-    RefPtr<Image> image = BitmapImage::create(cairo_surface_reference(m_data.m_surface));
+    RefPtr<Image> image = copyImage(DontCopyBackingStore);
     image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
 }
 
index 4b996e9..84a6601 100644 (file)
@@ -122,15 +122,7 @@ void TextureMapperLayer::updateBackingStore(TextureMapper* textureMapper, Graphi
     context->translate(-dirtyRect.x(), -dirtyRect.y());
     layer->paintGraphicsLayerContents(*context, dirtyRect);
 
-    RefPtr<Image> image;
-
-#if PLATFORM(QT)
-    image = imageBuffer->copyImage(DontCopyBackingStore);
-#else
-    // FIXME: support DontCopyBackingStore in non-Qt ports that use TextureMapper.
-    image = imageBuffer->copyImage(CopyBackingStore);
-#endif
-
+    RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
     static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect);
     m_state.needsDisplay = false;
     m_state.needsDisplayRect = IntRect();