Title: [107951] trunk/Source
Revision
107951
Author
[email protected]
Date
2012-02-16 09:48:04 -0800 (Thu, 16 Feb 2012)

Log Message

[Texmap] Improve the way we deal with BGRA extension
https://bugs.webkit.org/show_bug.cgi?id=78822

Source/WebCore:

Swizzle the RGBA manually only in OpenGL ES, and only if the extension is not available.
Pass the pixel-format of the images when updating TextureMapperTiledBackingStore.

Reviewed by Kenneth Rohde Christiansen.

No new behavior.

* platform/graphics/opengl/TextureMapperGL.cpp:
(WebCore):
(WebCore::hasExtension):
(WebCore::hasBgraExtension):
(WebCore::BitmapTextureGL::updateContents):
* platform/graphics/texmap/TextureMapperBackingStore.cpp:
(WebCore::TextureMapperTile::updateContents):
(WebCore::TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded):
(WebCore::TextureMapperTiledBackingStore::updateContents):
* platform/graphics/texmap/TextureMapperBackingStore.h:
(TextureMapperTile):
(TextureMapperTiledBackingStore):
(WebCore::TextureMapperTiledBackingStore::updateContents):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::updateBackingStore):

Source/WebKit2:

Get rid of swizzling in the web process. Instead, we moved swizzling back to
TextureMapperGL, as we're moving towards a setup where textures are uploaded
in the web process.

Reviewed by Kenneth Rohde Christiansen.

* UIProcess/qt/LayerBackingStore.cpp:
(WebKit::LayerBackingStoreTile::swapBuffers):
* UIProcess/qt/LayerTreeHostProxyQt.cpp:
(WebKit::LayerTreeHostProxy::createImage):
* WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
(WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::adoptImageBackingStore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107950 => 107951)


--- trunk/Source/WebCore/ChangeLog	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebCore/ChangeLog	2012-02-16 17:48:04 UTC (rev 107951)
@@ -1,3 +1,31 @@
+2012-02-16  No'am Rosenthal  <[email protected]>
+
+        [Texmap] Improve the way we deal with BGRA extension
+        https://bugs.webkit.org/show_bug.cgi?id=78822
+
+        Swizzle the RGBA manually only in OpenGL ES, and only if the extension is not available.
+        Pass the pixel-format of the images when updating TextureMapperTiledBackingStore.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        No new behavior.
+
+        * platform/graphics/opengl/TextureMapperGL.cpp:
+        (WebCore):
+        (WebCore::hasExtension):
+        (WebCore::hasBgraExtension):
+        (WebCore::BitmapTextureGL::updateContents):
+        * platform/graphics/texmap/TextureMapperBackingStore.cpp:
+        (WebCore::TextureMapperTile::updateContents):
+        (WebCore::TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded):
+        (WebCore::TextureMapperTiledBackingStore::updateContents):
+        * platform/graphics/texmap/TextureMapperBackingStore.h:
+        (TextureMapperTile):
+        (TextureMapperTiledBackingStore):
+        (WebCore::TextureMapperTiledBackingStore::updateContents):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::updateBackingStore):
+
 2012-02-16  Simon Hausmann  <[email protected]>
 
         [Gtk][Efl][Qt] Move OpenGLShims out of cairo/ subdirectory

Modified: trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp (107950 => 107951)


--- trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -616,7 +616,6 @@
     m_surfaceNeedsReset = true;
 }
 
-#if PLATFORM(QT) || (USE(CAIRO) && defined(TEXMAP_OPENGL_ES_2))
 static void swizzleBGRAToRGBA(uint32_t* data, const IntSize& size)
 {
     int width = size.width();
@@ -627,12 +626,38 @@
             p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
     }
 }
+
+// FIXME: Move this to Extensions3D when we move TextureMapper to use GC3D.
+static bool hasExtension(const char* extension)
+{
+    static Vector<String> availableExtensions;
+    if (!availableExtensions.isEmpty())
+        return availableExtensions.contains(extension);
+    String extensionsString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
+    extensionsString.split(" ", availableExtensions);
+    return availableExtensions.contains(extension);
+}
+static bool hasBGRAExtension()
+{
+#if !defined(TEXMAP_OPENGL_ES_2)
+    return true;
 #endif
+    static bool hasBGRA = hasExtension("GL_EXT_texture_format_BGRA8888");
+    return hasBGRA;
+}
 
 void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect)
 {
+    GLuint glFormat = GL_RGBA;
     GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id))
-    GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), GL_RGBA, GL_UNSIGNED_BYTE, data))
+    if (hasBGRAExtension())
+        glFormat = GL_BGRA;
+    else {
+        swizzleBGRAToRGBA(static_cast<uint32_t*>(const_cast<void*>(data)), targetRect.size());
+        glFormat = GL_RGBA;
+    }
+
+    GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, data))
 }
 
 void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntRect& sourceRect, BitmapTexture::PixelFormat format)
@@ -658,8 +683,12 @@
 
     if (IntSize(qtImage.size()) != sourceRect.size())
         qtImage = qtImage.copy(sourceRect);
-    if (format == BGRAFormat || format == BGRFormat)
-        swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(qtImage.bits()), qtImage.size());
+    if (format == BGRAFormat || format == BGRFormat) {
+        if (hasBGRAExtension())
+            glFormat = isOpaque() ? GL_BGR : GL_BGRA;
+        else
+            swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(qtImage.bits()), qtImage.size());
+    }
     GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, qtImage.constBits()))
 
 #elif USE(CAIRO)

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp (107950 => 107951)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -26,7 +26,7 @@
 
 namespace WebCore {
 
-void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect)
+void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::PixelFormat format)
 {
     IntRect targetRect = enclosingIntRect(m_rect);
     targetRect.intersect(dirtyRect);
@@ -44,7 +44,7 @@
         m_texture->reset(targetRect.size(), /* opaque = */ false);
     }
 
