Title: [291032] trunk
Revision
291032
Author
[email protected]
Date
2022-03-08 22:49:50 -0800 (Tue, 08 Mar 2022)

Log Message

RemoteGraphicsContextGL ReadPixels does not preserve contents for area that is not part of the Framebuffer
https://bugs.webkit.org/show_bug.cgi?id=222410
<rdar://problem/75025951>

Patch by John Cunningham <[email protected]> on 2022-03-08
Reviewed by Kimmo Kinnunen.

Source/WebKit:

Make a copy of the data buffer passed into readnpixels so that reads outside the framebuffer contain
the expected results, rather than being zero'd.

* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::readnPixels0):
(WebKit::RemoteGraphicsContextGL::readnPixels1):
* GPUProcess/graphics/RemoteGraphicsContextGL.h:
* GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
(bufferSubData):
(readnPixels0): Deleted.
(readnPixels1): Deleted.
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::readnPixels):
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:
(WebKit::RemoteGraphicsContextGLProxy::readnPixels): Deleted.

Tools:

Make a copy of the data buffer passed into readnpixels so that reads outside the framebuffer contain
the expected results, rather than being zero'd.

* Scripts/generate-gpup-webgl:

LayoutTests:

Don't overwrite the data buffer for readPixels

* platform/ios-wk2/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291031 => 291032)


--- trunk/LayoutTests/ChangeLog	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/LayoutTests/ChangeLog	2022-03-09 06:49:50 UTC (rev 291032)
@@ -1,3 +1,15 @@
+2022-03-08  John Cunningham  <[email protected]>
+
+        RemoteGraphicsContextGL ReadPixels does not preserve contents for area that is not part of the Framebuffer
+        https://bugs.webkit.org/show_bug.cgi?id=222410
+        <rdar://problem/75025951>
+
+        Reviewed by Kimmo Kinnunen.
+
+        Don't overwrite the data buffer for readPixels
+
+        * platform/ios-wk2/TestExpectations:
+
 2022-03-08  Chris Dumez  <[email protected]>
 
         IntersectionObserver is causing massive document leaks on haaretz.co.il

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (291031 => 291032)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2022-03-09 06:49:50 UTC (rev 291032)
@@ -2227,7 +2227,6 @@
 http/wpt/html/semantics/text-level-semantics/the-a-element/a-download-click-404.html [ Pass Failure ]
 
 # Test failures from turning GPU Process on by default
-webkit.org/b/234536 webgl/2.0.0/conformance/reading/read-pixels-test.html
 webkit.org/b/234536 webxr/high-performance.html
 webkit.org/b/234536 webgl/1.0.3/conformance/state/gl-object-get-calls.html [ Timeout ]
 

Modified: trunk/Source/WebKit/ChangeLog (291031 => 291032)


--- trunk/Source/WebKit/ChangeLog	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/ChangeLog	2022-03-09 06:49:50 UTC (rev 291032)
@@ -1,3 +1,29 @@
+2022-03-08  John Cunningham  <[email protected]>
+
+        RemoteGraphicsContextGL ReadPixels does not preserve contents for area that is not part of the Framebuffer
+        https://bugs.webkit.org/show_bug.cgi?id=222410
+        <rdar://problem/75025951>
+
+        Reviewed by Kimmo Kinnunen.
+
+        Make a copy of the data buffer passed into readnpixels so that reads outside the framebuffer contain
+        the expected results, rather than being zero'd.
+
+        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+        (WebKit::RemoteGraphicsContextGL::readnPixels0):
+        (WebKit::RemoteGraphicsContextGL::readnPixels1):
+        * GPUProcess/graphics/RemoteGraphicsContextGL.h:
+        * GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
+        * GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
+        (bufferSubData):
+        (readnPixels0): Deleted.
+        (readnPixels1): Deleted.
+        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
+        (WebKit::RemoteGraphicsContextGLProxy::readnPixels):
+        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
+        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:
+        (WebKit::RemoteGraphicsContextGLProxy::readnPixels): Deleted.
+
 2022-03-08  Simon Fraser  <[email protected]>
 
         Fix assertion when DOM Rendering in GPU Process is enabled with accelerated drawing disabled

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (291031 => 291032)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2022-03-09 06:49:50 UTC (rev 291032)
@@ -303,6 +303,20 @@
     m_context->simulateEventForTesting(event);
 }
 
