Title: [263076] trunk/Source/WebCore
Revision
263076
Author
changs...@webkit.org
Date
2020-06-15 22:39:50 -0700 (Mon, 15 Jun 2020)

Log Message

[GTK] Rename GC3D to GCGL.
https://bugs.webkit.org/show_bug.cgi?id=211117

Reviewed by Fujii Hironori.

GraphicsContext3D has been renamed to GraphicsContextGL after r254103 but some files
still follow the old name. This change reflects the new name to them for consistency.

No new tests because of no new functionalities.

* platform/TextureMapper.cmake:
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp.
(Nicosia::GCGLANGLELayer::ANGLEContext::errorString):
(Nicosia::GCGLANGLELayer::ANGLEContext::lastErrorString):
(Nicosia::GCGLANGLELayer::ANGLEContext::createContext):
(Nicosia::GCGLANGLELayer::ANGLEContext::ANGLEContext):
(Nicosia::GCGLANGLELayer::ANGLEContext::~ANGLEContext):
(Nicosia::GCGLANGLELayer::ANGLEContext::makeContextCurrent):
(Nicosia::GCGLANGLELayer::ANGLEContext::platformContext const):
(Nicosia::GCGLANGLELayer::GCGLANGLELayer):
(Nicosia::GCGLANGLELayer::~GCGLANGLELayer):
(Nicosia::GCGLANGLELayer::makeContextCurrent):
(Nicosia::GCGLANGLELayer::platformContext const):
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h.
* platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp.
(Nicosia::GCGLLayer::GCGLLayer):
(Nicosia::GCGLLayer::~GCGLLayer):
(Nicosia::GCGLLayer::makeContextCurrent):
(Nicosia::GCGLLayer::platformContext const):
(Nicosia::GCGLLayer::swapBuffersIfNeeded):
* platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h.
(Nicosia::GCGLLayer::contentLayer const):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:
* platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
(WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL):
* platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp.
(WebCore::TextureMapperGCGLPlatformLayer::TextureMapperGCGLPlatformLayer):
(WebCore::TextureMapperGCGLPlatformLayer::~TextureMapperGCGLPlatformLayer):
(WebCore::TextureMapperGCGLPlatformLayer::makeContextCurrent):
(WebCore::TextureMapperGCGLPlatformLayer::platformContext const):
(WebCore::TextureMapperGCGLPlatformLayer::proxy const):
(WebCore::TextureMapperGCGLPlatformLayer::swapBuffersIfNeeded):
(WebCore::TextureMapperGCGLPlatformLayer::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (263075 => 263076)


--- trunk/Source/WebCore/ChangeLog	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/ChangeLog	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,3 +1,50 @@
+2020-06-15  ChangSeok Oh  <changs...@webkit.org>
+
+        [GTK] Rename GC3D to GCGL.
+        https://bugs.webkit.org/show_bug.cgi?id=211117
+
+        Reviewed by Fujii Hironori.
+
+        GraphicsContext3D has been renamed to GraphicsContextGL after r254103 but some files
+        still follow the old name. This change reflects the new name to them for consistency.
+
+        No new tests because of no new functionalities.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp.
+        (Nicosia::GCGLANGLELayer::ANGLEContext::errorString):
+        (Nicosia::GCGLANGLELayer::ANGLEContext::lastErrorString):
+        (Nicosia::GCGLANGLELayer::ANGLEContext::createContext):
+        (Nicosia::GCGLANGLELayer::ANGLEContext::ANGLEContext):
+        (Nicosia::GCGLANGLELayer::ANGLEContext::~ANGLEContext):
+        (Nicosia::GCGLANGLELayer::ANGLEContext::makeContextCurrent):
+        (Nicosia::GCGLANGLELayer::ANGLEContext::platformContext const):
+        (Nicosia::GCGLANGLELayer::GCGLANGLELayer):
+        (Nicosia::GCGLANGLELayer::~GCGLANGLELayer):
+        (Nicosia::GCGLANGLELayer::makeContextCurrent):
+        (Nicosia::GCGLANGLELayer::platformContext const):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h.
+        * platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp.
+        (Nicosia::GCGLLayer::GCGLLayer):
+        (Nicosia::GCGLLayer::~GCGLLayer):
+        (Nicosia::GCGLLayer::makeContextCurrent):
+        (Nicosia::GCGLLayer::platformContext const):
+        (Nicosia::GCGLLayer::swapBuffersIfNeeded):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h.
+        (Nicosia::GCGLLayer::contentLayer const):
+        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
+        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
+        (WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL):
+        * platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp.
+        (WebCore::TextureMapperGCGLPlatformLayer::TextureMapperGCGLPlatformLayer):
+        (WebCore::TextureMapperGCGLPlatformLayer::~TextureMapperGCGLPlatformLayer):
+        (WebCore::TextureMapperGCGLPlatformLayer::makeContextCurrent):
+        (WebCore::TextureMapperGCGLPlatformLayer::platformContext const):
+        (WebCore::TextureMapperGCGLPlatformLayer::proxy const):
+        (WebCore::TextureMapperGCGLPlatformLayer::swapBuffersIfNeeded):
+        (WebCore::TextureMapperGCGLPlatformLayer::paintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h.
+
 2020-06-15  Megan Gardner  <megan_gard...@apple.com>
 
         Text form controls can scroll by 1px when value is the same length as size. No scrolling should happen.

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (263075 => 263076)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2020-06-16 05:39:50 UTC (rev 263076)
@@ -11,7 +11,7 @@
     platform/graphics/texmap/TextureMapper.cpp
     platform/graphics/texmap/TextureMapperBackingStore.cpp
     platform/graphics/texmap/TextureMapperFPSCounter.cpp
-    platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp
+    platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp
     platform/graphics/texmap/TextureMapperLayer.cpp
     platform/graphics/texmap/TextureMapperTile.cpp
 )
@@ -90,7 +90,7 @@
         platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp
         platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp
         platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp
-        platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp
+        platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp
         platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.cpp
     )
     list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
