Fix Google Maps rendering corruption in simulator with ANGLE
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2020 18:42:21 +0000 (18:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 May 2020 18:42:21 +0000 (18:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211398

glReadPixels call needs to respect the row stride of the IOSurface.

Patch by James Darpinian <jdarpinian@chromium.org> on 2020-05-07
Reviewed by Alex Christensen.

* src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h:
* src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm:
(rx::IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL):
(rx::IOSurfaceSurfaceEAGL::releaseTexImage):

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

Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm

index ec0e385..0aa3ba3 100644 (file)
@@ -1,3 +1,17 @@
+2020-05-07  James Darpinian  <jdarpinian@chromium.org>
+
+        Fix Google Maps rendering corruption in simulator with ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=211398
+
+        glReadPixels call needs to respect the row stride of the IOSurface.
+
+        Reviewed by Alex Christensen.
+
+        * src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h:
+        * src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm:
+        (rx::IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL):
+        (rx::IOSurfaceSurfaceEAGL::releaseTexImage):
+
 2020-05-07  Dean Jackson  <dino@apple.com>
 
         Update ANGLE to 2020-03-27
index 4c7fb07..c2ce06f 100644 (file)
@@ -75,6 +75,7 @@ class IOSurfaceSurfaceEAGL : public SurfaceGL
     int mHeight;
     int mPlane;
     int mFormatIndex;
+    int mRowStrideInPixels;
 
     bool mAlphaInitialized;
 #if defined(ANGLE_PLATFORM_IOS_SIMULATOR)
index 3ca0e1c..069d7a3 100644 (file)
@@ -83,6 +83,7 @@ IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
       mWidth(0),
       mHeight(0),
       mPlane(0),
+      mRowStrideInPixels(0),
       mFormatIndex(-1),
       mAlphaInitialized(false)
 {
@@ -94,6 +95,11 @@ IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
     mWidth  = static_cast<int>(attribs.get(EGL_WIDTH));
     mHeight = static_cast<int>(attribs.get(EGL_HEIGHT));
     mPlane  = static_cast<int>(attribs.get(EGL_IOSURFACE_PLANE_ANGLE));
+    // Hopefully the number of bytes per row is always an integer number of pixels.
+    // We use glReadPixels to fill the IOSurface in the simulator and it can only
+    // support strides that are an integer number of pixels.
+    ASSERT(IOSurfaceGetBytesPerRowOfPlane(mIOSurface, mPlane) % IOSurfaceGetBytesPerElementOfPlane(mIOSurface, mPlane) == 0);
+    mRowStrideInPixels = static_cast<int>(IOSurfaceGetBytesPerRowOfPlane(mIOSurface, mPlane) / IOSurfaceGetBytesPerElementOfPlane(mIOSurface, mPlane));
 
     EGLAttrib internalFormat = attribs.get(EGL_TEXTURE_INTERNAL_FORMAT_ANGLE);
     EGLAttrib type           = attribs.get(EGL_TEXTURE_TYPE_ANGLE);
@@ -227,6 +233,7 @@ egl::Error IOSurfaceSurfaceEAGL::releaseTexImage(const gl::Context *context, EGL
         functions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                         mBoundTextureID, 0);
         gl::PixelPackState state;
+        state.rowLength = mRowStrideInPixels;
         state.alignment = 1;
         stateManager->setPixelPackState(state);
         // TODO(kbr): possibly more state to be set here, including setting any