Title: [278918] trunk
Revision
278918
Author
s...@apple.com
Date
2021-06-15 18:47:43 -0700 (Tue, 15 Jun 2021)

Log Message

[GPU Process] ConcreteImageBuffer::baseTransform() returns incorrect transform for unaccelerated ImageBuffer
https://bugs.webkit.org/show_bug.cgi?id=227044
<rdar://78642742>

Reviewed by Simon Fraser.

Source/WebCore:

The static constant ImageBufferBackend::isOriginAtUpperLeftCorner is used
to tell where the origin of the physical graphics context. For CG platforms,
it is at the bottom left corner. This requires the coordinates system to
be moved to the top-left corner and flipped.

The fix is:
1) Rename isOriginAtUpperLeftCorner to isOriginAtBottomLeftCorner since
   it is a description for the physical graphics context. All the logical
   graphics contexts have to have their coordinates system at the top-left
   corner.
2) Set isOriginAtBottomLeftCorner to true in ImageBufferCGBackend only
   so all the super classes inherit the 'true' value. This includes
   ImageBufferShareableBitmapBackend for CG platforms.

Test: fast/canvas/canvas-large-dimensions-drawing.html

* platform/graphics/ConcreteImageBuffer.h:
* platform/graphics/ImageBufferBackend.h:
* platform/graphics/cg/ImageBufferCGBackend.h:
* platform/graphics/cg/ImageBufferCGBitmapBackend.h:
* platform/graphics/cg/ImageBufferIOSurfaceBackend.h:

Source/WebKit:

* Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h:
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h:

LayoutTests:

The large size of the canvas in this layout test will force creating
unaccelerated ImageBufferBackend.

* fast/canvas/canvas-large-dimensions-drawing-expected.html: Added.
* fast/canvas/canvas-large-dimensions-drawing.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278917 => 278918)


--- trunk/LayoutTests/ChangeLog	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/LayoutTests/ChangeLog	2021-06-16 01:47:43 UTC (rev 278918)
@@ -1,3 +1,17 @@
+2021-06-15  Said Abou-Hallawa  <s...@apple.com>
+
+        [GPU Process] ConcreteImageBuffer::baseTransform() returns incorrect transform for unaccelerated ImageBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=227044
+        <rdar://78642742>
+
+        Reviewed by Simon Fraser.
+
+        The large size of the canvas in this layout test will force creating 
+        unaccelerated ImageBufferBackend.
+
+        * fast/canvas/canvas-large-dimensions-drawing-expected.html: Added.
+        * fast/canvas/canvas-large-dimensions-drawing.html: Added.
+
 2021-06-15  Jean-Yves Avenard  <j...@apple.com>
 
         REGRESSION: MSE: Netflix playback sometimes fails when going to "next episode" in series

Added: trunk/LayoutTests/fast/canvas/canvas-large-dimensions-drawing-expected.html (0 => 278918)


--- trunk/LayoutTests/fast/canvas/canvas-large-dimensions-drawing-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-large-dimensions-drawing-expected.html	2021-06-16 01:47:43 UTC (rev 278918)
@@ -0,0 +1,20 @@
+<style>
+    html, body {
+        margin: 0; 
+        height: 100%; 
+        overflow: hidden;
+    }
+    canvas {
+        image-rendering: pixelated;
+    }
+</style>
+<body>
+    <canvas id="canvas" width="120" height="120"></canvas>
+    <script>
+        const canvas = document.getElementById('canvas');
+        const ctx = canvas.getContext('2d');
+
+        ctx.fillStyle = 'green';
+        ctx.fillRect(10, 10, 100, 100);
+    </script>
+</body>

Added: trunk/LayoutTests/fast/canvas/canvas-large-dimensions-drawing.html (0 => 278918)


--- trunk/LayoutTests/fast/canvas/canvas-large-dimensions-drawing.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-large-dimensions-drawing.html	2021-06-16 01:47:43 UTC (rev 278918)
@@ -0,0 +1,22 @@
+<style>
+    html, body {
+        margin: 0; 
+        height: 100%; 
+        overflow: hidden;
+    }
+    canvas {
+        image-rendering: pixelated;
+    }
+</style>
+<body>
+    <canvas id="canvas" width="4096" height="4096"></canvas>
+    <script>
+        const canvas = document.getElementById('canvas');
+        const ctx = canvas.getContext('2d');
+
+        ctx.resetTransform();
+
+        ctx.fillStyle = 'green';
+        ctx.fillRect(10, 10, 100, 100);
+    </script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (278917 => 278918)


