Title: [252136] trunk/Source/WebCore
Revision
252136
Author
commit-qu...@webkit.org
Date
2019-11-06 05:13:10 -0800 (Wed, 06 Nov 2019)

Log Message

[Cairo] Cairo graphics backend uses ImageBuffer::copyImage just to access native image buffer handles
https://bugs.webkit.org/show_bug.cgi?id=203884

Patch by Chris Lord <cl...@igalia.com> on 2019-11-06
Reviewed by Carlos Garcia Campos.

The Cairo graphics backend uses ImageBuffer::copyImage(DontCopyBackingStore) frequently just to access
the native image pointer. This makes several functions unusable off-main-thread, so add an accessor
function to avoid doing this.

No new tests -- no change in behavior.

* platform/graphics/ImageBuffer.h:
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::drawShadowLayerBuffer):
(WebCore::Cairo::drawShadowImage):
(WebCore::Cairo::fillShadowBuffer):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::clipToImageBuffer):
* platform/graphics/cairo/GraphicsContextImplCairo.cpp:
(WebCore::GraphicsContextImplCairo::clipToImageBuffer):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::nativeImage const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252135 => 252136)


--- trunk/Source/WebCore/ChangeLog	2019-11-06 10:34:18 UTC (rev 252135)
+++ trunk/Source/WebCore/ChangeLog	2019-11-06 13:13:10 UTC (rev 252136)
@@ -1,3 +1,28 @@
+2019-11-06  Chris Lord  <cl...@igalia.com>
+
+        [Cairo] Cairo graphics backend uses ImageBuffer::copyImage just to access native image buffer handles
+        https://bugs.webkit.org/show_bug.cgi?id=203884
+
+        Reviewed by Carlos Garcia Campos.
+
+        The Cairo graphics backend uses ImageBuffer::copyImage(DontCopyBackingStore) frequently just to access
+        the native image pointer. This makes several functions unusable off-main-thread, so add an accessor
+        function to avoid doing this.
+
+        No new tests -- no change in behavior.
+
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/cairo/CairoOperations.cpp:
+        (WebCore::Cairo::drawShadowLayerBuffer):
+        (WebCore::Cairo::drawShadowImage):
+        (WebCore::Cairo::fillShadowBuffer):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::clipToImageBuffer):
+        * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
+        (WebCore::GraphicsContextImplCairo::clipToImageBuffer):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::nativeImage const):
+
 2019-11-06  Philippe Normand  <ph...@igalia.com>
 
         REGRESSION(r249428): [GStreamer] VP9 video rendered green

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (252135 => 252136)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2019-11-06 10:34:18 UTC (rev 252135)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2019-11-06 13:13:10 UTC (rev 252136)
@@ -116,6 +116,10 @@
     Vector<uint8_t> toData(const String& mimeType, Optional<double> quality = WTF::nullopt) const;
     Vector<uint8_t> toBGRAData() const;
 
+#if USE(CAIRO)
+    NativeImagePtr nativeImage() const;
+#endif
+
 #if !USE(CG)
     AffineTransform baseTransform() const { return AffineTransform(); }
     void transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace);

Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp (252135 => 252136)


--- trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp	2019-11-06 10:34:18 UTC (rev 252135)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp	2019-11-06 13:13:10 UTC (rev 252136)
@@ -174,11 +174,7 @@
 
 static void drawShadowLayerBuffer(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize, const ShadowState& shadowState)
 {
-    RefPtr<Image> image = layerImage.copyImage(DontCopyBackingStore);
-    if (!image)
-        return;
-
-    if (auto surface = image->nativeImageForCurrentFrame()) {
+    if (auto surface = layerImage.nativeImage()) {
         drawNativeImage(platformContext, surface.get(), FloatRect(roundedIntPoint(layerOrigin), layerSize), FloatRect(FloatPoint(), layerSize), { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
     }
 }
@@ -186,11 +182,7 @@
 // FIXME: This is mostly same as drawShadowLayerBuffer, so we should merge two.
 static void drawShadowImage(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatRect& destRect, const FloatRect& srcRect, const ShadowState& shadowState)
 {
-    RefPtr<Image> image = layerImage.copyImage(DontCopyBackingStore);
-    if (!image)
-        return;
-
-    if (auto surface = image->nativeImageForCurrentFrame()) {
+    if (auto surface = layerImage.nativeImage()) {
         drawNativeImage(platformContext, surface.get(), destRect, srcRect, { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
     }
 }
@@ -199,11 +191,8 @@
 {
     save(platformContext);
 
-    RefPtr<Image> image = layerImage.copyImage(DontCopyBackingStore);
-    if (image) {
-        if (auto surface = image->nativeImageForCurrentFrame())
-            clipToImageBuffer(platformContext, surface.get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
-    }
+    if (auto surface = layerImage.nativeImage())
+        clipToImageBuffer(platformContext, surface.get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
 
     FillSource fillSource;
     fillSource.globalAlpha = shadowState.globalAlpha;

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (252135 => 252136)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2019-11-06 10:34:18 UTC (rev 252135)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2019-11-06 13:13:10 UTC (rev 252136)
@@ -267,12 +267,8 @@
         return;
     }
 
-    RefPtr<Image> image = buffer.copyImage(DontCopyBackingStore);
-    if (!image)
-        return;
-
     ASSERT(hasPlatformContext());
-    if (auto surface = image->nativeImageForCurrentFrame())
+    if (auto surface = buffer.nativeImage())
         Cairo::clipToImageBuffer(*platformContext(), surface.get(), destRect);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (252135 => 252136)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp	2019-11-06 10:34:18 UTC (rev 252135)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp	2019-11-06 13:13:10 UTC (rev 252136)
@@ -411,11 +411,7 @@
 
 void GraphicsContextImplCairo::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect)
 {
-    RefPtr<Image> image = buffer.copyImage(DontCopyBackingStore);
-    if (!image)
-        return;
-
-    if (auto surface = image->nativeImageForCurrentFrame())
+    if (auto surface = buffer.nativeImage())
         Cairo::clipToImageBuffer(m_platformContext, surface.get(), destRect);
 }
 

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


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2019-11-06 10:34:18 UTC (rev 252135)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2019-11-06 13:13:10 UTC (rev 252136)
@@ -259,6 +259,11 @@
     return imageData;
 }
 
+NativeImagePtr ImageBuffer::nativeImage() const
+{
+    return m_data.m_surface.get();
+}
+
 ImageBuffer::ImageBuffer(const FloatSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, const HostWindow*, bool& success)
     : m_data(IntSize(size), renderingMode)
     , m_logicalSize(size)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to