Title: [197759] releases/WebKitGTK/webkit-2.12/Source/WebCore
Revision
197759
Author
[email protected]
Date
2016-03-08 05:35:32 -0800 (Tue, 08 Mar 2016)

Log Message

Merge r197506 - [TextureMapper] Use RGBA format for textures attached to framebuffers
https://bugs.webkit.org/show_bug.cgi?id=154965

Patch by Miguel Gomez <[email protected]> on 2016-03-03
Reviewed by Žan Doberšek.

Use RGBA format when allocating textures that will be used as framebuffer
attachments. This means adding a new flag to BitmapTexture and modifying
BitmapTextureGL to use the appropriate format according to the flag. Also,
BitmapTexturePool needs to use two vectors to handle both types of textures
separately, as we want to avoid constantly switching the format of a reused
texture.

No new tests since the behavior change is covered by existing tests.

* platform/graphics/texmap/BitmapTexture.h: Add new flag.
* platform/graphics/texmap/BitmapTextureGL.cpp:
(WebCore::BitmapTextureGL::BitmapTextureGL): Receive flags on constructor and use RGBA
when the FBOAttachment flag is enabled.
(WebCore::BitmapTextureGL::applyFilters): Use FBOAttachemt flag to request a texture.
* platform/graphics/texmap/BitmapTextureGL.h: Add flags to the constructor.
* platform/graphics/texmap/BitmapTexturePool.cpp: Add a new vector of textures to hold
those in RGBA format.
(WebCore::BitmapTexturePool::acquireTexture): Return a texture for the usage specified
in the incoming flags.
(WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired): Release textures from
both vectors.
(WebCore::BitmapTexturePool::createTexture): Pass the usage flag when creating a new
texture.
* platform/graphics/texmap/BitmapTexturePool.h: Add new texture vector and add flags to
the needed headers.
* platform/graphics/texmap/TextureMapper.cpp:
(WebCore::TextureMapper::acquireTextureFromPool): Pass the received flags to the BitmapTexturePool.
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintIntoSurface): Use FBOAttachemt flag to request a texture.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog	2016-03-08 13:35:32 UTC (rev 197759)
@@ -1,3 +1,40 @@
+2016-03-03  Miguel Gomez  <[email protected]>
+
+        [TextureMapper] Use RGBA format for textures attached to framebuffers
+        https://bugs.webkit.org/show_bug.cgi?id=154965
+
+        Reviewed by Žan Doberšek.
+
+        Use RGBA format when allocating textures that will be used as framebuffer
+        attachments. This means adding a new flag to BitmapTexture and modifying
+        BitmapTextureGL to use the appropriate format according to the flag. Also,
+        BitmapTexturePool needs to use two vectors to handle both types of textures
+        separately, as we want to avoid constantly switching the format of a reused
+        texture.
+
+        No new tests since the behavior change is covered by existing tests.
+
+        * platform/graphics/texmap/BitmapTexture.h: Add new flag.
+        * platform/graphics/texmap/BitmapTextureGL.cpp:
+        (WebCore::BitmapTextureGL::BitmapTextureGL): Receive flags on constructor and use RGBA
+        when the FBOAttachment flag is enabled.
+        (WebCore::BitmapTextureGL::applyFilters): Use FBOAttachemt flag to request a texture.
+        * platform/graphics/texmap/BitmapTextureGL.h: Add flags to the constructor.
+        * platform/graphics/texmap/BitmapTexturePool.cpp: Add a new vector of textures to hold
+        those in RGBA format.
+        (WebCore::BitmapTexturePool::acquireTexture): Return a texture for the usage specified
+        in the incoming flags.
+        (WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired): Release textures from
+        both vectors.
+        (WebCore::BitmapTexturePool::createTexture): Pass the usage flag when creating a new
+        texture.
+        * platform/graphics/texmap/BitmapTexturePool.h: Add new texture vector and add flags to
+        the needed headers.
+        * platform/graphics/texmap/TextureMapper.cpp:
+        (WebCore::TextureMapper::acquireTextureFromPool): Pass the received flags to the BitmapTexturePool.
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintIntoSurface): Use FBOAttachemt flag to request a texture.
+
 2016-03-02  Zalan Bujtas  <[email protected]>
 
         Paint table borders on empty cells even in quirks mode.

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexture.h (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexture.h	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexture.h	2016-03-08 13:35:32 UTC (rev 197759)
@@ -45,7 +45,8 @@
 public:
     enum Flag {
         NoFlag = 0,
-        SupportsAlpha = 0x01
+        SupportsAlpha = 0x01,
+        FBOAttachment = 0x02
     };
 
     enum UpdateContentsFlag {

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp	2016-03-08 13:35:32 UTC (rev 197759)
@@ -58,7 +58,7 @@
     return static_cast<BitmapTextureGL*>(texture);
 }
 
-BitmapTextureGL::BitmapTextureGL(PassRefPtr<GraphicsContext3D> context3D)
+BitmapTextureGL::BitmapTextureGL(PassRefPtr<GraphicsContext3D> context3D, const Flags flags)
     : m_id(0)
     , m_fbo(0)
     , m_rbo(0)
@@ -71,15 +71,19 @@
     , m_type(GraphicsContext3D::UNSIGNED_BYTE)
 #endif
 {
-    // If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
-    // internal and external formats need to be BGRA
-    m_internalFormat = GraphicsContext3D::RGBA;
-    m_format = GraphicsContext3D::BGRA;
-    if (m_context3D->isGLES2Compliant()) {
-        if (m_context3D->getExtensions()->supports("GL_EXT_texture_format_BGRA8888"))
-            m_internalFormat = GraphicsContext3D::BGRA;
-        else
-            m_format = GraphicsContext3D::RGBA;
+    if (flags & FBOAttachment)
+        m_internalFormat = m_format = GraphicsContext3D::RGBA;
+    else {
+        // If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
+        // internal and external formats need to be BGRA
+        m_internalFormat = GraphicsContext3D::RGBA;
+        m_format = GraphicsContext3D::BGRA;
+        if (m_context3D->isGLES2Compliant()) {
+            if (m_context3D->getExtensions()->supports("GL_EXT_texture_format_BGRA8888"))
+                m_internalFormat = GraphicsContext3D::BGRA;
+            else
+                m_format = GraphicsContext3D::RGBA;
+        }
     }
 }
 
@@ -243,7 +247,7 @@
             bool last = (i == filters.size() - 1) && (j == numPasses - 1);
             if (!last) {
                 if (!intermediateSurface)
-                    intermediateSurface = texmapGL.acquireTextureFromPool(contentSize());
+                    intermediateSurface = texmapGL.acquireTextureFromPool(contentSize(), BitmapTexture::SupportsAlpha | BitmapTexture::FBOAttachment);
                 texmapGL.bindSurface(intermediateSurface.get());
             }
 

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h	2016-03-08 13:35:32 UTC (rev 197759)
@@ -38,7 +38,7 @@
 
 class BitmapTextureGL : public BitmapTexture {
 public:
-    BitmapTextureGL(PassRefPtr<GraphicsContext3D>);
+    BitmapTextureGL(PassRefPtr<GraphicsContext3D>, const Flags = NoFlag);
     virtual ~BitmapTextureGL();
 
     virtual IntSize size() const override;

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp	2016-03-08 13:35:32 UTC (rev 197759)
@@ -44,14 +44,16 @@
 }
 #endif
 
-RefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size)
+RefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size, const BitmapTexture::Flags flags)
 {
-    Entry* selectedEntry = std::find_if(m_textures.begin(), m_textures.end(),
+    Vector<Entry>& list = flags & BitmapTexture::FBOAttachment ? m_attachmentTextures : m_textures;
+
+    Entry* selectedEntry = std::find_if(list.begin(), list.end(),
         [&size](Entry& entry) { return entry.m_texture->refCount() == 1 && entry.m_texture->size() == size; });
 
-    if (selectedEntry == m_textures.end()) {
-        m_textures.append(Entry(createTexture()));
-        selectedEntry = &m_textures.last();
+    if (selectedEntry == list.end()) {
+        list.append(Entry(createTexture(flags)));
+        selectedEntry = &list.last();
     }
 
     scheduleReleaseUnusedTextures();
@@ -69,29 +71,41 @@
 
 void BitmapTexturePool::releaseUnusedTexturesTimerFired()
 {
-    if (m_textures.isEmpty())
-        return;
-
     // Delete entries, which have been unused in s_releaseUnusedSecondsTolerance.
-    std::sort(m_textures.begin(), m_textures.end(),
-        [](const Entry& a, const Entry& b) { return a.m_lastUsedTime > b.m_lastUsedTime; });
+    double minUsedTime = monotonicallyIncreasingTime() - s_releaseUnusedSecondsTolerance;
 
-    double minUsedTime = monotonicallyIncreasingTime() - s_releaseUnusedSecondsTolerance;
-    for (size_t i = 0; i < m_textures.size(); ++i) {
-        if (m_textures[i].m_lastUsedTime < minUsedTime) {
-            m_textures.remove(i, m_textures.size() - i);
-            break;
+    if (!m_textures.isEmpty()) {
+        std::sort(m_textures.begin(), m_textures.end(),
+            [](const Entry& a, const Entry& b) { return a.m_lastUsedTime > b.m_lastUsedTime; });
+
+        for (size_t i = 0; i < m_textures.size(); ++i) {
+            if (m_textures[i].m_lastUsedTime < minUsedTime) {
+                m_textures.remove(i, m_textures.size() - i);
+                break;
+            }
         }
     }
 
-    if (!m_textures.isEmpty())
+    if (!m_attachmentTextures.isEmpty()) {
+        std::sort(m_attachmentTextures.begin(), m_attachmentTextures.end(),
+            [](const Entry& a, const Entry& b) { return a.m_lastUsedTime > b.m_lastUsedTime; });
+
+        for (size_t i = 0; i < m_attachmentTextures.size(); ++i) {
+            if (m_attachmentTextures[i].m_lastUsedTime < minUsedTime) {
+                m_attachmentTextures.remove(i, m_textures.size() - i);
+                break;
+            }
+        }
+    }
+
+    if (!m_textures.isEmpty() || !m_attachmentTextures.isEmpty())
         scheduleReleaseUnusedTextures();
 }
 
-RefPtr<BitmapTexture> BitmapTexturePool::createTexture()
+RefPtr<BitmapTexture> BitmapTexturePool::createTexture(const BitmapTexture::Flags flags)
 {
 #if USE(TEXTURE_MAPPER_GL)
-    return adoptRef(new BitmapTextureGL(m_context3D));
+    return adoptRef(new BitmapTextureGL(m_context3D, flags));
 #else
     return nullptr;
 #endif

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h	2016-03-08 13:35:32 UTC (rev 197759)
@@ -48,7 +48,7 @@
     explicit BitmapTexturePool(RefPtr<GraphicsContext3D>&&);
 #endif
 
-    RefPtr<BitmapTexture> acquireTexture(const IntSize&);
+    RefPtr<BitmapTexture> acquireTexture(const IntSize&, const BitmapTexture::Flags);
 
 private:
     struct Entry {
@@ -64,13 +64,14 @@
 
     void scheduleReleaseUnusedTextures();
     void releaseUnusedTexturesTimerFired();
-    RefPtr<BitmapTexture> createTexture();
+    RefPtr<BitmapTexture> createTexture(const BitmapTexture::Flags);
 
 #if USE(TEXTURE_MAPPER_GL)
     RefPtr<GraphicsContext3D> m_context3D;
 #endif
 
     Vector<Entry> m_textures;
+    Vector<Entry> m_attachmentTextures;
     Timer m_releaseUnusedTexturesTimer;
 };
 

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp	2016-03-08 13:35:32 UTC (rev 197759)
@@ -32,7 +32,7 @@
 
 PassRefPtr<BitmapTexture> TextureMapper::acquireTextureFromPool(const IntSize& size, const BitmapTexture::Flags flags)
 {
-    RefPtr<BitmapTexture> selectedTexture = m_texturePool->acquireTexture(size);
+    RefPtr<BitmapTexture> selectedTexture = m_texturePool->acquireTexture(size, flags);
     selectedTexture->reset(size, flags);
     return selectedTexture.release();
 }

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (197758 => 197759)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2016-03-08 13:31:37 UTC (rev 197758)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2016-03-08 13:35:32 UTC (rev 197759)
@@ -370,7 +370,7 @@
 
 PassRefPtr<BitmapTexture> TextureMapperLayer::paintIntoSurface(const TextureMapperPaintOptions& options, const IntSize& size)
 {
-    RefPtr<BitmapTexture> surface = options.textureMapper.acquireTextureFromPool(size);
+    RefPtr<BitmapTexture> surface = options.textureMapper.acquireTextureFromPool(size, BitmapTexture::SupportsAlpha | BitmapTexture::FBOAttachment);
     TextureMapperPaintOptions paintOptions(options);
     paintOptions.surface = surface;
     options.textureMapper.bindSurface(surface.get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to