--- trunk/Source/WebCore/ChangeLog	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebCore/ChangeLog	2021-06-16 01:47:43 UTC (rev 278918)
@@ -1,3 +1,33 @@
+2021-06-15  Said Abou-Hallawa  <s...@apple.com>
+
+        [GPU Process] ConcreteImageBuffer::baseTransform() returns incorrect transform for unaccelerated ImageBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=227044
+        <rdar://78642742>
+
+        Reviewed by Simon Fraser.
+
+        The static constant ImageBufferBackend::isOriginAtUpperLeftCorner is used
+        to tell where the origin of the physical graphics context. For CG platforms,
+        it is at the bottom left corner. This requires the coordinates system to
+        be moved to the top-left corner and flipped.
+
+        The fix is:
+        1) Rename isOriginAtUpperLeftCorner to isOriginAtBottomLeftCorner since
+           it is a description for the physical graphics context. All the logical
+           graphics contexts have to have their coordinates system at the top-left
+           corner.
+        2) Set isOriginAtBottomLeftCorner to true in ImageBufferCGBackend only
+           so all the super classes inherit the 'true' value. This includes 
+           ImageBufferShareableBitmapBackend for CG platforms.
+
+        Test: fast/canvas/canvas-large-dimensions-drawing.html
+
+        * platform/graphics/ConcreteImageBuffer.h:
+        * platform/graphics/ImageBufferBackend.h:
+        * platform/graphics/cg/ImageBufferCGBackend.h:
+        * platform/graphics/cg/ImageBufferCGBitmapBackend.h:
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
+
 2021-06-15  Andres Gonzalez  <andresg...@apple.com>
 
         iOS - VoiceOver reads incorrectly in content editable element if role="document".

Modified: trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h (278917 => 278918)


--- trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -104,7 +104,7 @@
 
     AffineTransform baseTransform() const override
     {
-        if (BackendType::isOriginAtUpperLeftCorner)
+        if (BackendType::isOriginAtBottomLeftCorner)
             return AffineTransform(1, 0, 0, -1, 0, logicalSize().height());
         return { };
     }

Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h (278917 => 278918)


--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -120,7 +120,7 @@
 
     virtual std::unique_ptr<ThreadSafeImageBufferFlusher> createFlusher() { return nullptr; }
 
-    static constexpr bool isOriginAtUpperLeftCorner = false;
+    static constexpr bool isOriginAtBottomLeftCorner = false;
     static constexpr bool canMapBackingStore = true;
     static constexpr RenderingMode renderingMode = RenderingMode::Unaccelerated;
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h (278917 => 278918)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -51,6 +51,8 @@
 
     std::unique_ptr<ThreadSafeImageBufferFlusher> createFlusher() override;
 
+    static constexpr bool isOriginAtBottomLeftCorner = true;
+
 protected:
     using ImageBufferBackend::ImageBufferBackend;
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h (278917 => 278918)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -53,8 +53,6 @@
     std::optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override;
     void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;
 
-    static constexpr bool isOriginAtUpperLeftCorner = true;
-
 private:
     ImageBufferCGBitmapBackend(const Parameters&, void* data, RetainPtr<CGDataProviderRef>&&, std::unique_ptr<GraphicsContext>&&);
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (278917 => 278918)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -69,7 +69,6 @@
     VolatilityState setVolatile(bool) override;
     void releaseBufferToPool() override;
 
-    static constexpr bool isOriginAtUpperLeftCorner = true;
     static constexpr RenderingMode renderingMode = RenderingMode::Accelerated;
 
 protected:

Modified: trunk/Source/WebKit/ChangeLog (278917 => 278918)


--- trunk/Source/WebKit/ChangeLog	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebKit/ChangeLog	2021-06-16 01:47:43 UTC (rev 278918)
@@ -1,3 +1,14 @@
+2021-06-15  Said Abou-Hallawa  <s...@apple.com>
+
+        [GPU Process] ConcreteImageBuffer::baseTransform() returns incorrect transform for unaccelerated ImageBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=227044
+        <rdar://78642742>
+
+        Reviewed by Simon Fraser.
+
+        * Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h:
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h:
+
 2021-06-15  Jean-Yves Avenard  <j...@apple.com>
 
         REGRESSION: MSE: Netflix playback sometimes fails when going to "next episode" in series

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h (278917 => 278918)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -52,8 +52,6 @@
     std::optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& outputFormat, const WebCore::IntRect&) const override;
     void putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override;
 
-    static constexpr bool isOriginAtUpperLeftCorner = true;
-
 protected:
     CGDisplayListImageBufferBackend(const Parameters&, std::unique_ptr<WebCore::GraphicsContext>&&);
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (278917 => 278918)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h	2021-06-16 01:01:52 UTC (rev 278917)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h	2021-06-16 01:47:43 UTC (rev 278918)
@@ -62,7 +62,7 @@
     std::optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& outputFormat, const WebCore::IntRect&) const override;
     void putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override;
 
-    static constexpr bool isOriginAtUpperLeftCorner = true;
+    static constexpr bool isOriginAtBottomLeftCorner = true;
     static constexpr bool canMapBackingStore = false;
     static constexpr WebCore::RenderingMode renderingMode = WebCore::RenderingMode::Accelerated;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to