Modified: trunk/Source/WebCore/ChangeLog (174743 => 174744)
--- trunk/Source/WebCore/ChangeLog 2014-10-15 20:56:11 UTC (rev 174743)
+++ trunk/Source/WebCore/ChangeLog 2014-10-15 21:41:06 UTC (rev 174744)
@@ -1,3 +1,17 @@
+2014-10-15 Roger Fong <[email protected]>
+
+ glReadPixels on NVIDIA cards returns the wrong values for the alpha channel when alpha is off.
+ https://bugs.webkit.org/show_bug.cgi?id=137752.
+ <rdar://problem/15408133>
+
+ Reviewed by Brent Fulgham.
+
+ This change fixed the 1.0.2 conformance test: context/context-attribute-preserve-drawing-buffer.html
+
+ * platform/graphics/GraphicsContext3D.h:
+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+ Manually set the alpha channel to 255 when alpha is off on the rendering context.
+
2014-10-13 Chris Fleizach <[email protected]>
AX: Going back is broken for VoiceOver
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (174743 => 174744)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2014-10-15 20:56:11 UTC (rev 174743)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2014-10-15 21:41:06 UTC (rev 174744)
@@ -989,6 +989,7 @@
// backbuffer.
void readRenderingResults(unsigned char* pixels, int pixelsSize);
void readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels);
+ void callGLReadPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, unsigned char* pixels);
#if PLATFORM(IOS)
bool setRenderbufferStorageFromDrawable(GC3Dsizei width, GC3Dsizei height);
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp (174743 => 174744)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp 2014-10-15 20:56:11 UTC (rev 174743)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp 2014-10-15 21:41:06 UTC (rev 174744)
@@ -65,7 +65,7 @@
void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
{
- ::glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
+ callGLReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
}
void GraphicsContext3D::validateAttributes()
@@ -356,11 +356,24 @@
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
::glFlush();
}
- ::glReadPixels(x, y, width, height, format, type, data);
+ callGLReadPixels(x, y, width, height, format, type, static_cast<unsigned char*>(data));
+
if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
}
+void GraphicsContext3D::callGLReadPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, unsigned char* pixels)
+{
+ ::glReadPixels(x, y, width, height, format, type, pixels);
+ int totalBytes = width*height*4;
+ // FIXME: There is a bug with the NVIDIA drivers where if alpha is off,
+ // readPixels returns 0 for the alpha channel instead of 255.
+ if (getExtensions()->isNVIDIA() && !m_attrs.alpha) {
+ for (int i = 0; i < totalBytes; i += 4)
+ pixels[i+3] = 255;
+ }
}
+}
+
#endif // USE(3D_GRAPHICS)