Title: [123745] trunk/Source/WebCore
Revision
123745
Author
commit-qu...@webkit.org
Date
2012-07-26 07:54:23 -0700 (Thu, 26 Jul 2012)

Log Message

[WebGL] GraphicsContext3D::readPixels has extraneous code from GraphicsContext3D::readPixelsIMG
https://bugs.webkit.org/show_bug.cgi?id=92302

Patch by Joshua Netterfield <jnetterfi...@rim.com> on 2012-07-26
Reviewed by Noam Rosenthal.

This undoes a mistake from https://bugs.webkit.org/show_bug.cgi?id=90567.

No new tests, because it introduces no new functionality, but it makes the WebGL aquarium demo
run quite a bit smoother on SGX :)

* platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
(WebCore::GraphicsContext3D::readPixels):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123744 => 123745)


--- trunk/Source/WebCore/ChangeLog	2012-07-26 14:49:36 UTC (rev 123744)
+++ trunk/Source/WebCore/ChangeLog	2012-07-26 14:54:23 UTC (rev 123745)
@@ -1,3 +1,18 @@
+2012-07-26  Joshua Netterfield  <jnetterfi...@rim.com>
+
+        [WebGL] GraphicsContext3D::readPixels has extraneous code from GraphicsContext3D::readPixelsIMG
+        https://bugs.webkit.org/show_bug.cgi?id=92302
+
+        Reviewed by Noam Rosenthal.
+
+        This undoes a mistake from https://bugs.webkit.org/show_bug.cgi?id=90567.
+
+        No new tests, because it introduces no new functionality, but it makes the WebGL aquarium demo
+        run quite a bit smoother on SGX :)
+
+        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
+        (WebCore::GraphicsContext3D::readPixels):
+
 2012-07-26  Yury Semikhatsky  <yu...@chromium.org>
 
         Unreviewed. Revert r123740 as it breaks AppleMac compilation.

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp (123744 => 123745)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp	2012-07-26 14:49:36 UTC (rev 123744)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp	2012-07-26 14:54:23 UTC (rev 123745)
@@ -50,55 +50,10 @@
 
 void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
 {
-    // Currently only format=RGBA, type=UNSIGNED_BYTE is supported by the specification: http://www.khronos.org/registry/webgl/specs/latest/
-    // If this ever changes, this code will need to be updated.
-
-    // Calculate the strides of our data and canvas
-    unsigned int formatSize = 4; // RGBA UNSIGNED_BYTE
-    unsigned int dataStride = width * formatSize;
-    unsigned int canvasStride = m_currentWidth * formatSize;
-
-    // If we are using a pack alignment of 8, then we need to align our strides to 8 byte boundaries
-    // See: http://en.wikipedia.org/wiki/Data_structure_alignment (computing padding)
-    int packAlignment;
-    glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
-    if (8 == packAlignment) {
-        dataStride = (dataStride + 7) & ~7;
-        canvasStride = (canvasStride + 7) & ~7;
-    }
-
-    unsigned char* canvasData = new unsigned char[canvasStride * m_currentHeight];
-    ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, format, type, canvasData);
-
-    // If we failed to read our canvas data due to a GL error, don't continue
-    int error = glGetError();
-    if (GL_NO_ERROR != error) {
-        synthesizeGLError(error);
-        return;
-    }
-
-    // Clear our data in case some of it lies outside the bounds of our canvas
-    // TODO: don't do this if all of the data lies inside the bounds of the canvas
-    memset(data, 0, dataStride * height);
-
-    // Calculate the intersection of our canvas and data bounds
-    IntRect dataRect(x, y, width, height);
-    IntRect canvasRect(0, 0, m_currentWidth, m_currentHeight);
-    IntRect nonZeroDataRect = intersection(dataRect, canvasRect);
-
-    unsigned int xDataOffset = x < 0 ? -x * formatSize : 0;
-    unsigned int yDataOffset = y < 0 ? -y * dataStride : 0;
-    unsigned int xCanvasOffset = nonZeroDataRect.x() * formatSize;
-    unsigned int yCanvasOffset = nonZeroDataRect.y() * canvasStride;
-    unsigned char* dst = static_cast<unsigned char*>(data) + xDataOffset + yDataOffset;
-    unsigned char* src = "" + xCanvasOffset + yCanvasOffset;
-    for (int row = 0; row < nonZeroDataRect.height(); row++) {
-        memcpy(dst, src, nonZeroDataRect.width() * formatSize);
-        dst += dataStride;
-        src += canvasStride;
-    }
-
-    delete [] canvasData;
+    makeContextCurrent();
+    // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
+    // all previous rendering calls should be done before reading pixels.
+    ::glFlush();
 #if PLATFORM(BLACKBERRY)
     // Imagination specific fix
     if (m_isImaginationHardware)
@@ -108,6 +63,12 @@
 
     // Note: BlackBerries have a different anti-aliasing pipeline.
 #else
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+        ::glFlush();
+    }
+
     ::glReadPixels(x, y, width, height, format, type, data);
 
     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to