Title: [114268] trunk/Source/WebCore
Revision
114268
Author
commit-qu...@webkit.org
Date
2012-04-16 10:06:14 -0700 (Mon, 16 Apr 2012)

Log Message

Update GraphicsContext3DOpenGLES.cpp and fix some issues to build with GLES.
https://bugs.webkit.org/show_bug.cgi?id=83982

Patch by ChangSeok Oh <shivami...@gmail.com> on 2012-04-16
Reviewed by Martin Robinson.

GL_BGRA is not defined in GLESv2, so it causes build-break at readRenderingResults.
To resolve this, a helper function readPixelsAndConvertToBGRAIfNecessary is added
in GC3DOpenGL.cpp & GC3DOpenGLES.cpp and it's used in GC3DOpenGLCommon.cpp.
And some other issues to build with GLES are gone with this patch.

No new tests, since no new feature.

* platform/graphics/GraphicsContext3D.h:
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
(WebCore):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::readRenderingResults):
* platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
(WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
(WebCore):
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114267 => 114268)


--- trunk/Source/WebCore/ChangeLog	2012-04-16 17:03:42 UTC (rev 114267)
+++ trunk/Source/WebCore/ChangeLog	2012-04-16 17:06:14 UTC (rev 114268)
@@ -1,3 +1,29 @@
+2012-04-16  ChangSeok Oh  <shivami...@gmail.com>
+
+        Update GraphicsContext3DOpenGLES.cpp and fix some issues to build with GLES.
+        https://bugs.webkit.org/show_bug.cgi?id=83982
+
+        Reviewed by Martin Robinson.
+
+        GL_BGRA is not defined in GLESv2, so it causes build-break at readRenderingResults.
+        To resolve this, a helper function readPixelsAndConvertToBGRAIfNecessary is added
+        in GC3DOpenGL.cpp & GC3DOpenGLES.cpp and it's used in GC3DOpenGLCommon.cpp.
+        And some other issues to build with GLES are gone with this patch.
+
+        No new tests, since no new feature.
+
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+        (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
+        (WebCore):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::readRenderingResults):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
+        (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
+        (WebCore):
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary):
+
 2012-04-16  Xiaomei Ji  <x...@chromium.org>
 
         [chromium] wrong justification for arabic/persian page in cr-win.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (114267 => 114268)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-04-16 17:03:42 UTC (rev 114267)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-04-16 17:06:14 UTC (rev 114268)
@@ -907,6 +907,7 @@
     // Read rendering results into a pixel array with the same format as the
     // backbuffer.
     void readRenderingResults(unsigned char* pixels, int pixelsSize);
+    void readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels);
 #endif
 
     bool reshapeFBOs(const IntSize&);

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp (114267 => 114268)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp	2012-04-16 17:03:42 UTC (rev 114267)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp	2012-04-16 17:06:14 UTC (rev 114268)
@@ -42,6 +42,11 @@
 
 namespace WebCore {
 
+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);
+}
+
 bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 {
     const int width = size.width();

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (114267 => 114268)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2012-04-16 17:03:42 UTC (rev 114267)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2012-04-16 17:06:14 UTC (rev 114268)
@@ -184,8 +184,7 @@
 
 void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize)
 {
-    int totalBytes = m_currentWidth * m_currentHeight * 4;
-    if (pixelsSize < totalBytes)
+    if (pixelsSize < m_currentWidth * m_currentHeight * 4)
         return;
 
     makeContextCurrent();
@@ -210,11 +209,7 @@
         mustRestorePackAlignment = true;
     }
 
-    ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
-    if (isGLES2Compliant()) {
-        for (int i = 0; i < totalBytes; i += 4)
-            std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA.
-    }
+    readPixelsAndConvertToBGRAIfNecessary(0, 0, m_currentWidth, m_currentHeight, pixels);
 
     if (mustRestorePackAlignment)
         ::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);

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


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp	2012-04-16 17:03:42 UTC (rev 114267)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp	2012-04-16 17:06:14 UTC (rev 114268)
@@ -30,6 +30,7 @@
 
 #include "GraphicsContext3D.h"
 
+#include "Extensions3DOpenGL.h"
 #include "IntRect.h"
 #include "IntSize.h"
 #include "NotImplemented.h"
@@ -40,6 +41,14 @@
 
 namespace WebCore {
 
+void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
+{
+    const int totalBytes = m_currentWidth * m_currentHeight * 4;
+    ::glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+    for (int i = 0; i < totalBytes; i += 4)
+        std::swap(pixels[i], pixels[i + 2]); // Convert to BGRA.
+}
+
 bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 {
     const int width = size.width();
@@ -80,7 +89,7 @@
     if (m_attrs.stencil || m_attrs.depth) {
         // Use a 24 bit depth buffer where we know we have it.
         if (supportPackedDepthStencilBuffer) {
-            ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffr);
+            ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffer);
             ::glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, width, height, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 0);
             if (m_attrs.stencil)
                 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);
@@ -88,12 +97,12 @@
                 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);
             ::glBindTexture(GL_TEXTURE_2D, 0);
         } else {
-            if (m_attributes.stencil) {
+            if (m_attrs.stencil) {
                 ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_stencilBuffer);
                 ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8, width, height);
                 ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_stencilBuffer);
             }
-            if (m_attributes.depth) {
+            if (m_attrs.depth) {
                 ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer);
                 ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, width, height);
                 ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer);
@@ -109,7 +118,7 @@
     return mustRestoreFBO;
 }
 
-void GraphicsContext3D::resolveMultisamplingIfNecessary(IntRect& rect)
+void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect)
 {
     // FIXME: We don't support antialiasing yet.
     notImplemented();
@@ -147,4 +156,6 @@
     return true;
 }
 
+} // namespace WebCore
+
 #endif // ENABLE(WEBGL)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to