<!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>[211681] 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/211681">211681</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2017-02-05 09:22:45 -0800 (Sun, 05 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move TextureMapper-specific logic out of GraphicsContext3DPrivate
https://bugs.webkit.org/show_bug.cgi?id=167096

Reviewed by Alex Christensen.

Move the TextureMapper-specific functionality in GraphicsContext3DPrivate into a
separate class. The new TextureMapperGC3DPlatformLayer class inherits from the
class that's aliased to the PlatformLayer type, like GraphicsContext3DPrivate did
before.

In GraphicsContext3D, the new m_texmapLayer member variable of the
std::unique_ptr&lt;TextureMapperGC3DPlatformLayer&gt; type is used for configurations
that enable TextureMapper, largely the same way the GraphicsContext3DPrivate
object was used before. The remaining code in GraphicsContext3DPrivate is left
unchanged to keep it working for other ports.

No new tests -- no change in behavior.

* platform/TextureMapper.cmake:
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): Deleted.
(WebCore::GraphicsContext3DPrivate::proxy): Deleted.
(WebCore::GraphicsContext3DPrivate::swapBuffersIfNeeded): Deleted.
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Deleted.
* platform/graphics/GraphicsContext3DPrivate.h:
* platform/graphics/cairo/GraphicsContext3DCairo.cpp:
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::~GraphicsContext3D):
(WebCore::GraphicsContext3D::makeContextCurrent):
(WebCore::GraphicsContext3D::platformGraphicsContext3D):
(WebCore::GraphicsContext3D::platformLayer):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::createForCurrentGLContext):
* platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp.
(WebCore::TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer):
(WebCore::TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer):
(WebCore::TextureMapperGC3DPlatformLayer::makeContextCurrent):
(WebCore::TextureMapperGC3DPlatformLayer::platformContext):
(WebCore::TextureMapperGC3DPlatformLayer::proxy):
(WebCore::TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded):
(WebCore::TextureMapperGC3DPlatformLayer::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h.
(WebCore::TextureMapperGC3DPlatformLayer::renderStyle):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformTextureMappercmake">trunk/Source/WebCore/platform/TextureMapper.cmake</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3DPrivatecpp">trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3DPrivateh">trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoGraphicsContext3DCairocpp">trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp">trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayercpp">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayerh">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/ChangeLog        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2017-02-05  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
+
+        Move TextureMapper-specific logic out of GraphicsContext3DPrivate
+        https://bugs.webkit.org/show_bug.cgi?id=167096
+
+        Reviewed by Alex Christensen.
+
+        Move the TextureMapper-specific functionality in GraphicsContext3DPrivate into a
+        separate class. The new TextureMapperGC3DPlatformLayer class inherits from the
+        class that's aliased to the PlatformLayer type, like GraphicsContext3DPrivate did
+        before.
+
+        In GraphicsContext3D, the new m_texmapLayer member variable of the
+        std::unique_ptr&lt;TextureMapperGC3DPlatformLayer&gt; type is used for configurations
+        that enable TextureMapper, largely the same way the GraphicsContext3DPrivate
+        object was used before. The remaining code in GraphicsContext3DPrivate is left
+        unchanged to keep it working for other ports.
+
+        No new tests -- no change in behavior.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/GraphicsContext3DPrivate.cpp:
+        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): Deleted.
+        (WebCore::GraphicsContext3DPrivate::proxy): Deleted.
+        (WebCore::GraphicsContext3DPrivate::swapBuffersIfNeeded): Deleted.
+        (WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Deleted.
+        * platform/graphics/GraphicsContext3DPrivate.h:
+        * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        (WebCore::GraphicsContext3D::~GraphicsContext3D):
+        (WebCore::GraphicsContext3D::makeContextCurrent):
+        (WebCore::GraphicsContext3D::platformGraphicsContext3D):
+        (WebCore::GraphicsContext3D::platformLayer):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::createForCurrentGLContext):
+        * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp.
+        (WebCore::TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer):
+        (WebCore::TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer):
+        (WebCore::TextureMapperGC3DPlatformLayer::makeContextCurrent):
+        (WebCore::TextureMapperGC3DPlatformLayer::platformContext):
+        (WebCore::TextureMapperGC3DPlatformLayer::proxy):
+        (WebCore::TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded):
+        (WebCore::TextureMapperGC3DPlatformLayer::paintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h.
+        (WebCore::TextureMapperGC3DPlatformLayer::renderStyle):
+
</ins><span class="cx"> 2017-02-05  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Simple line layout: Bail out from Simple Line Layout on surrogate pairs.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformTextureMappercmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/TextureMapper.cmake        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -9,6 +9,7 @@
</span><span class="cx">     platform/graphics/texmap/TextureMapperAnimation.cpp
</span><span class="cx">     platform/graphics/texmap/TextureMapperBackingStore.cpp
</span><span class="cx">     platform/graphics/texmap/TextureMapperFPSCounter.cpp
</span><ins>+    platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp
</ins><span class="cx">     platform/graphics/texmap/TextureMapperLayer.cpp
</span><span class="cx">     platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
</span><span class="cx">     platform/graphics/texmap/TextureMapperTile.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -101,6 +101,9 @@
</span><span class="cx"> #if USE(CAIRO)
</span><span class="cx"> class PlatformContextCairo;
</span><span class="cx"> #endif
</span><ins>+#if USE(TEXTURE_MAPPER)
+class TextureMapperGC3DPlatformLayer;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> typedef WTF::HashMap&lt;CString, uint64_t&gt; ShaderNameHash;
</span><span class="cx"> 
</span><span class="lines">@@ -1416,8 +1419,13 @@
</span><span class="cx">     // Errors raised by synthesizeGLError().
</span><span class="cx">     ListHashSet&lt;GC3Denum&gt; m_syntheticErrors;
</span><span class="cx"> 
</span><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; !PLATFORM(EFL)
+    friend class TextureMapperGC3DPlatformLayer;
+    std::unique_ptr&lt;TextureMapperGC3DPlatformLayer&gt; m_texmapLayer;
+#else
</ins><span class="cx">     friend class GraphicsContext3DPrivate;
</span><span class="cx">     std::unique_ptr&lt;GraphicsContext3DPrivate&gt; m_private;
</span><ins>+#endif
</ins><span class="cx">     
</span><span class="cx">     WebGLRenderingContextBase* m_webglContext;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3DPrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -25,9 +25,6 @@
</span><span class="cx"> #include &quot;HostWindow.h&quot;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> 
</span><del>-#if USE(CAIRO)
-#include &quot;PlatformContextCairo.h&quot;
-#endif
</del><span class="cx"> 
</span><span class="cx"> #if USE(OPENGL_ES_2)
</span><span class="cx"> #include &lt;GLES2/gl2.h&gt;
</span><span class="lines">@@ -36,21 +33,12 @@
</span><span class="cx"> #include &quot;OpenGLShims.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER_GL)
-#include &lt;texmap/TextureMapperGL.h&gt;
-#endif
-
-#if USE(COORDINATED_GRAPHICS_THREADED)
-#include &quot;TextureMapperPlatformLayerBuffer.h&quot;
-#endif
-
</del><span class="cx"> using namespace std;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
-    : m_context(context)
-    , m_renderStyle(renderStyle)
</del><ins>+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle renderStyle)
+    : m_renderStyle(renderStyle)
</ins><span class="cx"> {
</span><span class="cx">     switch (renderStyle) {
</span><span class="cx">     case GraphicsContext3D::RenderOffscreen:
</span><span class="lines">@@ -62,20 +50,9 @@
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         break;
</span><span class="cx">     }
</span><del>-
-#if USE(COORDINATED_GRAPHICS_THREADED)
-    if (m_renderStyle == GraphicsContext3D::RenderOffscreen)
-        m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
-{
-#if USE(TEXTURE_MAPPER) &amp;&amp; !USE(COORDINATED_GRAPHICS_THREADED)
-    if (client())
-        client()-&gt;platformLayerWillBeDestroyed();
-#endif
-}
</del><ins>+GraphicsContext3DPrivate::~GraphicsContext3DPrivate() = default;
</ins><span class="cx"> 
</span><span class="cx"> bool GraphicsContext3DPrivate::makeContextCurrent()
</span><span class="cx"> {
</span><span class="lines">@@ -87,60 +64,6 @@
</span><span class="cx">     return m_glContext ? m_glContext-&gt;platformContext() : GLContext::current()-&gt;platformContext();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(COORDINATED_GRAPHICS_THREADED)
-RefPtr&lt;TextureMapperPlatformLayerProxy&gt; GraphicsContext3DPrivate::proxy() const
-{
-    return m_platformLayerProxy.copyRef();
-}
-
-void GraphicsContext3DPrivate::swapBuffersIfNeeded()
-{
-    ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
-    if (m_context-&gt;layerComposited())
-        return;
-
-    m_context-&gt;prepareTexture();
-    IntSize textureSize(m_context-&gt;m_currentWidth, m_context-&gt;m_currentHeight);
-    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context-&gt;m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
-
-    {
-        LockHolder holder(m_platformLayerProxy-&gt;lock());
-        m_platformLayerProxy-&gt;pushNextBuffer(std::make_unique&lt;TextureMapperPlatformLayerBuffer&gt;(m_context-&gt;m_compositorTexture, textureSize, flags));
-    }
-
-    m_context-&gt;markLayerComposited();
-}
-#elif USE(TEXTURE_MAPPER)
-void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper&amp; textureMapper, const FloatRect&amp; targetRect, const TransformationMatrix&amp; matrix, float opacity)
-{
-    if (!m_glContext)
-        return;
-
-    ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
-
-    m_context-&gt;markLayerComposited();
-
-#if USE(TEXTURE_MAPPER_GL)
-    if (m_context-&gt;m_attrs.antialias &amp;&amp; m_context-&gt;m_state.boundFBO == m_context-&gt;m_multisampleFBO) {
-        GLContext* previousActiveContext = GLContext::current();
-        if (previousActiveContext != m_glContext.get())
-            m_context-&gt;makeContextCurrent();
-
-        m_context-&gt;resolveMultisamplingIfNecessary();
-        ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context-&gt;m_state.boundFBO);
-
-        if (previousActiveContext &amp;&amp; previousActiveContext != m_glContext.get())
-            previousActiveContext-&gt;makeContextCurrent();
-    }
-
-    TextureMapperGL&amp; texmapGL = static_cast&lt;TextureMapperGL&amp;&gt;(textureMapper);
-    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context-&gt;m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
-    IntSize textureSize(m_context-&gt;m_currentWidth, m_context-&gt;m_currentHeight);
-    texmapGL.drawTexture(m_context-&gt;m_texture, flags, textureSize, targetRect, matrix, opacity);
-#endif // USE(TEXTURE_MAPPER_GL)
-}
-#endif // USE(TEXTURE_MAPPER)
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(GRAPHICS_CONTEXT_3D)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3DPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -24,20 +24,11 @@
</span><span class="cx"> #include &quot;GraphicsContext3D.h&quot;
</span><span class="cx"> #include &quot;PlatformLayer.h&quot;
</span><span class="cx"> 
</span><del>-#if USE(TEXTURE_MAPPER)
-#include &quot;TextureMapperPlatformLayer.h&quot;
-#include &quot;TextureMapperPlatformLayerProxy.h&quot;
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class BitmapTextureGL;
</span><span class="cx"> 
</span><del>-class GraphicsContext3DPrivate
-#if USE(TEXTURE_MAPPER)
-    : public PlatformLayer
-#endif
-{
</del><ins>+class GraphicsContext3DPrivate {
</ins><span class="cx"> public:
</span><span class="cx">     GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
</span><span class="cx">     ~GraphicsContext3DPrivate();
</span><span class="lines">@@ -46,22 +37,9 @@
</span><span class="cx"> 
</span><span class="cx">     GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
</span><span class="cx"> 
</span><del>-#if USE(COORDINATED_GRAPHICS_THREADED)
-    RefPtr&lt;TextureMapperPlatformLayerProxy&gt; proxy() const override;
-    void swapBuffersIfNeeded() override;
-#elif USE(TEXTURE_MAPPER)
-    virtual void paintToTextureMapper(TextureMapper&amp;, const FloatRect&amp; target, const TransformationMatrix&amp;, float opacity);
-#endif
-
</del><span class="cx"> private:
</span><del>-    GraphicsContext3D* m_context;
</del><span class="cx">     std::unique_ptr&lt;GLContext&gt; m_glContext;
</span><span class="cx">     GraphicsContext3D::RenderStyle m_renderStyle;
</span><del>-
-#if USE(COORDINATED_GRAPHICS_THREADED)
-    RefPtr&lt;TextureMapperPlatformLayerProxy&gt; m_platformLayerProxy;
-    RefPtr&lt;BitmapTextureGL&gt; m_compositorTexture;
-#endif
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoGraphicsContext3DCairocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -54,6 +54,10 @@
</span><span class="cx"> #include &quot;OpenGLShims.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(TEXTURE_MAPPER)
+#include &quot;TextureMapperGC3DPlatformLayer.h&quot;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;GraphicsContext3D&gt; GraphicsContext3D::create(GraphicsContext3DAttributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
</span><span class="lines">@@ -91,8 +95,13 @@
</span><span class="cx">     , m_multisampleFBO(0)
</span><span class="cx">     , m_multisampleDepthStencilBuffer(0)
</span><span class="cx">     , m_multisampleColorBuffer(0)
</span><del>-    , m_private(std::make_unique&lt;GraphicsContext3DPrivate&gt;(this, renderStyle))
</del><span class="cx"> {
</span><ins>+#if USE(TEXTURE_MAPPER)
+    m_texmapLayer = std::make_unique&lt;TextureMapperGC3DPlatformLayer&gt;(*this, renderStyle);
+#else
+    m_private = std::make_unique&lt;GraphicsContext3DPrivate&gt;(this, renderStyle);
+#endif
+
</ins><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><span class="cx">     validateAttributes();
</span><span class="lines">@@ -200,8 +209,13 @@
</span><span class="cx"> 
</span><span class="cx"> GraphicsContext3D::~GraphicsContext3D()
</span><span class="cx"> {
</span><ins>+#if USE(TEXTURE_MAPPER)
+    if (m_texmapLayer-&gt;renderStyle() == RenderToCurrentGLContext)
+        return;
+#else
</ins><span class="cx">     if (m_private-&gt;renderStyle() == RenderToCurrentGLContext)
</span><span class="cx">         return;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     makeContextCurrent();
</span><span class="cx">     if (m_texture)
</span><span class="lines">@@ -338,9 +352,14 @@
</span><span class="cx"> 
</span><span class="cx"> bool GraphicsContext3D::makeContextCurrent()
</span><span class="cx"> {
</span><del>-    if (!m_private)
-        return false;
-    return m_private-&gt;makeContextCurrent();
</del><ins>+#if USE(TEXTURE_MAPPER)
+    if (m_texmapLayer)
+        return m_texmapLayer-&gt;makeContextCurrent();
+#else
+    if (m_private)
+        return m_private-&gt;makeContextCurrent();
+#endif
+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext3D::checkGPUStatusIfNecessary()
</span><span class="lines">@@ -349,7 +368,11 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
</span><span class="cx"> {
</span><ins>+#if USE(TEXTURE_MAPPER)
+    return m_texmapLayer-&gt;platformContext();
+#else
</ins><span class="cx">     return m_private-&gt;platformContext();
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Platform3DObject GraphicsContext3D::platformTexture() const
</span><span class="lines">@@ -368,7 +391,11 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformLayer* GraphicsContext3D::platformLayer() const
</span><span class="cx"> {
</span><ins>+#if USE(TEXTURE_MAPPER)
+    return m_texmapLayer.get();
+#else
</ins><span class="cx">     return m_private.get();
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (211680 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2017-02-05 14:41:10 UTC (rev 211680)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -133,8 +133,13 @@
</span><span class="cx"> RefPtr&lt;GraphicsContext3D&gt; GraphicsContext3D::createForCurrentGLContext()
</span><span class="cx"> {
</span><span class="cx">     auto context = adoptRef(*new GraphicsContext3D({ }, 0, GraphicsContext3D::RenderToCurrentGLContext));
</span><ins>+#if USE(TEXTURE_MAPPER) &amp;&amp; !PLATFORM(EFL)
+    if (!context-&gt;m_texmapLayer)
+        return nullptr;
+#else
</ins><span class="cx">     if (!context-&gt;m_private)
</span><span class="cx">         return nullptr;
</span><ins>+#endif
</ins><span class="cx">     return WTFMove(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp (0 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -0,0 +1,126 @@
</span><ins>+/*
+ * Copyright (C) 2011, 2012, 2017 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#include &quot;config.h&quot;
+#include &quot;TextureMapperGC3DPlatformLayer.h&quot;
+
+#if USE(TEXTURE_MAPPER) &amp;&amp; !PLATFORM(EFL)
+
+#include &quot;BitmapTextureGL.h&quot;
+#include &quot;GLContext.h&quot;
+#include &quot;TextureMapperPlatformLayerBuffer.h&quot;
+
+namespace WebCore {
+
+TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer(GraphicsContext3D&amp; context, GraphicsContext3D::RenderStyle renderStyle)
+    : m_context(context)
+    , m_renderStyle(renderStyle)
+{
+    switch (renderStyle) {
+    case GraphicsContext3D::RenderOffscreen:
+        m_glContext = GLContext::createOffscreenContext(&amp;PlatformDisplay::sharedDisplayForCompositing());
+        break;
+    case GraphicsContext3D::RenderToCurrentGLContext:
+        break;
+    case GraphicsContext3D::RenderDirectlyToHostWindow:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    if (m_renderStyle == GraphicsContext3D::RenderOffscreen)
+        m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
+#endif
+}
+
+TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer()
+{
+#if !USE(COORDINATED_GRAPHICS_THREADED)
+    if (client())
+        client()-&gt;platformLayerWillBeDestroyed();
+#endif
+}
+
+bool TextureMapperGC3DPlatformLayer::makeContextCurrent()
+{
+    return m_glContext ? m_glContext-&gt;makeContextCurrent() : false;
+}
+
+PlatformGraphicsContext3D TextureMapperGC3DPlatformLayer::platformContext()
+{
+    return m_glContext ? m_glContext-&gt;platformContext() : GLContext::current()-&gt;platformContext();
+}
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+RefPtr&lt;TextureMapperPlatformLayerProxy&gt; TextureMapperGC3DPlatformLayer::proxy() const
+{
+    return m_platformLayerProxy.copyRef();
+}
+
+void TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded()
+{
+    ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
+    if (m_context.layerComposited())
+        return;
+
+    m_context.prepareTexture();
+    IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight);
+    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context.m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
+
+    {
+        LockHolder holder(m_platformLayerProxy-&gt;lock());
+        m_platformLayerProxy-&gt;pushNextBuffer(std::make_unique&lt;TextureMapperPlatformLayerBuffer&gt;(m_context.m_compositorTexture, textureSize, flags));
+    }
+
+    m_context.markLayerComposited();
+}
+#else
+void TextureMapperGC3DPlatformLayer::paintToTextureMapper(TextureMapper&amp; textureMapper, const FloatRect&amp; targetRect, const TransformationMatrix&amp; matrix, float opacity)
+{
+    if (!m_glContext)
+        return;
+
+    ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
+
+    m_context.markLayerComposited();
+
+#if USE(TEXTURE_MAPPER_GL)
+    if (m_context.m_attrs.antialias &amp;&amp; m_context.m_state.boundFBO == m_context.m_multisampleFBO) {
+        GLContext* previousActiveContext = GLContext::current();
+        if (previousActiveContext != m_glContext.get())
+            m_context.makeContextCurrent();
+
+        m_context.resolveMultisamplingIfNecessary();
+        ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context.m_state.boundFBO);
+
+        if (previousActiveContext &amp;&amp; previousActiveContext != m_glContext.get())
+            previousActiveContext-&gt;makeContextCurrent();
+    }
+
+    TextureMapperGL&amp; texmapGL = static_cast&lt;TextureMapperGL&amp;&gt;(textureMapper);
+    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context.m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
+    IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight);
+    texmapGL.drawTexture(m_context.m_texture, flags, textureSize, targetRect, matrix, opacity);
+#endif // USE(TEXTURE_MAPPER_GL)
+}
+#endif // USE(COORDINATED_GRAPHICS_THREADED)
+
+} // namespace WebCore
+
+#endif // USE(TEXTURE_MAPPER) &amp;&amp; !PLATFORM(EFL)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperGC3DPlatformLayerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h (0 => 211681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h        2017-02-05 17:22:45 UTC (rev 211681)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2011, 2012, 2017 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#if USE(TEXTURE_MAPPER) &amp;&amp; !PLATFORM(EFL)
+
+#include &quot;GraphicsContext3D.h&quot;
+#include &quot;PlatformLayer.h&quot;
+#include &quot;TextureMapperPlatformLayer.h&quot;
+#include &quot;TextureMapperPlatformLayerProxy.h&quot;
+
+namespace WebCore {
+
+class BitmapTextureGL;
+class GLContext;
+class TextureMapperPlatformLayerProxy;
+
+class TextureMapperGC3DPlatformLayer : public PlatformLayer {
+public:
+    TextureMapperGC3DPlatformLayer(GraphicsContext3D&amp;, GraphicsContext3D::RenderStyle);
+    virtual ~TextureMapperGC3DPlatformLayer();
+
+    bool makeContextCurrent();
+    PlatformGraphicsContext3D platformContext();
+    GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    RefPtr&lt;TextureMapperPlatformLayerProxy&gt; proxy() const override;
+    void swapBuffersIfNeeded() override;
+#else
+    virtual void paintToTextureMapper(TextureMapper&amp;, const FloatRect&amp; target, const TransformationMatrix&amp;, float opacity);
+#endif
+
+private:
+    GraphicsContext3D&amp; m_context;
+    std::unique_ptr&lt;GLContext&gt; m_glContext;
+    GraphicsContext3D::RenderStyle m_renderStyle;
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    RefPtr&lt;TextureMapperPlatformLayerProxy&gt; m_platformLayerProxy;
+    RefPtr&lt;BitmapTextureGL&gt; m_compositorTexture;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // USE(TEXTURE_MAPPER) &amp;&amp; !PLATFORM(EFL)
</ins></span></pre>
</div>
</div>

</body>
</html>