+void RemoteGraphicsContextGL::readnPixels0(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t>&& data, CompletionHandler<void(IPC::ArrayReference<uint8_t>)>&& completionHandler)
+{
+    assertIsCurrent(workQueue());
+    Vector<uint8_t, 4> pixels(data);
+    m_context->readnPixels(x, y, width, height, format, type, pixels);
+    completionHandler(IPC::ArrayReference<uint8_t>(reinterpret_cast<uint8_t*>(pixels.data()), pixels.size()));
+}
+
+void RemoteGraphicsContextGL::readnPixels1(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t offset)
+{
+    assertIsCurrent(workQueue());
+    m_context->readnPixels(x, y, width, height, format, type, static_cast<GCGLintptr>(offset));
+}
+
 } // namespace WebKit
 
 #endif

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h (291031 => 291032)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h	2022-03-09 06:49:50 UTC (rev 291032)
@@ -126,6 +126,8 @@
     void copyTextureFromVideoFrame(RemoteVideoFrameReadReference, uint32_t texture, uint32_t target, int32_t level, uint32_t internalFormat, uint32_t format, uint32_t type, bool premultiplyAlpha, bool flipY, CompletionHandler<void(bool)>&&);
 #endif
     void simulateEventForTesting(WebCore::GraphicsContextGL::SimulatedEventForTesting);
+    void readnPixels0(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t>&& data, CompletionHandler<void(IPC::ArrayReference<uint8_t>)>&&);
+    void readnPixels1(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t offset);
 
 #include "RemoteGraphicsContextGLFunctionsGenerated.h" // NOLINT
 

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in (291031 => 291032)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in	2022-03-09 06:49:50 UTC (rev 291032)
@@ -48,6 +48,8 @@
     void PaintCompositedResultsToMediaSample() -> (std::optional<WebKit::RemoteVideoFrameProxy::Properties> properties) Synchronous
 #endif
     void SimulateEventForTesting(WebCore::GraphicsContextGL::SimulatedEventForTesting event)
+    void ReadnPixels0(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t> data) -> (IPC::ArrayReference<uint8_t> data) Synchronous
+    void ReadnPixels1(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t offset)
 
     void MoveErrorsToSyntheticErrorList() -> (bool returnValue) Synchronous
     void ActiveTexture(uint32_t texture)
@@ -183,8 +185,6 @@
     void BufferData0(uint32_t target, uint64_t arg1, uint32_t usage)
     void BufferData1(uint32_t target, IPC::ArrayReference<uint8_t> data, uint32_t usage)
     void BufferSubData(uint32_t target, uint64_t offset, IPC::ArrayReference<uint8_t> data)
-    void ReadnPixels0(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t dataSize) -> (IPC::ArrayReference<uint8_t> data) Synchronous
-    void ReadnPixels1(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t offset)
     void TexImage2D0(uint32_t target, int32_t level, uint32_t internalformat, int32_t width, int32_t height, int32_t border, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t> pixels)
     void TexImage2D1(uint32_t target, int32_t level, uint32_t internalformat, int32_t width, int32_t height, int32_t border, uint32_t format, uint32_t type, uint64_t offset)
     void TexSubImage2D0(uint32_t target, int32_t level, int32_t xoffset, int32_t yoffset, int32_t width, int32_t height, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t> pixels)

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h (291031 => 291032)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h	2022-03-09 06:49:50 UTC (rev 291032)
@@ -778,18 +778,6 @@
         assertIsCurrent(workQueue());
         m_context->bufferSubData(target, static_cast<GCGLintptr>(offset), makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(data.data()), data.size()));
     }
-    void readnPixels0(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t dataSize, CompletionHandler<void(IPC::ArrayReference<uint8_t>)>&& completionHandler)
-    {
-        Vector<GCGLchar, 4> data(static_cast<size_t>(dataSize), 0);
-        assertIsCurrent(workQueue());
-        m_context->readnPixels(x, y, width, height, format, type, data);
-        completionHandler(IPC::ArrayReference<uint8_t>(reinterpret_cast<uint8_t*>(data.data()), data.size()));
-    }
-    void readnPixels1(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t offset)
-    {
-        assertIsCurrent(workQueue());
-        m_context->readnPixels(x, y, width, height, format, type, static_cast<GCGLintptr>(offset));
-    }
     void texImage2D0(uint32_t target, int32_t level, uint32_t internalformat, int32_t width, int32_t height, int32_t border, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t>&& pixels)
     {
         assertIsCurrent(workQueue());

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp (291031 => 291032)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp	2022-03-09 06:49:50 UTC (rev 291032)
@@ -233,6 +233,27 @@
     }
 }
 
