<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191541] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191541">191541</a></dd>
<dt>Author</dt> <dd>yoon@igalia.com</dd>
<dt>Date</dt> <dd>2015-10-24 19:23:20 -0700 (Sat, 24 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapBitmapTextureh">trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLcpp">trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLh">trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapBitmapTexturePoolcpp">trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191540 => 191541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-25 01:33:02 UTC (rev 191540)
+++ trunk/Source/WebCore/ChangeLog        2015-10-25 02:23:20 UTC (rev 191541)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2015-10-24  Gwang Yoon Hwang  &lt;yoon@igalia.com&gt;
+
+        [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.
+
</ins><span class="cx"> 2015-10-24  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r187121): Delayed instantaneous animations not honouring ' forwards' fill-mode
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapBitmapTextureh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h (191540 => 191541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h        2015-10-25 01:33:02 UTC (rev 191540)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h        2015-10-25 02:23:20 UTC (rev 191541)
</span><span class="lines">@@ -75,7 +75,6 @@
</span><span class="cx">     inline Flags flags() const { return m_flags; }
</span><span class="cx"> 
</span><span class="cx">     virtual int bpp() const { return 32; }
</span><del>-    virtual bool canReuseWith(const IntSize&amp; /* contentsSize */, Flags = 0) { return false; }
</del><span class="cx">     void reset(const IntSize&amp; size, Flags flags = 0)
</span><span class="cx">     {
</span><span class="cx">         m_flags = flags;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (191540 => 191541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp        2015-10-25 01:33:02 UTC (rev 191540)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp        2015-10-25 02:23:20 UTC (rev 191541)
</span><span class="lines">@@ -69,19 +69,23 @@
</span><span class="cx">     , m_depthBufferObject(0)
</span><span class="cx">     , m_shouldClear(true)
</span><span class="cx">     , m_context3D(context3D)
</span><del>-{
-}
-
-bool BitmapTextureGL::canReuseWith(const IntSize&amp; contentsSize, Flags)
-{
-    return contentsSize == m_textureSize;
-}
-
</del><span class="cx"> #if OS(DARWIN)
</span><del>-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
</del><ins>+    , m_type(GL_UNSIGNED_INT_8_8_8_8_REV)
</ins><span class="cx"> #else
</span><del>-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE
</del><ins>+    , m_type(GraphicsContext3D::UNSIGNED_BYTE)
</ins><span class="cx"> #endif
</span><ins>+{
+    // 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-&gt;isGLES2Compliant()) {
+        if (m_context3D-&gt;getExtensions()-&gt;supports(&quot;GL_EXT_texture_format_BGRA8888&quot;))
+            m_internalFormat = GraphicsContext3D::BGRA;
+        else
+            m_format = GraphicsContext3D::RGBA;
+    }
+}
</ins><span class="cx"> 
</span><span class="cx"> static void swizzleBGRAToRGBA(uint32_t* data, const IntRect&amp; rect, int stride = 0)
</span><span class="cx"> {
</span><span class="lines">@@ -93,18 +97,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// 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-&gt;isGLES2Compliant()) {
-        static bool supportsExternalTextureBGRA = context-&gt;getExtensions()-&gt;supports(&quot;GL_EXT_texture_format_BGRA8888&quot;);
-        return supportsExternalTextureBGRA;
-    }
-
-    return true;
-}
-
</del><span class="cx"> static bool driverSupportsSubImage(GraphicsContext3D* context)
</span><span class="cx"> {
</span><span class="cx">     if (context-&gt;isGLES2Compliant()) {
</span><span class="lines">@@ -124,7 +116,6 @@
</span><span class="cx">     if (m_textureSize == contentSize())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-
</del><span class="cx">     m_textureSize = contentSize();
</span><span class="cx">     m_context3D-&gt;bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
</span><span class="cx">     m_context3D-&gt;texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
</span><span class="lines">@@ -132,16 +123,7 @@
</span><span class="cx">     m_context3D-&gt;texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
</span><span class="cx">     m_context3D-&gt;texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
</span><span class="cx"> 
</span><del>-    Platform3DObject internalFormat = GraphicsContext3D::RGBA;
-    Platform3DObject externalFormat = GraphicsContext3D::BGRA;
-    if (m_context3D-&gt;isGLES2Compliant()) {
-        if (driverSupportsExternalTextureBGRA(m_context3D.get()))
-            internalFormat = GraphicsContext3D::BGRA;
-        else
-            externalFormat = GraphicsContext3D::RGBA;
-    }
-
-    m_context3D-&gt;texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, internalFormat, m_textureSize.width(), m_textureSize.height(), 0, externalFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
</del><ins>+    m_context3D-&gt;texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, m_internalFormat, m_textureSize.width(), m_textureSize.height(), 0, m_format, m_type, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect&amp; targetRect, const IntPoint&amp; sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
</span><span class="lines">@@ -155,7 +137,7 @@
</span><span class="cx">         m_context3D-&gt;pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_context3D-&gt;texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, srcData);
</del><ins>+    m_context3D-&gt;texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, m_type, srcData);
</ins><span class="cx"> 
</span><span class="cx">     // For ES drivers that don't support sub-images.
</span><span class="cx">     if (driverSupportsSubImage(m_context3D.get())) {
</span><span class="lines">@@ -167,7 +149,6 @@
</span><span class="cx"> 
</span><span class="cx"> void BitmapTextureGL::updateContents(const void* srcData, const IntRect&amp; targetRect, const IntPoint&amp; sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
</span><span class="cx"> {
</span><del>-    Platform3DObject glFormat = GraphicsContext3D::RGBA;
</del><span class="cx">     m_context3D-&gt;bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
</span><span class="cx"> 
</span><span class="cx">     const unsigned bytesPerPixel = 4;
</span><span class="lines">@@ -180,7 +161,7 @@
</span><span class="cx">         &amp;&amp; !(bytesPerLine == static_cast&lt;int&gt;(targetRect.width() * bytesPerPixel) &amp;&amp; adjustedSourceOffset == IntPoint::zero());
</span><span class="cx"> 
</span><span class="cx">     // prepare temporaryData if necessary
</span><del>-    if ((!driverSupportsExternalTextureBGRA(m_context3D.get()) &amp;&amp; updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
</del><ins>+    if ((m_format == GraphicsContext3D::RGBA &amp;&amp; updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
</ins><span class="cx">         temporaryData.resize(targetRect.width() * targetRect.height() * bytesPerPixel);
</span><span class="cx">         data = temporaryData.data();
</span><span class="cx">         const char* bits = static_cast&lt;const char*&gt;(srcData);
</span><span class="lines">@@ -197,12 +178,10 @@
</span><span class="cx">         adjustedSourceOffset = IntPoint(0, 0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (driverSupportsExternalTextureBGRA(m_context3D.get()))
-        glFormat = GraphicsContext3D::BGRA;
-    else
</del><ins>+    if (m_format == GraphicsContext3D::RGBA)
</ins><span class="cx">         swizzleBGRAToRGBA(reinterpret_cast_ptr&lt;uint32_t*&gt;(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
</span><span class="cx"> 
</span><del>-    updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, glFormat);
</del><ins>+    updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, m_format);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void BitmapTextureGL::updateContents(Image* image, const IntRect&amp; targetRect, const IntPoint&amp; offset, UpdateContentsFlag updateContentsFlag)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (191540 => 191541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h        2015-10-25 01:33:02 UTC (rev 191540)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h        2015-10-25 02:23:20 UTC (rev 191541)
</span><span class="lines">@@ -42,7 +42,6 @@
</span><span class="cx"> 
</span><span class="cx">     virtual IntSize size() const override;
</span><span class="cx">     virtual bool isValid() const override;
</span><del>-    virtual bool canReuseWith(const IntSize&amp; contentsSize, Flags = 0) override;
</del><span class="cx">     virtual void didReset() override;
</span><span class="cx">     void bindAsSurface(GraphicsContext3D*);
</span><span class="cx">     void initializeStencil();
</span><span class="lines">@@ -88,6 +87,10 @@
</span><span class="cx">     void createFboIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     FilterInfo m_filterInfo;
</span><ins>+
+    GC3Dint m_internalFormat;
+    GC3Denum m_format;
+    GC3Denum m_type;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> BitmapTextureGL* toBitmapTextureGL(BitmapTexture*);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapBitmapTexturePoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp (191540 => 191541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp        2015-10-25 01:33:02 UTC (rev 191540)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp        2015-10-25 02:23:20 UTC (rev 191541)
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx">         if (entry.m_texture-&gt;refCount() &gt; 1)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        if (entry.m_texture-&gt;canReuseWith(size)) {
</del><ins>+        if (entry.m_texture-&gt;size() == size) {
</ins><span class="cx">             selectedEntry = &amp;entry;
</span><span class="cx">             break;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>