Title: [191579] releases/WebKitGTK/webkit-2.10/Source/WebCore
Revision
191579
Author
[email protected]
Date
2015-10-26 02:30:10 -0700 (Mon, 26 Oct 2015)

Log Message

Merge r191541 - [TexMap] Clean up BitmapTexture and BitmapTextureGL.
https://bugs.webkit.org/show_bug.cgi?id=143298

Reviewed by Žan Doberšek.

No new tests, this is just a refactor.

* platform/graphics/texmap/BitmapTexture.h:
(WebCore::BitmapTexture::canReuseWith): Deleted.
Reuseability of a BitmapTexture is only decided by its size.
We can use size() instead of this method.

* platform/graphics/texmap/BitmapTextureGL.h:
(WebCore::driverSupportsExternalTextureBGRA): Deleted.
We do not have to check a suitable texture format in every
update/reset. It is enough to store the formats in construction time
and reuse them.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (191578 => 191579)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-10-26 09:26:41 UTC (rev 191578)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-10-26 09:30:10 UTC (rev 191579)
@@ -1,3 +1,23 @@
+2015-10-24  Gwang Yoon Hwang  <[email protected]>
+
+        [TexMap] Clean up BitmapTexture and BitmapTextureGL.
+        https://bugs.webkit.org/show_bug.cgi?id=143298
+
+        Reviewed by Žan Doberšek.
+
+        No new tests, this is just a refactor.
+
+        * platform/graphics/texmap/BitmapTexture.h:
+        (WebCore::BitmapTexture::canReuseWith): Deleted.
+        Reuseability of a BitmapTexture is only decided by its size.
+        We can use size() instead of this method.
+
+        * platform/graphics/texmap/BitmapTextureGL.h:
+        (WebCore::driverSupportsExternalTextureBGRA): Deleted.
+        We do not have to check a suitable texture format in every
+        update/reset. It is enough to store the formats in construction time
+        and reuse them.
+
 2015-10-24  Simon Fraser  <[email protected]>
 
         REGRESSION (r187121): Delayed instantaneous animations not honouring ' forwards' fill-mode

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h (191578 => 191579)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h	2015-10-26 09:26:41 UTC (rev 191578)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h	2015-10-26 09:30:10 UTC (rev 191579)
@@ -75,7 +75,6 @@
     inline Flags flags() const { return m_flags; }
 
     virtual int bpp() const { return 32; }
-    virtual bool canReuseWith(const IntSize& /* contentsSize */, Flags = 0) { return false; }
     void reset(const IntSize& size, Flags flags = 0)
     {
         m_flags = flags;

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (191578 => 191579)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp	2015-10-26 09:26:41 UTC (rev 191578)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp	2015-10-26 09:30:10 UTC (rev 191579)
@@ -69,19 +69,23 @@
     , m_depthBufferObject(0)
     , m_shouldClear(true)
     , m_context3D(context3D)
-{
-}
-
-bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags)
-{
-    return contentsSize == m_textureSize;
-}
-
 #if OS(DARWIN)
-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+    , m_type(GL_UNSIGNED_INT_8_8_8_8_REV)
 #else
-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE
+    , 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;
+    }
+}
 
 static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride = 0)
 {
@@ -93,18 +97,6 @@
     }
 }
 
-// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
-// internal and external formats need to be BGRA
-static bool driverSupportsExternalTextureBGRA(GraphicsContext3D* context)
-{
-    if (context->isGLES2Compliant()) {
-        static bool supportsExternalTextureBGRA = context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888");
-        return supportsExternalTextureBGRA;
-    }
-
-    return true;
-}
-
 static bool driverSupportsSubImage(GraphicsContext3D* context)
 {
     if (context->isGLES2Compliant()) {
@@ -124,7 +116,6 @@
     if (m_textureSize == contentSize())
         return;
 
-
     m_textureSize = contentSize();
     m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
     m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
@@ -132,16 +123,7 @@
     m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
     m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
 
-    Platform3DObject internalFormat = GraphicsContext3D::RGBA;
-    Platform3DObject externalFormat = GraphicsContext3D::BGRA;
-    if (m_context3D->isGLES2Compliant()) {
-        if (driverSupportsExternalTextureBGRA(m_context3D.get()))
-            internalFormat = GraphicsContext3D::BGRA;
-        else
-            externalFormat = GraphicsContext3D::RGBA;
-    }
-
-    m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, internalFormat, m_textureSize.width(), m_textureSize.height(), 0, externalFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
+    m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, m_internalFormat, m_textureSize.width(), m_textureSize.height(), 0, m_format, m_type, 0);
 }
 
 void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
@@ -155,7 +137,7 @@
         m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
     }
 
-    m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, srcData);
+    m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, m_type, srcData);
 
     // For ES drivers that don't support sub-images.
     if (driverSupportsSubImage(m_context3D.get())) {
@@ -167,7 +149,6 @@
 
 void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
 {
-    Platform3DObject glFormat = GraphicsContext3D::RGBA;
     m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
 
     const unsigned bytesPerPixel = 4;
@@ -180,7 +161,7 @@
         && !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero());
 
     // prepare temporaryData if necessary
-    if ((!driverSupportsExternalTextureBGRA(m_context3D.get()) && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
+    if ((m_format == GraphicsContext3D::RGBA && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
         temporaryData.resize(targetRect.width() * targetRect.height() * bytesPerPixel);
         data = ""
         const char* bits = static_cast<const char*>(srcData);
@@ -197,12 +178,10 @@
         adjustedSourceOffset = IntPoint(0, 0);
     }
 
-    if (driverSupportsExternalTextureBGRA(m_context3D.get()))
-        glFormat = GraphicsContext3D::BGRA;
-    else
+    if (m_format == GraphicsContext3D::RGBA)
         swizzleBGRAToRGBA(reinterpret_cast_ptr<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
 
-    updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, glFormat);
+    updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, m_format);
 }
 
 void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (191578 => 191579)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h	2015-10-26 09:26:41 UTC (rev 191578)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h	2015-10-26 09:30:10 UTC (rev 191579)
@@ -42,7 +42,6 @@
 
     virtual IntSize size() const override;
     virtual bool isValid() const override;
-    virtual bool canReuseWith(const IntSize& contentsSize, Flags = 0) override;
     virtual void didReset() override;
     void bindAsSurface(GraphicsContext3D*);
     void initializeStencil();
@@ -88,6 +87,10 @@
     void createFboIfNeeded();
 
     FilterInfo m_filterInfo;
+
+    GC3Dint m_internalFormat;
+    GC3Denum m_format;
+    GC3Denum m_type;
 };
 
 BitmapTextureGL* toBitmapTextureGL(BitmapTexture*);

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp (191578 => 191579)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp	2015-10-26 09:26:41 UTC (rev 191578)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp	2015-10-26 09:30:10 UTC (rev 191579)
@@ -83,7 +83,7 @@
         if (entry.m_texture->refCount() > 1)
             continue;
 
-        if (entry.m_texture->canReuseWith(size)) {
+        if (entry.m_texture->size() == size) {
             selectedEntry = &entry;
             break;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to