-    m_texture->updateContents(image, targetRect, sourceRect, BitmapTexture::RGBAFormat);
+    m_texture->updateContents(image, targetRect, sourceRect, format);
 }
 
 void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
@@ -57,7 +57,7 @@
     if (!m_image)
         return;
 
-    updateContents(textureMapper, m_image.get());
+    updateContents(textureMapper, m_image.get(), BitmapTexture::BGRAFormat);
     m_image.clear();
 }
 
@@ -133,11 +133,11 @@
         m_tiles.remove(tileIndicesToRemove[i]);
 }
 
-void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect)
+void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::PixelFormat format)
 {
     createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize());
     for (size_t i = 0; i < m_tiles.size(); ++i)
-        m_tiles[i].updateContents(textureMapper, image, dirtyRect);
+        m_tiles[i].updateContents(textureMapper, image, dirtyRect, format);
 }
 
 PassRefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h (107950 => 107951)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h	2012-02-16 17:48:04 UTC (rev 107951)
@@ -23,6 +23,7 @@
 #include "FloatRect.h"
 #include "Image.h"
 #include "RefPtr.h"
+#include "TextureMapper.h"
 #include "TextureMapperPlatformLayer.h"
 
 namespace WebCore {
@@ -43,7 +44,7 @@
     inline void setTexture(BitmapTexture* texture) { m_texture = texture; }
     inline void setRect(const FloatRect& rect) { m_rect = rect; }
 
-    void updateContents(TextureMapper*, Image*, const IntRect&);
+    void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::PixelFormat);
     virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*);
     virtual ~TextureMapperTile() { }
 
@@ -63,8 +64,8 @@
     virtual ~TextureMapperTiledBackingStore() { }
     virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
     virtual PassRefPtr<BitmapTexture> texture() const;
-    void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&);
-    void updateContents(TextureMapper* textureMapper, Image* image) { updateContents(textureMapper, image, image->size(), image->rect()); }
+    void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::PixelFormat);
+    void updateContents(TextureMapper* textureMapper, Image* image, BitmapTexture::PixelFormat format) { updateContents(textureMapper, image, image->size(), image->rect(), format); }
     inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
     static PassRefPtr<TextureMapperTiledBackingStore> create() { return adoptRef(new TextureMapperTiledBackingStore); }
     void setContentsToImage(Image* image) { m_image = image; }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (107950 => 107951)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -128,7 +128,7 @@
     image = imageBuffer->copyImage(CopyBackingStore);
 #endif
 
-    static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect);
+    static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::BGRAFormat);
 }
 
 void TextureMapperLayer::paint()

Modified: trunk/Source/WebKit2/ChangeLog (107950 => 107951)


--- trunk/Source/WebKit2/ChangeLog	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-16 17:48:04 UTC (rev 107951)
@@ -1,3 +1,23 @@
+2012-02-16  No'am Rosenthal  <[email protected]>
+
+        [Texmap] Improve the way we deal with BGRA extension
+        https://bugs.webkit.org/show_bug.cgi?id=78822
+
+        Get rid of swizzling in the web process. Instead, we moved swizzling back to
+        TextureMapperGL, as we're moving towards a setup where textures are uploaded
+        in the web process.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * UIProcess/qt/LayerBackingStore.cpp:
+        (WebKit::LayerBackingStoreTile::swapBuffers):
+        * UIProcess/qt/LayerTreeHostProxyQt.cpp:
+        (WebKit::LayerTreeHostProxy::createImage):
+        * WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
+        (WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+        (WebKit::LayerTreeHostQt::adoptImageBackingStore):
+
 2012-02-16  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix WebKit2 GTK+ build after r107947.

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (107950 => 107951)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -3306,7 +3306,6 @@
 #if PLATFORM(WIN)
     parameters.nativeWindow = m_pageClient->nativeWindow();
 #endif
-
     return parameters;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp (107950 => 107951)


--- trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -373,7 +373,7 @@
 void LayerTreeHostProxy::createImage(int64_t imageID, ShareableBitmap* bitmap)
 {
     RefPtr<TextureMapperTiledBackingStore> backingStore = TextureMapperTiledBackingStore::create();
-    backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get());
+    backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get(), BitmapTexture::BGRAFormat);
     m_directlyCompositedImages.set(imageID, backingStore);
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp (107950 => 107951)


--- trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -88,11 +88,6 @@
     OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext());
     graphicsContext->drawImageBuffer(m_localBuffer.get(), ColorSpaceDeviceRGB, IntPoint(0, 0));
 
-#if PLATFORM(QT)
-    // Qt uses BGRA interally, we swizzle to RGBA for OpenGL.
-    bitmap->swizzleRGB();
-#endif
-
     UpdateInfo updateInfo;
     updateInfo.updateRectBounds = m_rect;
     updateInfo.updateScaleFactor = m_tiledBackingStore->contentsScale();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (107950 => 107951)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2012-02-16 17:45:48 UTC (rev 107950)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2012-02-16 17:48:04 UTC (rev 107951)
@@ -334,8 +334,6 @@
         graphicsContext->drawImage(image, ColorSpaceDeviceRGB, IntPoint::zero());
     }
 
-    // Qt uses BGRA internally, we swizzle to RGBA for OpenGL.
-    bitmap->swizzleRGB();
     ShareableBitmap::Handle handle;
     bitmap->createHandle(handle);
     m_webPage->send(Messages::LayerTreeHostProxy::CreateDirectlyCompositedImage(key, handle));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to