Commit c55d2b41 by James Darpinian Committed by Commit Bot

Respect IOSurface stride

In the iOS simulator we use glReadPixels to transfer rendered pixels to the IOSurface. We need to account for the possibility of the row stride not being equal to the width, because that happens sometimes. It's currently causing corrupt rendering in Google Maps on WebKit. Bug: angleproject:4611 Change-Id: I553d65cb0d0bf922e855ea50089904807dd39118 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2181676Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: James Darpinian <jdarpinian@chromium.org>
parent 8270ebbd
...@@ -75,6 +75,7 @@ class IOSurfaceSurfaceEAGL : public SurfaceGL ...@@ -75,6 +75,7 @@ class IOSurfaceSurfaceEAGL : public SurfaceGL
int mHeight; int mHeight;
int mPlane; int mPlane;
int mFormatIndex; int mFormatIndex;
int mRowStrideInPixels;
bool mAlphaInitialized; bool mAlphaInitialized;
#if defined(ANGLE_PLATFORM_IOS_SIMULATOR) #if defined(ANGLE_PLATFORM_IOS_SIMULATOR)
......
...@@ -83,6 +83,7 @@ IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state, ...@@ -83,6 +83,7 @@ IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
mWidth(0), mWidth(0),
mHeight(0), mHeight(0),
mPlane(0), mPlane(0),
mRowStrideInPixels(0),
mFormatIndex(-1), mFormatIndex(-1),
mAlphaInitialized(false) mAlphaInitialized(false)
{ {
...@@ -94,6 +95,14 @@ IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state, ...@@ -94,6 +95,14 @@ IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
mWidth = static_cast<int>(attribs.get(EGL_WIDTH)); mWidth = static_cast<int>(attribs.get(EGL_WIDTH));
mHeight = static_cast<int>(attribs.get(EGL_HEIGHT)); mHeight = static_cast<int>(attribs.get(EGL_HEIGHT));
mPlane = static_cast<int>(attribs.get(EGL_IOSURFACE_PLANE_ANGLE)); 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 internalFormat = attribs.get(EGL_TEXTURE_INTERNAL_FORMAT_ANGLE);
EGLAttrib type = attribs.get(EGL_TEXTURE_TYPE_ANGLE); EGLAttrib type = attribs.get(EGL_TEXTURE_TYPE_ANGLE);
...@@ -227,6 +236,7 @@ egl::Error IOSurfaceSurfaceEAGL::releaseTexImage(const gl::Context *context, EGL ...@@ -227,6 +236,7 @@ egl::Error IOSurfaceSurfaceEAGL::releaseTexImage(const gl::Context *context, EGL
functions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, functions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
mBoundTextureID, 0); mBoundTextureID, 0);
gl::PixelPackState state; gl::PixelPackState state;
state.rowLength = mRowStrideInPixels;
state.alignment = 1; state.alignment = 1;
stateManager->setPixelPackState(state); stateManager->setPixelPackState(state);
// TODO(kbr): possibly more state to be set here, including setting any // TODO(kbr): possibly more state to be set here, including setting any
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment