[Texmap][Qt] Enable TextureMapperGL in platforms where BGRA is not present
authornoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 10:51:59 +0000 (10:51 +0000)
committernoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Sep 2011 10:51:59 +0000 (10:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65473

Reviewed by Andreas Kling.

For now, swap RGBA->BGRA in software if we're in OpenGL ES 2.
We do that by iterating on the pixels and manually swapping each pixel's red and blue
values. This can be done faster with shaders, but for now this is a working solution
for platforms without BGRA support.

No new tests. Existing layout tests cover this.

* platform/graphics/opengl/TextureMapperGL.cpp:
(WebCore::BitmapTextureGL::endPaint):
* platform/graphics/opengl/TextureMapperGL.h:
* platform/graphics/qt/TextureMapperQt.cpp:
(WebCore::RGBA32PremultimpliedBufferQt::swapRGB):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp
Source/WebCore/platform/graphics/opengl/TextureMapperGL.h
Source/WebCore/platform/graphics/qt/TextureMapperQt.cpp

index e0a1d0b..259ba33 100644 (file)
@@ -1,3 +1,23 @@
+2011-09-26  No'am Rosenthal  <noam.rosenthal@nokia.com>
+
+        [Texmap][Qt] Enable TextureMapperGL in platforms where BGRA is not present
+        https://bugs.webkit.org/show_bug.cgi?id=65473
+
+        Reviewed by Andreas Kling.
+
+        For now, swap RGBA->BGRA in software if we're in OpenGL ES 2.
+        We do that by iterating on the pixels and manually swapping each pixel's red and blue
+        values. This can be done faster with shaders, but for now this is a working solution
+        for platforms without BGRA support.
+
+        No new tests. Existing layout tests cover this.
+
+        * platform/graphics/opengl/TextureMapperGL.cpp:
+        (WebCore::BitmapTextureGL::endPaint):
+        * platform/graphics/opengl/TextureMapperGL.h:
+        * platform/graphics/qt/TextureMapperQt.cpp:
+        (WebCore::RGBA32PremultimpliedBufferQt::swapRGB):
+
 2011-09-26  Sergio Villar Senin  <svillar@igalia.com>
 
         [GTK] Fix coding style bits in ResourceHandleSoup.cpp
index 4e2dde1..fe8b894 100644 (file)
@@ -534,7 +534,13 @@ void BitmapTextureGL::endPaint()
         return;
     m_buffer->endPaint();
     GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id))
+#ifdef TEXMAP_OPENGL_ES_2
+    // FIXME: use shaders for RGBA->BGRA swap if this becomes a performance issue.
+    m_buffer->swapRGB();
+    GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirtyRect.x(), m_dirtyRect.y(), m_dirtyRect.width(), m_dirtyRect.height(), GL_RGBA, GL_UNSIGNED_BYTE, m_buffer->data()))
+#else
     GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirtyRect.x(), m_dirtyRect.y(), m_dirtyRect.width(), m_dirtyRect.height(), GL_BGRA, GL_UNSIGNED_BYTE, m_buffer->data()))
+#endif
     m_buffer.clear();
 }
 
index 5306918..305b496 100644 (file)
@@ -67,6 +67,7 @@ class RGBA32PremultimpliedBuffer : public RefCounted<RGBA32PremultimpliedBuffer>
 public:
     virtual ~RGBA32PremultimpliedBuffer() {}
     virtual PlatformGraphicsContext* beginPaint(const IntRect& dirtyRect, bool opaque) = 0;
+    virtual void swapRGB() = 0;
     virtual void endPaint() = 0;
     virtual const void* data() const = 0;
     static PassRefPtr<RGBA32PremultimpliedBuffer> create();
index 332b185..41112f4 100644 (file)
@@ -228,6 +228,11 @@ public:
         return &m_painter;
     }
 
+    void swapRGB()
+    {
+        m_image = m_image.rgbSwapped();
+    }
+
     virtual void endPaint() { m_painter.end(); }
     virtual const void* data() const { return m_image.constBits(); }