@@ -118,6 +118,6 @@
 
 if (USE_ANGLE_WEBGL)
     list(APPEND WebCore_SOURCES
-        platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp
+        platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp
     )
 endif ()

Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Copyright (C) 2018, 2019 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NicosiaGC3DANGLELayer.h"
-
-#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-
-#include "Logging.h"
-
-#define EGL_EGL_PROTOTYPES 0
-// Skip the inclusion of ANGLE's explicit context entry points for now.
-#define GL_ANGLE_explicit_context
-#define GL_ANGLE_explicit_context_gles1
-typedef void* GLeglContext;
-#include <ANGLE/egl.h>
-#include <ANGLE/eglext.h>
-#include <ANGLE/eglext_angle.h>
-#include <ANGLE/entry_points_egl.h>
-#include <ANGLE/entry_points_gles_2_0_autogen.h>
-#include <ANGLE/entry_points_gles_ext_autogen.h>
-#include <ANGLE/gl2ext.h>
-#include <ANGLE/gl2ext_angle.h>
-
-namespace Nicosia {
-
-using namespace WebCore;
-
-const char* GC3DANGLELayer::ANGLEContext::errorString(int statusCode)
-{
-    static_assert(sizeof(int) >= sizeof(EGLint), "EGLint must not be wider than int");
-    switch (statusCode) {
-#define CASE_RETURN_STRING(name) case name: return #name
-        // https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglGetError.xhtml
-        CASE_RETURN_STRING(EGL_SUCCESS);
-        CASE_RETURN_STRING(EGL_NOT_INITIALIZED);
-        CASE_RETURN_STRING(EGL_BAD_ACCESS);
-        CASE_RETURN_STRING(EGL_BAD_ALLOC);
-        CASE_RETURN_STRING(EGL_BAD_ATTRIBUTE);
-        CASE_RETURN_STRING(EGL_BAD_CONTEXT);
-        CASE_RETURN_STRING(EGL_BAD_CONFIG);
-        CASE_RETURN_STRING(EGL_BAD_CURRENT_SURFACE);
-        CASE_RETURN_STRING(EGL_BAD_DISPLAY);
-        CASE_RETURN_STRING(EGL_BAD_SURFACE);
-        CASE_RETURN_STRING(EGL_BAD_MATCH);
-        CASE_RETURN_STRING(EGL_BAD_PARAMETER);
-        CASE_RETURN_STRING(EGL_BAD_NATIVE_PIXMAP);
-        CASE_RETURN_STRING(EGL_BAD_NATIVE_WINDOW);
-        CASE_RETURN_STRING(EGL_CONTEXT_LOST);
-#undef CASE_RETURN_STRING
-    default: return "Unknown EGL error";
-    }
-}
-
-const char* GC3DANGLELayer::ANGLEContext::lastErrorString()
-{
-    return errorString(EGL_GetError());
-}
-
-std::unique_ptr<GC3DANGLELayer::ANGLEContext> GC3DANGLELayer::ANGLEContext::createContext()
-{
-    EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
-    if (display == EGL_NO_DISPLAY)
-        return nullptr;
-
-    EGLint majorVersion, minorVersion;
-    if (EGL_Initialize(display, &majorVersion, &minorVersion) == EGL_FALSE) {
-        LOG(WebGL, "EGLDisplay Initialization failed.");
-        return nullptr;
-    }
-    LOG(WebGL, "ANGLE initialised Major: %d Minor: %d", majorVersion, minorVersion);
-
-    const char* displayExtensions = EGL_QueryString(display, EGL_EXTENSIONS);
-    LOG(WebGL, "Extensions: %s", displayExtensions);
-
-    EGLConfig config;
-    EGLint configAttributes[] = {
-        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-        EGL_RED_SIZE, 8,
-        EGL_GREEN_SIZE, 8,
-        EGL_BLUE_SIZE, 8,
-        EGL_ALPHA_SIZE, 8,
-        EGL_NONE
-    };
-    EGLint numberConfigsReturned = 0;
-    EGL_ChooseConfig(display, configAttributes, &config, 1, &numberConfigsReturned);
-    if (numberConfigsReturned != 1) {
-        LOG(WebGL, "EGLConfig Initialization failed.");
-        return nullptr;
-    }
-    LOG(WebGL, "Got EGLConfig");
-
-    EGL_BindAPI(EGL_OPENGL_ES_API);
-    if (EGL_GetError() != EGL_SUCCESS) {
-        LOG(WebGL, "Unable to bind to OPENGL_ES_API");
-        return nullptr;
-    }
-
-    std::vector<EGLint> contextAttributes;
-    contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
-    contextAttributes.push_back(2);
-    contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
-    contextAttributes.push_back(EGL_TRUE);
-    contextAttributes.push_back(EGL_EXTENSIONS_ENABLED_ANGLE);
-    contextAttributes.push_back(EGL_TRUE);
-    if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
-        contextAttributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
-        // EGL_LOW_POWER_ANGLE is the default. Change to
-        // EGL_HIGH_POWER_ANGLE if desired.
-        contextAttributes.push_back(EGL_LOW_POWER_ANGLE);
-    }
-    contextAttributes.push_back(EGL_NONE);
-
-    EGLContext context = EGL_CreateContext(display, config, EGL_NO_CONTEXT, contextAttributes.data());
-    if (context == EGL_NO_CONTEXT) {
-        LOG(WebGL, "EGLContext Initialization failed.");
-        return nullptr;
-    }
-    LOG(WebGL, "Got EGLContext");
-
-    return std::unique_ptr<ANGLEContext>(new ANGLEContext(display, context, EGL_NO_SURFACE));
-}
-
-GC3DANGLELayer::ANGLEContext::ANGLEContext(EGLDisplay display, EGLContext context, EGLSurface surface)
-    : m_display(display)
-    , m_context(context)
-    , m_surface(surface)
-{
-}
-
-GC3DANGLELayer::ANGLEContext::~ANGLEContext()
-{
-    if (m_context) {
-        gl::BindFramebuffer(GL_FRAMEBUFFER, 0);
-        EGL_MakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-        EGL_DestroyContext(m_display, m_context);
-    }
-
-    if (m_surface)
-        EGL_DestroySurface(m_display, m_surface);
-}
-
-bool GC3DANGLELayer::ANGLEContext::makeContextCurrent()
-{
-    ASSERT(m_context);
-
-    if (EGL_GetCurrentContext() != m_context)
-        return EGL_MakeCurrent(m_display, m_surface, m_surface, m_context);
-    return true;
-}
-
-PlatformGraphicsContextGL GC3DANGLELayer::ANGLEContext::platformContext() const
-{
-    return m_context;
-}
-
-GC3DANGLELayer::GC3DANGLELayer(GraphicsContextGLOpenGL& context, GraphicsContextGLOpenGL::Destination destination)
-    : GC3DLayer(context)
-{
-    switch (destination) {
-    case GraphicsContextGLOpenGL::Destination::Offscreen:
-        m_angleContext = ANGLEContext::createContext();
-        break;
-    case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-}
-
-GC3DANGLELayer::~GC3DANGLELayer()
-{
-}
-
-bool GC3DANGLELayer::makeContextCurrent()
-{
-    ASSERT(m_angleContext);
-    return m_angleContext->makeContextCurrent();
-
-}
-
-PlatformGraphicsContextGL GC3DANGLELayer::platformContext() const
-{
-    ASSERT(m_angleContext);
-    return m_angleContext->platformContext();
-}
-
-} // namespace Nicosia
-
-#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Copyright (C) 2018, 2019 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-
-#include "GLContext.h"
-#include "GraphicsContextGLOpenGL.h"
-#include "NicosiaGC3DLayer.h"
-#include <memory>
-
-typedef void *EGLConfig;
-typedef void *EGLContext;
-typedef void *EGLDisplay;
-typedef void *EGLSurface;
-
-namespace WebCore {
-class IntSize;
-class GLContext;
-class PlatformDisplay;
-}
-
-namespace Nicosia {
-
-class GC3DANGLELayer final : public GC3DLayer {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    class ANGLEContext {
-        WTF_MAKE_NONCOPYABLE(ANGLEContext);
-    public:
-        static const char* errorString(int statusCode);
-        static const char* lastErrorString();
-
-        static std::unique_ptr<ANGLEContext> createContext();
-        virtual ~ANGLEContext();
-
-        bool makeContextCurrent();
-#if ENABLE(GRAPHICS_CONTEXT_GL)
-        PlatformGraphicsContextGL platformContext() const;
-#endif
-
-    private:
-        ANGLEContext(EGLDisplay, EGLContext, EGLSurface);
-
-        EGLDisplay m_display { nullptr };
-        EGLContext m_context { nullptr };
-        EGLSurface m_surface { nullptr };
-    };
-
-    GC3DANGLELayer(WebCore::GraphicsContextGLOpenGL&, WebCore::GraphicsContextGLOpenGL::Destination);
-    virtual ~GC3DANGLELayer();
-
-    bool makeContextCurrent() override;
-    PlatformGraphicsContextGL platformContext() const override;
-
-private:
-    std::unique_ptr<ANGLEContext> m_angleContext;
-};
-
-} // namespace Nicosia
-
-#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Copyright (C) 2018 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NicosiaGC3DLayer.h"
-
-#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-
-#if USE(COORDINATED_GRAPHICS)
-#include "TextureMapperGL.h"
-#include "TextureMapperPlatformLayerBuffer.h"
-#include "TextureMapperPlatformLayerProxy.h"
-#endif
-
-#if USE(ANGLE)
-#include "ImageBuffer.h"
-#endif
-
-#include "GLContext.h"
-
-namespace Nicosia {
-
-using namespace WebCore;
-
-GC3DLayer::GC3DLayer(GraphicsContextGLOpenGL& context)
-    : m_context(context)
-    , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
-{
-}
-
-GC3DLayer::GC3DLayer(GraphicsContextGLOpenGL& context, GraphicsContextGLOpenGL::Destination destination)
-    : m_context(context)
-    , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
-{
-    switch (destination) {
-    case GraphicsContextGLOpenGL::Destination::Offscreen:
-        m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
-        break;
-    case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-}
-
-GC3DLayer::~GC3DLayer()
-{
-    downcast<ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient();
-}
-
-bool GC3DLayer::makeContextCurrent()
-{
-    ASSERT(m_glContext);
-    return m_glContext->makeContextCurrent();
-}
-
-PlatformGraphicsContextGL GC3DLayer::platformContext() const
-{
-    ASSERT(m_glContext);
-    return m_glContext->platformContext();
-}
-
-void GC3DLayer::swapBuffersIfNeeded()
-{
-#if USE(COORDINATED_GRAPHICS)
-    if (m_context.layerComposited())
-        return;
-
-    m_context.prepareTexture();
-    IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight);
-    TextureMapperGL::Flags flags = m_context.contextAttributes().alpha ? TextureMapperGL::ShouldBlend : 0;
-#if USE(ANGLE)
-    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(textureSize, RenderingMode::Unaccelerated);
-    if (!imageBuffer)
-        return;
-
-    m_context.paintRenderingResultsToCanvas(imageBuffer.get());
-    RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
-    if (!image)
-        return;
-#else
-    flags |= TextureMapperGL::ShouldFlipTexture;
-#endif
-
-    {
-        auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy();
-#if USE(ANGLE)
-        std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer;
-        layerBuffer = proxy.getAvailableBuffer(textureSize, m_context.m_internalColorFormat);
-        if (!layerBuffer) {
-            auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get(), flags, m_context.m_internalColorFormat);
-            static_cast<BitmapTextureGL&>(texture.get()).setPendingContents(WTFMove(image));
-            layerBuffer = makeUnique<TextureMapperPlatformLayerBuffer>(WTFMove(texture), flags);
-        } else
-            layerBuffer->textureGL().setPendingContents(WTFMove(image));
-
-        LockHolder holder(proxy.lock());
-        proxy.pushNextBuffer(WTFMove(layerBuffer));
-#else
-        LockHolder holder(proxy.lock());
-        proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
-#endif
-    }
-
-    m_context.markLayerComposited();
-#endif
-}
-
-} // namespace Nicosia
-
-#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2018 Metrological Group B.V.
- * Copyright (C) 2018 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-
-#include "GraphicsContextGLOpenGL.h"
-#include "NicosiaContentLayerTextureMapperImpl.h"
-#include <memory>
-
-namespace WebCore {
-class GLContext;
-}
-
-namespace Nicosia {
-
-class GC3DLayer : public ContentLayerTextureMapperImpl::Client {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit GC3DLayer(WebCore::GraphicsContextGLOpenGL&);
-    GC3DLayer(WebCore::GraphicsContextGLOpenGL&, WebCore::GraphicsContextGLOpenGL::Destination);
-
-    virtual ~GC3DLayer();
-
-    ContentLayer& contentLayer() const { return m_contentLayer; }
-    virtual bool makeContextCurrent();
-    virtual PlatformGraphicsContextGL platformContext() const;
-
-    void swapBuffersIfNeeded() override;
-
-private:
-    WebCore::GraphicsContextGLOpenGL& m_context;
-    std::unique_ptr<WebCore::GLContext> m_glContext;
-
-    Ref<ContentLayer> m_contentLayer;
-};
-
-} // namespace Nicosia
-
-#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp (from rev 263075, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp) (0 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018, 2019 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NicosiaGCGLANGLELayer.h"
+
+#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
+
+#include "Logging.h"
+
+#define EGL_EGL_PROTOTYPES 0
+// Skip the inclusion of ANGLE's explicit context entry points for now.
+#define GL_ANGLE_explicit_context
+#define GL_ANGLE_explicit_context_gles1
+typedef void* GLeglContext;
+#include <ANGLE/egl.h>
+#include <ANGLE/eglext.h>
+#include <ANGLE/eglext_angle.h>
+#include <ANGLE/entry_points_egl.h>
+#include <ANGLE/entry_points_gles_2_0_autogen.h>
+#include <ANGLE/entry_points_gles_ext_autogen.h>
+#include <ANGLE/gl2ext.h>
+#include <ANGLE/gl2ext_angle.h>
+
+namespace Nicosia {
+
+using namespace WebCore;
+
+const char* GCGLANGLELayer::ANGLEContext::errorString(int statusCode)
+{
+    static_assert(sizeof(int) >= sizeof(EGLint), "EGLint must not be wider than int");
+    switch (statusCode) {
+#define CASE_RETURN_STRING(name) case name: return #name
+        // https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglGetError.xhtml
+        CASE_RETURN_STRING(EGL_SUCCESS);
+        CASE_RETURN_STRING(EGL_NOT_INITIALIZED);
+        CASE_RETURN_STRING(EGL_BAD_ACCESS);
+        CASE_RETURN_STRING(EGL_BAD_ALLOC);
+        CASE_RETURN_STRING(EGL_BAD_ATTRIBUTE);
+        CASE_RETURN_STRING(EGL_BAD_CONTEXT);
+        CASE_RETURN_STRING(EGL_BAD_CONFIG);
+        CASE_RETURN_STRING(EGL_BAD_CURRENT_SURFACE);
+        CASE_RETURN_STRING(EGL_BAD_DISPLAY);
+        CASE_RETURN_STRING(EGL_BAD_SURFACE);
+        CASE_RETURN_STRING(EGL_BAD_MATCH);
+        CASE_RETURN_STRING(EGL_BAD_PARAMETER);
+        CASE_RETURN_STRING(EGL_BAD_NATIVE_PIXMAP);
+        CASE_RETURN_STRING(EGL_BAD_NATIVE_WINDOW);
+        CASE_RETURN_STRING(EGL_CONTEXT_LOST);
+#undef CASE_RETURN_STRING
+    default: return "Unknown EGL error";
+    }
+}
+
+const char* GCGLANGLELayer::ANGLEContext::lastErrorString()
+{
+    return errorString(EGL_GetError());
+}
+
+std::unique_ptr<GCGLANGLELayer::ANGLEContext> GCGLANGLELayer::ANGLEContext::createContext()
+{
+    EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
+    if (display == EGL_NO_DISPLAY)
+        return nullptr;
+
+    EGLint majorVersion, minorVersion;
+    if (EGL_Initialize(display, &majorVersion, &minorVersion) == EGL_FALSE) {
+        LOG(WebGL, "EGLDisplay Initialization failed.");
+        return nullptr;
+    }
+    LOG(WebGL, "ANGLE initialised Major: %d Minor: %d", majorVersion, minorVersion);
+
+    const char* displayExtensions = EGL_QueryString(display, EGL_EXTENSIONS);
+    LOG(WebGL, "Extensions: %s", displayExtensions);
+
+    EGLConfig config;
+    EGLint configAttributes[] = {
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+        EGL_RED_SIZE, 8,
+        EGL_GREEN_SIZE, 8,
+        EGL_BLUE_SIZE, 8,
+        EGL_ALPHA_SIZE, 8,
+        EGL_NONE
+    };
+    EGLint numberConfigsReturned = 0;
+    EGL_ChooseConfig(display, configAttributes, &config, 1, &numberConfigsReturned);
+    if (numberConfigsReturned != 1) {
+        LOG(WebGL, "EGLConfig Initialization failed.");
+        return nullptr;
+    }
+    LOG(WebGL, "Got EGLConfig");
+
+    EGL_BindAPI(EGL_OPENGL_ES_API);
+    if (EGL_GetError() != EGL_SUCCESS) {
+        LOG(WebGL, "Unable to bind to OPENGL_ES_API");
+        return nullptr;
+    }
+
+    std::vector<EGLint> contextAttributes;
+    contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
+    contextAttributes.push_back(2);
+    contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
+    contextAttributes.push_back(EGL_TRUE);
+    contextAttributes.push_back(EGL_EXTENSIONS_ENABLED_ANGLE);
+    contextAttributes.push_back(EGL_TRUE);
+    if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
+        contextAttributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
+        // EGL_LOW_POWER_ANGLE is the default. Change to
+        // EGL_HIGH_POWER_ANGLE if desired.
+        contextAttributes.push_back(EGL_LOW_POWER_ANGLE);
+    }
+    contextAttributes.push_back(EGL_NONE);
+
+    EGLContext context = EGL_CreateContext(display, config, EGL_NO_CONTEXT, contextAttributes.data());
+    if (context == EGL_NO_CONTEXT) {
+        LOG(WebGL, "EGLContext Initialization failed.");
+        return nullptr;
+    }
+    LOG(WebGL, "Got EGLContext");
+
+    return std::unique_ptr<ANGLEContext>(new ANGLEContext(display, context, EGL_NO_SURFACE));
+}
+
+GCGLANGLELayer::ANGLEContext::ANGLEContext(EGLDisplay display, EGLContext context, EGLSurface surface)
+    : m_display(display)
+    , m_context(context)
+    , m_surface(surface)
+{
+}
+
+GCGLANGLELayer::ANGLEContext::~ANGLEContext()
+{
+    if (m_context) {
+        gl::BindFramebuffer(GL_FRAMEBUFFER, 0);
+        EGL_MakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        EGL_DestroyContext(m_display, m_context);
+    }
+
+    if (m_surface)
+        EGL_DestroySurface(m_display, m_surface);
+}
+
+bool GCGLANGLELayer::ANGLEContext::makeContextCurrent()
+{
+    ASSERT(m_context);
+
+    if (EGL_GetCurrentContext() != m_context)
+        return EGL_MakeCurrent(m_display, m_surface, m_surface, m_context);
+    return true;
+}
+
+PlatformGraphicsContextGL GCGLANGLELayer::ANGLEContext::platformContext() const
+{
+    return m_context;
+}
+
+GCGLANGLELayer::GCGLANGLELayer(GraphicsContextGLOpenGL& context, GraphicsContextGLOpenGL::Destination destination)
+    : GCGLLayer(context)
+{
+    switch (destination) {
+    case GraphicsContextGLOpenGL::Destination::Offscreen:
+        m_angleContext = ANGLEContext::createContext();
+        break;
+    case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+GCGLANGLELayer::~GCGLANGLELayer()
+{
+}
+
+bool GCGLANGLELayer::makeContextCurrent()
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->makeContextCurrent();
+
+}
+
+PlatformGraphicsContextGL GCGLANGLELayer::platformContext() const
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->platformContext();
+}
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h (from rev 263075, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h) (0 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018, 2019 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
+
+#include "GLContext.h"
+#include "GraphicsContextGLOpenGL.h"
+#include "NicosiaGCGLLayer.h"
+#include <memory>
+
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+
+namespace WebCore {
+class IntSize;
+class GLContext;
+class PlatformDisplay;
+}
+
+namespace Nicosia {
+
+class GCGLANGLELayer final : public GCGLLayer {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    class ANGLEContext {
+        WTF_MAKE_NONCOPYABLE(ANGLEContext);
+    public:
+        static const char* errorString(int statusCode);
+        static const char* lastErrorString();
+
+        static std::unique_ptr<ANGLEContext> createContext();
+        virtual ~ANGLEContext();
+
+        bool makeContextCurrent();
+#if ENABLE(GRAPHICS_CONTEXT_GL)
+        PlatformGraphicsContextGL platformContext() const;
+#endif
+
+    private:
+        ANGLEContext(EGLDisplay, EGLContext, EGLSurface);
+
+        EGLDisplay m_display { nullptr };
+        EGLContext m_context { nullptr };
+        EGLSurface m_surface { nullptr };
+    };
+
+    GCGLANGLELayer(WebCore::GraphicsContextGLOpenGL&, WebCore::GraphicsContextGLOpenGL::Destination);
+    virtual ~GCGLANGLELayer();
+
+    bool makeContextCurrent() override;
+    PlatformGraphicsContextGL platformContext() const override;
+
+private:
+    std::unique_ptr<ANGLEContext> m_angleContext;
+};
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp (from rev 263075, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp) (0 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NicosiaGCGLLayer.h"
+
+#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
+
+#if USE(COORDINATED_GRAPHICS)
+#include "TextureMapperGL.h"
+#include "TextureMapperPlatformLayerBuffer.h"
+#include "TextureMapperPlatformLayerProxy.h"
+#endif
+
+#if USE(ANGLE)
+#include "ImageBuffer.h"
+#endif
+
+#include "GLContext.h"
+
+namespace Nicosia {
+
+using namespace WebCore;
+
+GCGLLayer::GCGLLayer(GraphicsContextGLOpenGL& context)
+    : m_context(context)
+    , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
+{
+}
+
+GCGLLayer::GCGLLayer(GraphicsContextGLOpenGL& context, GraphicsContextGLOpenGL::Destination destination)
+    : m_context(context)
+    , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
+{
+    switch (destination) {
+    case GraphicsContextGLOpenGL::Destination::Offscreen:
+        m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
+        break;
+    case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+GCGLLayer::~GCGLLayer()
+{
+    downcast<ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient();
+}
+
+bool GCGLLayer::makeContextCurrent()
+{
+    ASSERT(m_glContext);
+    return m_glContext->makeContextCurrent();
+}
+
+PlatformGraphicsContextGL GCGLLayer::platformContext() const
+{
+    ASSERT(m_glContext);
+    return m_glContext->platformContext();
+}
+
+void GCGLLayer::swapBuffersIfNeeded()
+{
+#if USE(COORDINATED_GRAPHICS)
+    if (m_context.layerComposited())
+        return;
+
+    m_context.prepareTexture();
+    IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight);
+    TextureMapperGL::Flags flags = m_context.contextAttributes().alpha ? TextureMapperGL::ShouldBlend : 0;
+#if USE(ANGLE)
+    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(textureSize, RenderingMode::Unaccelerated);
+    if (!imageBuffer)
+        return;
+
+    m_context.paintRenderingResultsToCanvas(imageBuffer.get());
+    RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
+    if (!image)
+        return;
+#else
+    flags |= TextureMapperGL::ShouldFlipTexture;
+#endif
+
+    {
+        auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy();
+#if USE(ANGLE)
+        std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer;
+        layerBuffer = proxy.getAvailableBuffer(textureSize, m_context.m_internalColorFormat);
+        if (!layerBuffer) {
+            auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get(), flags, m_context.m_internalColorFormat);
+            static_cast<BitmapTextureGL&>(texture.get()).setPendingContents(WTFMove(image));
+            layerBuffer = makeUnique<TextureMapperPlatformLayerBuffer>(WTFMove(texture), flags);
+        } else
+            layerBuffer->textureGL().setPendingContents(WTFMove(image));
+
+        LockHolder holder(proxy.lock());
+        proxy.pushNextBuffer(WTFMove(layerBuffer));
+#else
+        LockHolder holder(proxy.lock());
+        proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
+#endif
+    }
+
+    m_context.markLayerComposited();
+#endif
+}
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h (from rev 263075, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h) (0 => 263076)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
+
+#include "GraphicsContextGLOpenGL.h"
+#include "NicosiaContentLayerTextureMapperImpl.h"
+#include <memory>
+
+namespace WebCore {
+class GLContext;
+}
+
+namespace Nicosia {
+
+class GCGLLayer : public ContentLayerTextureMapperImpl::Client {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit GCGLLayer(WebCore::GraphicsContextGLOpenGL&);
+    GCGLLayer(WebCore::GraphicsContextGLOpenGL&, WebCore::GraphicsContextGLOpenGL::Destination);
+
+    virtual ~GCGLLayer();
+
+    ContentLayer& contentLayer() const { return m_contentLayer; }
+    virtual bool makeContextCurrent();
+    virtual PlatformGraphicsContextGL platformContext() const;
+
+    void swapBuffersIfNeeded() override;
+
+private:
+    WebCore::GraphicsContextGLOpenGL& m_context;
+    std::unique_ptr<WebCore::GLContext> m_glContext;
+
+    Ref<ContentLayer> m_contentLayer;
+};
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -62,7 +62,7 @@
 
 #if USE(NICOSIA)
 namespace Nicosia {
-class GC3DLayer;
+class GCGLLayer;
 }
 #endif
 
@@ -79,7 +79,7 @@
 class ImageBuffer;
 class ImageData;
 #if USE(TEXTURE_MAPPER)
-class TextureMapperGC3DPlatformLayer;
+class TextureMapperGCGLPlatformLayer;
 #endif
 
 typedef WTF::HashMap<CString, uint64_t> ShaderNameHash;
@@ -880,11 +880,11 @@
     ListHashSet<GCGLenum> m_syntheticErrors;
 
 #if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-    friend class Nicosia::GC3DLayer;
-    std::unique_ptr<Nicosia::GC3DLayer> m_nicosiaLayer;
+    friend class Nicosia::GCGLLayer;
+    std::unique_ptr<Nicosia::GCGLLayer> m_nicosiaLayer;
 #elif USE(TEXTURE_MAPPER)
-    friend class TextureMapperGC3DPlatformLayer;
-    std::unique_ptr<TextureMapperGC3DPlatformLayer> m_texmapLayer;
+    friend class TextureMapperGCGLPlatformLayer;
+    std::unique_ptr<TextureMapperGCGLPlatformLayer> m_texmapLayer;
 #elif !PLATFORM(COCOA)
     friend class GraphicsContextGLOpenGLPrivate;
     std::unique_ptr<GraphicsContextGLOpenGLPrivate> m_private;

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -31,7 +31,7 @@
 #if ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER)
 
 #include "GraphicsContextGLOpenGLPrivate.h"
-#include "TextureMapperGC3DPlatformLayer.h"
+#include "TextureMapperGCGLPlatformLayer.h"
 #include <ANGLE/ShaderLang.h>
 #include <wtf/Deque.h>
 #include <wtf/NeverDestroyed.h>
@@ -75,9 +75,9 @@
 
 #if USE(NICOSIA)
 #if USE(ANGLE)
-#include "NicosiaGC3DANGLELayer.h"
+#include "NicosiaGCGLANGLELayer.h"
 #else
-#include "NicosiaGC3DLayer.h"
+#include "NicosiaGCGLLayer.h"
 #endif
 #endif
 
@@ -135,9 +135,9 @@
 {
     ASSERT_UNUSED(sharedContext, !sharedContext);
 #if USE(NICOSIA)
-    m_nicosiaLayer = WTF::makeUnique<Nicosia::GC3DANGLELayer>(*this, destination);
+    m_nicosiaLayer = WTF::makeUnique<Nicosia::GCGLANGLELayer>(*this, destination);
 #else
-    m_texmapLayer = WTF::makeUnique<TextureMapperGC3DPlatformLayer>(*this, destination);
+    m_texmapLayer = WTF::makeUnique<TextureMapperGCGLPlatformLayer>(*this, destination);
 #endif
     makeContextCurrent();
 
@@ -208,9 +208,9 @@
 {
     ASSERT_UNUSED(sharedContext, !sharedContext);
 #if USE(NICOSIA)
-    m_nicosiaLayer = makeUnique<Nicosia::GC3DLayer>(*this, destination);
+    m_nicosiaLayer = makeUnique<Nicosia::GCGLLayer>(*this, destination);
 #else
-    m_texmapLayer = makeUnique<TextureMapperGC3DPlatformLayer>(*this, destination);
+    m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this, destination);
 #endif
 
     makeContextCurrent();

Deleted: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,124 +0,0 @@
-/*
- * 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 ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
-
-#include "BitmapTextureGL.h"
-#include "GLContext.h"
-#include "TextureMapperGLHeaders.h"
-#include "TextureMapperPlatformLayerBuffer.h"
-#include "TextureMapperPlatformLayerProxy.h"
-
-namespace WebCore {
-
-TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer(GraphicsContextGLOpenGL& context, GraphicsContextGLOpenGL::Destination destination)
-    : m_context(context)
-{
-    switch (destination) {
-    case GraphicsContextGLOpenGL::Destination::Offscreen:
-        m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
-        break;
-    case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-
-#if USE(COORDINATED_GRAPHICS)
-    m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
-#endif
-}
-
-TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer()
-{
-#if !USE(COORDINATED_GRAPHICS)
-    if (client())
-        client()->platformLayerWillBeDestroyed();
-#endif
-}
-
-bool TextureMapperGC3DPlatformLayer::makeContextCurrent()
-{
-    ASSERT(m_glContext);
-    return m_glContext->makeContextCurrent();
-}
-
-PlatformGraphicsContextGL TextureMapperGC3DPlatformLayer::platformContext() const
-{
-    ASSERT(m_glContext);
-    return m_glContext->platformContext();
-}
-
-#if USE(COORDINATED_GRAPHICS)
-RefPtr<TextureMapperPlatformLayerProxy> TextureMapperGC3DPlatformLayer::proxy() const
-{
-    return m_platformLayerProxy.copyRef();
-}
-
-void TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded()
-{
-    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(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
-    }
-
-    m_context.markLayerComposited();
-}
-#else
-void TextureMapperGC3DPlatformLayer::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
-{
-    ASSERT(m_glContext);
-
-    m_context.markLayerComposited();
-
-#if USE(TEXTURE_MAPPER_GL)
-    auto attrs = m_context.contextAttributes();
-    ASSERT(m_context.m_state.boundReadFBO == m_context.m_state.boundDrawFBO);
-    if (attrs.antialias && m_context.m_state.boundDrawFBO == m_context.m_multisampleFBO) {
-        GLContext* previousActiveContext = GLContext::current();
-        if (previousActiveContext != m_glContext.get())
-            m_context.makeContextCurrent();
-
-        m_context.resolveMultisamplingIfNecessary();
-        ::glBindFramebuffer(GraphicsContextGLOpenGL::FRAMEBUFFER, m_context.m_state.boundDrawFBO);
-
-        if (previousActiveContext && previousActiveContext != m_glContext.get())
-            previousActiveContext->makeContextCurrent();
-    }
-
-    TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(textureMapper);
-    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (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)
-
-} // namespace WebCore
-
-#endif // ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER)

Deleted: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h (263075 => 263076)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h	2020-06-16 05:04:44 UTC (rev 263075)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -1,61 +0,0 @@
-/*
- * 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 ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
-
-#include "GraphicsContextGLOpenGL.h"
-#include "PlatformLayer.h"
-#include "TextureMapperPlatformLayer.h"
-#include "TextureMapperPlatformLayerProxyProvider.h"
-
-namespace WebCore {
-
-class GLContext;
-class TextureMapperPlatformLayerProxy;
-
-class TextureMapperGC3DPlatformLayer : public PlatformLayer {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    TextureMapperGC3DPlatformLayer(GraphicsContextGLOpenGL&, GraphicsContextGLOpenGL::Destination);
-    virtual ~TextureMapperGC3DPlatformLayer();
-
-    bool makeContextCurrent();
-    PlatformGraphicsContextGL platformContext() const;
-
-#if USE(COORDINATED_GRAPHICS)
-    RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
-    void swapBuffersIfNeeded() override;
-#else
-    virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
-#endif
-
-private:
-    GraphicsContextGLOpenGL& m_context;
-    std::unique_ptr<GLContext> m_glContext;
-
-#if USE(COORDINATED_GRAPHICS)
-    RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp (from rev 263075, trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp) (0 => 263076)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp	2020-06-16 05:39:50 UTC (rev 263076)
@@ -0,0 +1,124 @@
+/*
+ * 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 "TextureMapperGCGLPlatformLayer.h"
+
+#if ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
+
+#include "BitmapTextureGL.h"
+#include "GLContext.h"
+#include "TextureMapperGLHeaders.h"
+#include "TextureMapperPlatformLayerBuffer.h"
+#include "TextureMapperPlatformLayerProxy.h"
+
+namespace WebCore {
+
+TextureMapperGCGLPlatformLayer::TextureMapperGCGLPlatformLayer(GraphicsContextGLOpenGL& context, GraphicsContextGLOpenGL::Destination destination)
+    : m_context(context)
+{
+    switch (destination) {
+    case GraphicsContextGLOpenGL::Destination::Offscreen:
+        m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
+        break;
+    case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+#if USE(COORDINATED_GRAPHICS)
+    m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
+#endif
+}
+
+TextureMapperGCGLPlatformLayer::~TextureMapperGCGLPlatformLayer()
+{
+#if !USE(COORDINATED_GRAPHICS)
+    if (client())
+        client()->platformLayerWillBeDestroyed();
+#endif
+}
+
+bool TextureMapperGCGLPlatformLayer::makeContextCurrent()
+{
+    ASSERT(m_glContext);
+    return m_glContext->makeContextCurrent();
+}
+
+PlatformGraphicsContextGL TextureMapperGCGLPlatformLayer::platformContext() const
+{
+    ASSERT(m_glContext);
+    return m_glContext->platformContext();
+}
+
+#if USE(COORDINATED_GRAPHICS)
+RefPtr<TextureMapperPlatformLayerProxy> TextureMapperGCGLPlatformLayer::proxy() const
+{
+    return m_platformLayerProxy.copyRef();
+}
+
+void TextureMapperGCGLPlatformLayer::swapBuffersIfNeeded()
+{
+    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(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
+    }
+
+    m_context.markLayerComposited();
+}
+#else
+void TextureMapperGCGLPlatformLayer::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+    ASSERT(m_glContext);
+
+    m_context.markLayerComposited();
+
+#if USE(TEXTURE_MAPPER_GL)
+    auto attrs = m_context.contextAttributes();
+    ASSERT(m_context.m_state.boundReadFBO == m_context.m_state.boundDrawFBO);
+    if (attrs.antialias && m_context.m_state.boundDrawFBO == m_context.m_multisampleFBO) {
+        GLContext* previousActiveContext = GLContext::current();
+        if (previousActiveContext != m_glContext.get())
+            m_context.makeContextCurrent();
+
+        m_context.resolveMultisamplingIfNecessary();
+        ::glBindFramebuffer(GraphicsContextGLOpenGL::FRAMEBUFFER, m_context.m_state.boundDrawFBO);
+
+        if (previousActiveContext && previousActiveContext != m_glContext.get())
+            previousActiveContext->makeContextCurrent();
+    }
+
+    TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(textureMapper);
+    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (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)
+
+} // namespace WebCore
+
+#endif // ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h (from rev 263075, trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h) (0 => 263076)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h	2020-06-16 05:39:50 UTC (rev 263076)
@@ -0,0 +1,61 @@
+/*
+ * 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 ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
+
+#include "GraphicsContextGLOpenGL.h"
+#include "PlatformLayer.h"
+#include "TextureMapperPlatformLayer.h"
+#include "TextureMapperPlatformLayerProxyProvider.h"
+
+namespace WebCore {
+
+class GLContext;
+class TextureMapperPlatformLayerProxy;
+
+class TextureMapperGCGLPlatformLayer : public PlatformLayer {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    TextureMapperGCGLPlatformLayer(GraphicsContextGLOpenGL&, GraphicsContextGLOpenGL::Destination);
+    virtual ~TextureMapperGCGLPlatformLayer();
+
+    bool makeContextCurrent();
+    PlatformGraphicsContextGL platformContext() const;
+
+#if USE(COORDINATED_GRAPHICS)
+    RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
+    void swapBuffersIfNeeded() override;
+#else
+    virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
+#endif
+
+private:
+    GraphicsContextGLOpenGL& m_context;
+    std::unique_ptr<GLContext> m_glContext;
+
+#if USE(COORDINATED_GRAPHICS)
+    RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GRAPHICS_CONTEXT_GL) && USE(TEXTURE_MAPPER)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to