Title: [269159] trunk
Revision
269159
Author
[email protected]
Date
2020-10-29 11:35:59 -0700 (Thu, 29 Oct 2020)

Log Message

REGRESSION(269065): [GPU Process]: Order of drawing has to be preserved when drawing a canvas to another canvas
https://bugs.webkit.org/show_bug.cgi?id=218324

Reviewed by Simon Fraser.

Source/WebCore:

Allow DisplayList::Recorder::Delegate to take an action after appending
a DisplayList::Item to its DisplayList::DisplayList.

Test: fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html

* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::didAppendItem):
(WebCore::DisplayList::Recorder::appendItemAndUpdateExtent):
(WebCore::DisplayList::Recorder::appendItem):
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::Delegate::didAppendItem):

Source/WebKit:

When drawing an ImageBuffer to another ImageBuffer, the DrawingContext of
the source and the destination ImageBuffers have to be flushed immediately.
Otherwise an older version or a newer version of the source ImageBuffer
might be drawn to the destination ImageBuffer.

* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:

LayoutTests:

* fast/canvas/canvas-draw-canvas-on-canvas-flushing-order-expected.html: Added.
* fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269158 => 269159)


--- trunk/LayoutTests/ChangeLog	2020-10-29 18:32:05 UTC (rev 269158)
+++ trunk/LayoutTests/ChangeLog	2020-10-29 18:35:59 UTC (rev 269159)
@@ -1,3 +1,13 @@
+2020-10-29  Said Abou-Hallawa  <[email protected]>
+
+        REGRESSION(269065): [GPU Process]: Order of drawing has to be preserved when drawing a canvas to another canvas
+        https://bugs.webkit.org/show_bug.cgi?id=218324
+
+        Reviewed by Simon Fraser.
+
+        * fast/canvas/canvas-draw-canvas-on-canvas-flushing-order-expected.html: Added.
+        * fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html: Added.
+
 2020-10-29  Noam Rosenthal  <[email protected]>
 
         REGRESSION(r268249): image-orientation:none is broken for local (file://) urls

Added: trunk/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-flushing-order-expected.html (0 => 269159)


--- trunk/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-flushing-order-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-flushing-order-expected.html	2020-10-29 18:35:59 UTC (rev 269159)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<body>
+    <canvas id="canvas1" width="100" height="100"></canvas>
+    <canvas id="canvas2" width="100" height="100"></canvas>
+    <canvas id="canvas3" width="100" height="100"></canvas>
+    <script>
+        let colors = ['red', 'green', 'blue'];
+        let canvases = ['canvas1', 'canvas2', 'canvas3'];
+
+        colors.forEach(function(color, index, colors) {
+            var canvas = document.getElementById(canvases[index]);
+            var ctx = canvas.getContext('2d');
+            ctx.fillStyle = color;
+            ctx.fillRect(0, 0, 100, 100);
+        });
+    </script>
+</body>

Added: trunk/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html (0 => 269159)


--- trunk/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html	2020-10-29 18:35:59 UTC (rev 269159)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<body>
+    <canvas id="canvas1" width="100" height="100"></canvas>
+    <canvas id="canvas2" width="100" height="100"></canvas>
+    <canvas id="canvas3" width="100" height="100"></canvas>
+    <script>
+        let colors = ['red', 'green', 'blue'];
+        let canvases = ['canvas1', 'canvas2', 'canvas3'];
+
+        colors.forEach(function(color, index, colors) {
+            var canvas = document.getElementById(canvases[colors.length - 1]);
+            var ctx = canvas.getContext('2d');
+            ctx.fillStyle = color;
+            ctx.fillRect(0, 0, 100, 100);
+
+            var canvasDest = document.getElementById(canvases[index]);
+            var ctxDest = canvasDest.getContext('2d');
+            ctxDest.drawImage(canvas, 0, 0);
+        });
+    </script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (269158 => 269159)


--- trunk/Source/WebCore/ChangeLog	2020-10-29 18:32:05 UTC (rev 269158)
+++ trunk/Source/WebCore/ChangeLog	2020-10-29 18:35:59 UTC (rev 269159)
@@ -1,3 +1,22 @@
+2020-10-29  Said Abou-Hallawa  <[email protected]>
+
+        REGRESSION(269065): [GPU Process]: Order of drawing has to be preserved when drawing a canvas to another canvas
+        https://bugs.webkit.org/show_bug.cgi?id=218324
+
+        Reviewed by Simon Fraser.
+
+        Allow DisplayList::Recorder::Delegate to take an action after appending
+        a DisplayList::Item to its DisplayList::DisplayList.
+
+        Test: fast/canvas/canvas-draw-canvas-on-canvas-flushing-order.html
+
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::didAppendItem):
+        (WebCore::DisplayList::Recorder::appendItemAndUpdateExtent):
+        (WebCore::DisplayList::Recorder::appendItem):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        (WebCore::DisplayList::Recorder::Delegate::didAppendItem):
+
 2020-10-29  Noam Rosenthal  <[email protected]>
 
         REGRESSION(r268249): image-orientation:none is broken for local (file://) urls

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (269158 => 269159)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2020-10-29 18:32:05 UTC (rev 269158)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2020-10-29 18:35:59 UTC (rev 269159)
@@ -125,6 +125,12 @@
     }
 }
 
