Title: [211681] trunk/Source/WebCore
Revision
211681
Author
zandober...@gmail.com
Date
2017-02-05 09:22:45 -0800 (Sun, 05 Feb 2017)

Log Message

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<TextureMapperGC3DPlatformLayer> 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):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211680 => 211681)


--- 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)
@@ -1,3 +1,51 @@
+2017-02-05  Zan Dobersek  <zdober...@igalia.com>
+
+        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<TextureMapperGC3DPlatformLayer> 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):
+
 2017-02-05  Zalan Bujtas  <za...@apple.com>
 
         Simple line layout: Bail out from Simple Line Layout on surrogate pairs.

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (211680 => 211681)


--- 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)
@@ -9,6 +9,7 @@
     platform/graphics/texmap/TextureMapperAnimation.cpp
     platform/graphics/texmap/TextureMapperBackingStore.cpp
     platform/graphics/texmap/TextureMapperFPSCounter.cpp
+    platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp
     platform/graphics/texmap/TextureMapperLayer.cpp
     platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
     platform/graphics/texmap/TextureMapperTile.cpp

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (211680 => 211681)


--- 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)
@@ -101,6 +101,9 @@
 #if USE(CAIRO)
 class PlatformContextCairo;
 #endif
+#if USE(TEXTURE_MAPPER)
+class TextureMapperGC3DPlatformLayer;
+#endif
 
 typedef WTF::HashMap<CString, uint64_t> ShaderNameHash;
 
@@ -1416,8 +1419,13 @@
     // Errors raised by synthesizeGLError().
     ListHashSet<GC3Denum> m_syntheticErrors;
 
+#if USE(TEXTURE_MAPPER) && !PLATFORM(EFL)
+    friend class TextureMapperGC3DPlatformLayer;
+    std::unique_ptr<TextureMapperGC3DPlatformLayer> m_texmapLayer;
+#else
     friend class GraphicsContext3DPrivate;
     std::unique_ptr<GraphicsContext3DPrivate> m_private;
+#endif
     
     WebGLRenderingContextBase* m_webglContext;
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp (211680 => 211681)


--- 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)
@@ -25,9 +25,6 @@
 #include "HostWindow.h"
 #include <wtf/StdLibExtras.h>
 
-#if USE(CAIRO)
-#include "PlatformContextCairo.h"
-#endif
 
 #if USE(OPENGL_ES_2)
 #include <GLES2/gl2.h>
@@ -36,21 +33,12 @@
 #include "OpenGLShims.h"
 #endif
 
-#if USE(TEXTURE_MAPPER_GL)
-#include <texmap/TextureMapperGL.h>
-#endif
-
-#if USE(COORDINATED_GRAPHICS_THREADED)
-#include "TextureMapperPlatformLayerBuffer.h"
-#endif
-
 using namespace std;
 
 namespace WebCore {
 
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
-    : m_context(context)
-    , m_renderStyle(renderStyle)
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle renderStyle)
+    : m_renderStyle(renderStyle)
 {
     switch (renderStyle) {
     case GraphicsContext3D::RenderOffscreen:
@@ -62,20 +50,9 @@
         ASSERT_NOT_REACHED();
         break;
     }
-
-#if USE(COORDINATED_GRAPHICS_THREADED)
-    if (m_renderStyle == GraphicsContext3D::RenderOffscreen)
-        m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
-#endif
 }
 
-GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
-{
-#if USE(TEXTURE_MAPPER) && !USE(COORDINATED_GRAPHICS_THREADED)
-    if (client())
-        client()->platformLayerWillBeDestroyed();
-#endif
-}
+GraphicsContext3DPrivate::~GraphicsContext3DPrivate() = default;
 
 bool GraphicsContext3DPrivate::makeContextCurrent()
 {
@@ -87,60 +64,6 @@
     return m_glContext ? m_glContext->platformContext() : GLContext::current()->platformContext();
 }
 