+void RemoteGraphicsContextGLProxy::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data)
+{
+    IPC::ArrayReference<uint8_t> dataReply;
+    if (!isContextLost()) {
+        auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::ReadnPixels0(x, y, width, height, format, type, IPC::ArrayReference<uint8_t>(reinterpret_cast<uint8_t*>(data.data), data.bufSize)), Messages::RemoteGraphicsContextGL::ReadnPixels0::Reply(dataReply));
+        if (!sendResult)
+            markContextLost();
+        else
+            memcpy(data.data, dataReply.data(), data.bufSize * sizeof(uint8_t));
+    }
+}
+
+void RemoteGraphicsContextGLProxy::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
+{
+    if (!isContextLost()) {
+        auto sendResult = send(Messages::RemoteGraphicsContextGL::ReadnPixels1(x, y, width, height, format, type, static_cast<uint64_t>(offset)));
+        if (!sendResult)
+            markContextLost();
+    }
+}
+
 void RemoteGraphicsContextGLProxy::wasCreated(bool didSucceed, IPC::Semaphore&& semaphore, String&& availableExtensions, String&& requestedExtensions)
 {
     if (isContextLost())

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h (291031 => 291032)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h	2022-03-09 06:49:50 UTC (rev 291032)
@@ -77,6 +77,8 @@
     bool copyTextureFromMedia(WebCore::MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
 #endif
     void simulateEventForTesting(SimulatedEventForTesting) final;
+    void readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data) final;
+    void readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
 
     // Functions with a generated implementation. This list is used by generate-gpup-webgl script.
     bool moveErrorsToSyntheticErrorList() final;
@@ -213,8 +215,6 @@
     void bufferData(GCGLenum target, GCGLsizeiptr arg1, GCGLenum usage) final;
     void bufferData(GCGLenum target, GCGLSpan<const GCGLvoid> data, GCGLenum usage) final;
     void bufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<const GCGLvoid> data) final;
-    void readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data) final;
-    void readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
     void texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels) final;
     void texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
     void texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels) final;

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp (291031 => 291032)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp	2022-03-09 06:49:50 UTC (rev 291032)
@@ -1328,27 +1328,6 @@
     }
 }
 
-void RemoteGraphicsContextGLProxy::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data)
-{
-    IPC::ArrayReference<uint8_t> dataReply;
-    if (!isContextLost()) {
-        auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::ReadnPixels0(x, y, width, height, format, type, data.bufSize), Messages::RemoteGraphicsContextGL::ReadnPixels0::Reply(dataReply));
-        if (!sendResult)
-            markContextLost();
-        else
-            memcpy(data.data, dataReply.data(), data.bufSize * sizeof(uint8_t));
-    }
-}
-
-void RemoteGraphicsContextGLProxy::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
-{
-    if (!isContextLost()) {
-        auto sendResult = send(Messages::RemoteGraphicsContextGL::ReadnPixels1(x, y, width, height, format, type, static_cast<uint64_t>(offset)));
-        if (!sendResult)
-            markContextLost();
-    }
-}
-
 void RemoteGraphicsContextGLProxy::texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
 {
     if (!isContextLost()) {

Modified: trunk/Tools/ChangeLog (291031 => 291032)


--- trunk/Tools/ChangeLog	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Tools/ChangeLog	2022-03-09 06:49:50 UTC (rev 291032)
@@ -1,3 +1,16 @@
+2022-03-08  John Cunningham  <[email protected]>
+
+        RemoteGraphicsContextGL ReadPixels does not preserve contents for area that is not part of the Framebuffer
+        https://bugs.webkit.org/show_bug.cgi?id=222410
+        <rdar://problem/75025951>
+
+        Reviewed by Kimmo Kinnunen.
+
+        Make a copy of the data buffer passed into readnpixels so that reads outside the framebuffer contain
+        the expected results, rather than being zero'd.
+
+        * Scripts/generate-gpup-webgl:
+
 2022-03-08  Jean-Yves Avenard  <[email protected]>
 
         Split SourceBufferParserWebM and have platform agnostic WebMParser

Modified: trunk/Tools/Scripts/generate-gpup-webgl (291031 => 291032)


--- trunk/Tools/Scripts/generate-gpup-webgl	2022-03-09 06:19:52 UTC (rev 291031)
+++ trunk/Tools/Scripts/generate-gpup-webgl	2022-03-09 06:49:50 UTC (rev 291032)
@@ -112,6 +112,8 @@
     void PaintCompositedResultsToMediaSample() -> (std::optional<WebKit::RemoteVideoFrameProxy::Properties> properties) Synchronous
 #endif
     void SimulateEventForTesting(WebCore::GraphicsContextGL::SimulatedEventForTesting event)
+    void ReadnPixels0(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, IPC::ArrayReference<uint8_t> data) -> (IPC::ArrayReference<uint8_t> data) Synchronous
+    void ReadnPixels1(int32_t x, int32_t y, int32_t width, int32_t height, uint32_t format, uint32_t type, uint64_t offset)
 {}
 }}
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to