+void Recorder::didAppendItem(const Item& item)
+{
+    if (m_delegate)
+        m_delegate->didAppendItem(item);
+}
+
 void Recorder::updateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags)
 {
     currentState().stateChange.accumulate(state, flags);
@@ -447,15 +453,17 @@
 
 void Recorder::appendItemAndUpdateExtent(Ref<DrawingItem>&& item)
 {
-    auto& newItem = appendItem(WTFMove(item));
+    DrawingItem& newItem = item.get();
+    appendItem(WTFMove(item));
     updateItemExtent(newItem);
 }
 
-template<typename ItemType>
-ItemType& Recorder::appendItem(Ref<ItemType>&& item)
+void Recorder::appendItem(Ref<Item>&& item)
 {
+    Item& newItem = item.get();
     willAppendItem(item.get());
-    return downcast<ItemType>(m_displayList.append(WTFMove(item)));
+    m_displayList.append(WTFMove(item));
+    didAppendItem(newItem);
 }
 
 void Recorder::updateItemExtent(DrawingItem& item) const

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (269158 => 269159)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-10-29 18:32:05 UTC (rev 269158)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h	2020-10-29 18:35:59 UTC (rev 269159)
@@ -68,6 +68,7 @@
         virtual ~Delegate() { }
         virtual bool lockRemoteImageBuffer(WebCore::ImageBuffer&) { return false; }
         virtual void willAppendItem(const Item&) { };
+        virtual void didAppendItem(const Item&) { };
     };
 
 private:
@@ -147,9 +148,9 @@
 
     FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) override;
 
-    template<typename ItemType>
-    ItemType& appendItem(Ref<ItemType>&&);
+    void appendItem(Ref<Item>&&);
     void willAppendItem(const Item&);
+    void didAppendItem(const Item&);
 
     void appendStateChangeItem(const GraphicsContextStateChange&, GraphicsContextState::StateChangeFlags);
 

Modified: trunk/Source/WebKit/ChangeLog (269158 => 269159)


--- trunk/Source/WebKit/ChangeLog	2020-10-29 18:32:05 UTC (rev 269158)
+++ trunk/Source/WebKit/ChangeLog	2020-10-29 18:35:59 UTC (rev 269159)
@@ -1,3 +1,17 @@
+2020-10-29  Said Abou-Hallawa  <[email protected]>
+
+        REGRESSION(269065): [GPU Process]: Order of drawing has to be preserved when drawing a canvas to another canvas
+        https://bugs.webkit.org/show_bug.cgi?id=218324
+
+        Reviewed by Simon Fraser.
+
+        When drawing an ImageBuffer to another ImageBuffer, the DrawingContext of
+        the source and the destination ImageBuffers have to be flushed immediately.
+        Otherwise an older version or a newer version of the source ImageBuffer
+        might be drawn to the destination ImageBuffer.
+
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+
 2020-10-29  Ryan Haddad  <[email protected]>
 
         Unreviewed, reverting r269109.

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (269158 => 269159)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-10-29 18:32:05 UTC (rev 269158)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2020-10-29 18:35:59 UTC (rev 269159)
@@ -164,7 +164,10 @@
     {
         if (!m_remoteRenderingBackendProxy)
             return false;
-        return m_remoteRenderingBackendProxy->remoteResourceCacheProxy().lockRemoteImageBufferForRemoteClient(imageBuffer, m_renderingResourceIdentifier);
+        if (!m_remoteRenderingBackendProxy->remoteResourceCacheProxy().lockRemoteImageBufferForRemoteClient(imageBuffer, m_renderingResourceIdentifier))
+            return false;
+        imageBuffer.flushDrawingContext();
+        return true;
     }
 
     void willAppendItem(const WebCore::DisplayList::Item&) override
@@ -178,6 +181,12 @@
         displayList.clear();
     }
 
+    void didAppendItem(const WebCore::DisplayList::Item& item) override
+    {
+        if (item.type() == WebCore::DisplayList::ItemType::DrawImageBuffer)
+            flushDrawingContext();
+    }
+
     DisplayListFlushIdentifier m_sentFlushIdentifier;
     DisplayListFlushIdentifier m_receivedFlushIdentifier;
     WebCore::RenderingResourceIdentifier m_renderingResourceIdentifier { WebCore::RenderingResourceIdentifier::generate() };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to