-#if USE(COORDINATED_GRAPHICS_THREADED)
-RefPtr<TextureMapperPlatformLayerProxy> GraphicsContext3DPrivate::proxy() const
-{
-    return m_platformLayerProxy.copyRef();
-}
-
-void GraphicsContext3DPrivate::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->lock());
-        m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_context->m_compositorTexture, textureSize, flags));
-    }
-
-    m_context->markLayerComposited();
-}
-#elif USE(TEXTURE_MAPPER)
-void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& 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 && 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 && previousActiveContext != m_glContext.get())
-            previousActiveContext->makeContextCurrent();
-    }
-
-    TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(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(TEXTURE_MAPPER)
-
 } // namespace WebCore
 
 #endif // ENABLE(GRAPHICS_CONTEXT_3D)

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h (211680 => 211681)


--- 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)
@@ -24,20 +24,11 @@
 #include "GraphicsContext3D.h"
 #include "PlatformLayer.h"
 
-#if USE(TEXTURE_MAPPER)
-#include "TextureMapperPlatformLayer.h"
-#include "TextureMapperPlatformLayerProxy.h"
-#endif
-
 namespace WebCore {
 
 class BitmapTextureGL;
 
-class GraphicsContext3DPrivate
-#if USE(TEXTURE_MAPPER)
-    : public PlatformLayer
-#endif
-{
+class GraphicsContext3DPrivate {
 public:
     GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
     ~GraphicsContext3DPrivate();
@@ -46,22 +37,9 @@
 
     GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
 
-#if USE(COORDINATED_GRAPHICS_THREADED)
-    RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
-    void swapBuffersIfNeeded() override;
-#elif USE(TEXTURE_MAPPER)
-    virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
-#endif
-
 private:
-    GraphicsContext3D* m_context;
     std::unique_ptr<GLContext> m_glContext;
     GraphicsContext3D::RenderStyle m_renderStyle;
-
-#if USE(COORDINATED_GRAPHICS_THREADED)
-    RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
-    RefPtr<BitmapTextureGL> m_compositorTexture;
-#endif
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (211680 => 211681)


--- 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)
@@ -54,6 +54,10 @@
 #include "OpenGLShims.h"
 #endif
 
+#if USE(TEXTURE_MAPPER)
+#include "TextureMapperGC3DPlatformLayer.h"
+#endif
+
 namespace WebCore {
 
 RefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3DAttributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
@@ -91,8 +95,13 @@
     , m_multisampleFBO(0)
     , m_multisampleDepthStencilBuffer(0)
     , m_multisampleColorBuffer(0)
-    , m_private(std::make_unique<GraphicsContext3DPrivate>(this, renderStyle))
 {
+#if USE(TEXTURE_MAPPER)
+    m_texmapLayer = std::make_unique<TextureMapperGC3DPlatformLayer>(*this, renderStyle);
+#else
+    m_private = std::make_unique<GraphicsContext3DPrivate>(this, renderStyle);
+#endif
+
     makeContextCurrent();
 
     validateAttributes();
@@ -200,8 +209,13 @@
 
 GraphicsContext3D::~GraphicsContext3D()
 {
+#if USE(TEXTURE_MAPPER)
+    if (m_texmapLayer->renderStyle() == RenderToCurrentGLContext)
+        return;
+#else
     if (m_private->renderStyle() == RenderToCurrentGLContext)
         return;
+#endif
 
     makeContextCurrent();
     if (m_texture)
@@ -338,9 +352,14 @@
 
 bool GraphicsContext3D::makeContextCurrent()
 {
-    if (!m_private)
-        return false;
-    return m_private->makeContextCurrent();
+#if USE(TEXTURE_MAPPER)
+    if (m_texmapLayer)
+        return m_texmapLayer->makeContextCurrent();
+#else
+    if (m_private)
+        return m_private->makeContextCurrent();
+#endif
+    return false;
 }
 
 void GraphicsContext3D::checkGPUStatusIfNecessary()
@@ -349,7 +368,11 @@
 
 PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
 {
+#if USE(TEXTURE_MAPPER)
+    return m_texmapLayer->platformContext();
+#else
     return m_private->platformContext();
+#endif
 }
 
 Platform3DObject GraphicsContext3D::platformTexture() const
@@ -368,7 +391,11 @@
 
 PlatformLayer* GraphicsContext3D::platformLayer() const
 {
+#if USE(TEXTURE_MAPPER)
+    return m_texmapLayer.get();
+#else
     return m_private.get();
+#endif
 }
 
 #if PLATFORM(GTK)

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (211680 => 211681)


--- 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)
@@ -133,8 +133,13 @@
 RefPtr<GraphicsContext3D> GraphicsContext3D::createForCurrentGLContext()
 {
     auto context = adoptRef(*new GraphicsContext3D({ }, 0, GraphicsContext3D::RenderToCurrentGLContext));
+#if USE(TEXTURE_MAPPER) && !PLATFORM(EFL)
+    if (!context->m_texmapLayer)
+        return nullptr;
+#else
     if (!context->m_private)
         return nullptr;
+#endif
     return WTFMove(context);
 }
 

Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp (0 => 211681)


--- 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)
@@ -0,0 +1,126 @@
+/*
+ * 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 "config.h"
+#include "TextureMapperGC3DPlatformLayer.h"
+
+#if USE(TEXTURE_MAPPER) && !PLATFORM(EFL)
+
+#include "BitmapTextureGL.h"
+#include "GLContext.h"
+#include "TextureMapperPlatformLayerBuffer.h"
+
+namespace WebCore {
+
+TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle)
+    : m_context(context)
+    , m_renderStyle(renderStyle)
+{
+    switch (renderStyle) {
+    case GraphicsContext3D::RenderOffscreen:
+        m_glContext = GLContext::createOffscreenContext(&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()->platformLayerWillBeDestroyed();
+#endif
+}
+
+bool TextureMapperGC3DPlatformLayer::makeContextCurrent()
+{
+    return m_glContext ? m_glContext->makeContextCurrent() : false;
+}
+
+PlatformGraphicsContext3D TextureMapperGC3DPlatformLayer::platformContext()
+{
+    return m_glContext ? m_glContext->platformContext() : GLContext::current()->platformContext();
+}
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+RefPtr<TextureMapperPlatformLayerProxy> 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->lock());
+        m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags));
+    }
+
+    m_context.markLayerComposited();
+}
+#else
+void TextureMapperGC3DPlatformLayer::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& 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 && 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 && previousActiveContext != m_glContext.get())
+            previousActiveContext->makeContextCurrent();
+    }
+
+    TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(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) && !PLATFORM(EFL)

Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h (0 => 211681)


--- 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)
@@ -0,0 +1,64 @@
+/*
+ * 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) && !PLATFORM(EFL)
+
+#include "GraphicsContext3D.h"
+#include "PlatformLayer.h"
+#include "TextureMapperPlatformLayer.h"
+#include "TextureMapperPlatformLayerProxy.h"
+
+namespace WebCore {
+
+class BitmapTextureGL;
+class GLContext;
+class TextureMapperPlatformLayerProxy;
+
+class TextureMapperGC3DPlatformLayer : public PlatformLayer {
+public:
+    TextureMapperGC3DPlatformLayer(GraphicsContext3D&, GraphicsContext3D::RenderStyle);
+    virtual ~TextureMapperGC3DPlatformLayer();
+
+    bool makeContextCurrent();
+    PlatformGraphicsContext3D platformContext();
+    GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
+    void swapBuffersIfNeeded() override;
+#else
+    virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
+#endif
+
+private:
+    GraphicsContext3D& m_context;
+    std::unique_ptr<GLContext> m_glContext;
+    GraphicsContext3D::RenderStyle m_renderStyle;
+
+#if USE(COORDINATED_GRAPHICS_THREADED)
+    RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
+    RefPtr<BitmapTextureGL> m_compositorTexture;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // USE(TEXTURE_MAPPER) && !PLATFORM(EFL)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to