Title: [288014] trunk/Source/WebCore
Revision
288014
Author
[email protected]
Date
2022-01-14 04:55:03 -0800 (Fri, 14 Jan 2022)

Log Message

[GTK][WPE] Share code between NicosiaGCGLLayer+ANGLE and NicosiaImageBufferPipe
https://bugs.webkit.org/show_bug.cgi?id=235182

Reviewed by Alejandro G. Castro.

Rename NicosiaGCGLANGLELayer to NicosiaGCGLANGLEPipe and have it
inherit from NicosiaImageBufferPipe instead of NicosiaGCGLLayer.

No new tests, no change in behaviour.

* platform/TextureMapper.cmake:
* platform/graphics/angle/GraphicsContextGLANGLE.h:
* platform/graphics/nicosia/NicosiaImageBufferPipe.cpp:
(Nicosia::NicosiaImageBufferPipe::NicosiaImageBufferPipe):
(Nicosia::NicosiaImageBufferPipe::source const):
(Nicosia::NicosiaImageBufferPipe::layerContentsDisplayDelegate):
(): Deleted.
(Nicosia::WebCore::NicosiaImageBufferPipeSource::NicosiaImageBufferPipeSource): Deleted.
(Nicosia::WebCore::NicosiaImageBufferPipeSource::~NicosiaImageBufferPipeSource): Deleted.
(Nicosia::WebCore::NicosiaImageBufferPipeSource::handle): Deleted.
(Nicosia::WebCore::NicosiaImageBufferPipeSource::swapBuffersIfNeeded): Deleted.
* platform/graphics/nicosia/NicosiaImageBufferPipe.h: Added.
(Nicosia::NicosiaImageBufferPipeSource::platformLayer const):
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp.
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h.
* platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp:
(Nicosia::GCGLLayer::GCGLLayer):
(Nicosia::GCGLLayer::swapBuffersIfNeeded):
* platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h:
* platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
(WebCore::GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper):
* platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::GraphicsContextGLANGLE):
(WebCore::GraphicsContextGLANGLE::platformDisplay const):
(WebCore::GraphicsContextGLANGLE::platformConfig const):
(WebCore::GraphicsContextGLANGLE::makeContextCurrent):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288013 => 288014)


--- trunk/Source/WebCore/ChangeLog	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/ChangeLog	2022-01-14 12:55:03 UTC (rev 288014)
@@ -1,3 +1,42 @@
+2022-01-14  Chris Lord  <[email protected]>
+
+        [GTK][WPE] Share code between NicosiaGCGLLayer+ANGLE and NicosiaImageBufferPipe
+        https://bugs.webkit.org/show_bug.cgi?id=235182
+
+        Reviewed by Alejandro G. Castro.
+
+        Rename NicosiaGCGLANGLELayer to NicosiaGCGLANGLEPipe and have it
+        inherit from NicosiaImageBufferPipe instead of NicosiaGCGLLayer.
+
+        No new tests, no change in behaviour.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/angle/GraphicsContextGLANGLE.h:
+        * platform/graphics/nicosia/NicosiaImageBufferPipe.cpp:
+        (Nicosia::NicosiaImageBufferPipe::NicosiaImageBufferPipe):
+        (Nicosia::NicosiaImageBufferPipe::source const):
+        (Nicosia::NicosiaImageBufferPipe::layerContentsDisplayDelegate):
+        (): Deleted.
+        (Nicosia::WebCore::NicosiaImageBufferPipeSource::NicosiaImageBufferPipeSource): Deleted.
+        (Nicosia::WebCore::NicosiaImageBufferPipeSource::~NicosiaImageBufferPipeSource): Deleted.
+        (Nicosia::WebCore::NicosiaImageBufferPipeSource::handle): Deleted.
+        (Nicosia::WebCore::NicosiaImageBufferPipeSource::swapBuffersIfNeeded): Deleted.
+        * platform/graphics/nicosia/NicosiaImageBufferPipe.h: Added.
+        (Nicosia::NicosiaImageBufferPipeSource::platformLayer const):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp.
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h.
+        * platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp:
+        (Nicosia::GCGLLayer::GCGLLayer):
+        (Nicosia::GCGLLayer::swapBuffersIfNeeded):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h:
+        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
+        (WebCore::GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper):
+        * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
+        (WebCore::GraphicsContextGLANGLE::GraphicsContextGLANGLE):
+        (WebCore::GraphicsContextGLANGLE::platformDisplay const):
+        (WebCore::GraphicsContextGLANGLE::platformConfig const):
+        (WebCore::GraphicsContextGLANGLE::makeContextCurrent):
+
 2022-01-14  Carlos Garcia Campos  <[email protected]>
 
         [GTK][a11y] Unregister objects and clear cache when last client disconnect with ATSPI

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (288013 => 288014)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2022-01-14 12:55:03 UTC (rev 288014)
@@ -126,7 +126,7 @@
 
 if (USE_ANGLE_WEBGL)
     list(APPEND WebCore_SOURCES
-        platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp
+        platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp
     )
 endif ()
 

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h	2022-01-14 12:55:03 UTC (rev 288014)
@@ -42,7 +42,7 @@
 
 #if USE(NICOSIA)
 namespace Nicosia {
-class GCGLANGLELayer;
+class GCGLANGLEPipe;
 class GCGLLayer;
 }
 #endif
@@ -450,7 +450,11 @@
     GCGLuint m_intermediateTexture { 0 };
 #endif
 #if USE(NICOSIA)
-    std::unique_ptr<Nicosia::GCGLANGLELayer> m_nicosiaLayer;
+#if USE(ANGLE)
+    std::unique_ptr<Nicosia::GCGLANGLEPipe> m_nicosiaPipe;
+#else
+    std::unique_ptr<Nicosia::GCGLLayer> m_nicosiaLayer;
+#endif
 #elif USE(TEXTURE_MAPPER)
     std::unique_ptr<TextureMapperGCGLPlatformLayer> m_texmapLayer;
 #endif

Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp	2022-01-14 12:55:03 UTC (rev 288014)
@@ -25,11 +25,10 @@
  */
 
 #include "config.h"
+#include "NicosiaImageBufferPipe.h"
+
 #include "ImageBuffer.h"
-
-#include "ImageBufferPipe.h"
 #include "NativeImage.h"
-#include "NicosiaContentLayerTextureMapperImpl.h"
 #include "NicosiaPlatformLayer.h"
 #include "TextureMapperPlatformLayerBuffer.h"
 #include "TextureMapperPlatformLayerProxy.h"
@@ -44,60 +43,6 @@
 
 using namespace WebCore;
 
-namespace {
-class NicosiaImageBufferPipeSource final : public ImageBufferPipe::Source, public ContentLayerTextureMapperImpl::Client {
-public:
-    NicosiaImageBufferPipeSource();
-    virtual ~NicosiaImageBufferPipeSource();
-
-    // ImageBufferPipe::Source overrides.
-    void handle(RefPtr<ImageBuffer>&&) final;
-
-    ContentLayer* platformLayer() const { return m_nicosiaLayer.get(); }
-private:
-    // ContentLayerTextureMapperImpl::Client overrides.
-    void swapBuffersIfNeeded() override;
-
-    RefPtr<ContentLayer> m_nicosiaLayer;
-
-    mutable Lock m_imageBufferLock;
-    RefPtr<ImageBuffer> m_imageBuffer;
-};
-
-class PipeSourceDisplayDelegate final : public GraphicsLayerContentsDisplayDelegate {
-public:
-    static Ref<PipeSourceDisplayDelegate> create(RefPtr<ContentLayer>&& nicosiaLayer)
-    {
-        return adoptRef(*new PipeSourceDisplayDelegate(WTFMove(nicosiaLayer)));
-    }
-
-    // GraphicsLayerContentsDisplayDelegate overrides.
-    PlatformLayer* platformLayer() const final { return m_nicosiaLayer.get(); }
-private:
-    PipeSourceDisplayDelegate(RefPtr<ContentLayer>&& nicosiaLayer)
-        : m_nicosiaLayer(WTFMove(nicosiaLayer))
-    {
-    }
-
-    RefPtr<ContentLayer> m_nicosiaLayer;
-};
-
-class NicosiaImageBufferPipe final : public ImageBufferPipe {
-public:
-    NicosiaImageBufferPipe()
-        : m_source(adoptRef(*new NicosiaImageBufferPipeSource))
-        , m_layerContentsDisplayDelegate(PipeSourceDisplayDelegate::create(m_source->platformLayer()))
-    {
-    }
-
-    // ImageBufferPipe overrides.
-    RefPtr<ImageBufferPipe::Source> source() const final { return m_source.ptr(); }
-    RefPtr<GraphicsLayerContentsDisplayDelegate> layerContentsDisplayDelegate() final { return m_layerContentsDisplayDelegate.ptr(); }
-private:
-    Ref<NicosiaImageBufferPipeSource> m_source;
-    Ref<PipeSourceDisplayDelegate> m_layerContentsDisplayDelegate;
-};
-
 NicosiaImageBufferPipeSource::NicosiaImageBufferPipeSource()
 {
     m_nicosiaLayer = Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this));
@@ -163,8 +108,22 @@
 {
 }
 
+NicosiaImageBufferPipe::NicosiaImageBufferPipe()
+    : m_source(adoptRef(*new NicosiaImageBufferPipeSource))
+    , m_layerContentsDisplayDelegate(NicosiaImageBufferPipeSourceDisplayDelegate::create(m_source->platformLayer()))
+{
 }
 
+RefPtr<ImageBufferPipe::Source> NicosiaImageBufferPipe::source() const
+{
+    return m_source.ptr();
+}
+
+RefPtr<GraphicsLayerContentsDisplayDelegate> NicosiaImageBufferPipe::layerContentsDisplayDelegate()
+{
+    return m_layerContentsDisplayDelegate.ptr();
+}
+
 } // namespace Nicosia
 
 namespace WebCore {

Added: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.h (0 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.h	2022-01-14 12:55:03 UTC (rev 288014)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2020,2022 Igalia S.L
+ * Copyright (C) 2020,2022 Metrological Group B.V.
+ *
+ * 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 APPLE AND ITS 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 APPLE OR ITS 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
+
+#include "ImageBufferPipe.h"
+#include "NicosiaContentLayerTextureMapperImpl.h"
+
+namespace Nicosia {
+
+class NicosiaImageBufferPipeSourceDisplayDelegate final : public WebCore::GraphicsLayerContentsDisplayDelegate {
+public:
+    static Ref<NicosiaImageBufferPipeSourceDisplayDelegate> create(RefPtr<ContentLayer>&& nicosiaLayer)
+    {
+        return adoptRef(*new NicosiaImageBufferPipeSourceDisplayDelegate(WTFMove(nicosiaLayer)));
+    }
+
+    // GraphicsLayerContentsDisplayDelegate overrides.
+    PlatformLayer* platformLayer() const final { return m_nicosiaLayer.get(); }
+private:
+    NicosiaImageBufferPipeSourceDisplayDelegate(RefPtr<ContentLayer>&& nicosiaLayer)
+        : m_nicosiaLayer(WTFMove(nicosiaLayer))
+    {
+    }
+
+    RefPtr<ContentLayer> m_nicosiaLayer;
+};
+
+class NicosiaImageBufferPipeSource : public WebCore::ImageBufferPipe::Source, public ContentLayerTextureMapperImpl::Client {
+public:
+    NicosiaImageBufferPipeSource();
+    virtual ~NicosiaImageBufferPipeSource();
+
+    // ImageBufferPipe::Source overrides.
+    void handle(RefPtr<WebCore::ImageBuffer>&&) final;
+
+    // ContentLayerTextureMapperImpl::Client overrides.
+    void swapBuffersIfNeeded() override;
+
+    ContentLayer* platformLayer() const { return m_nicosiaLayer.get(); }
+private:
+    RefPtr<ContentLayer> m_nicosiaLayer;
+
+    mutable Lock m_imageBufferLock;
+    RefPtr<WebCore::ImageBuffer> m_imageBuffer;
+};
+
+class NicosiaImageBufferPipe final : public WebCore::ImageBufferPipe {
+public:
+    NicosiaImageBufferPipe();
+
+    // ImageBufferPipe overrides.
+    RefPtr<WebCore::ImageBufferPipe::Source> source() const final;
+    RefPtr<WebCore::GraphicsLayerContentsDisplayDelegate> layerContentsDisplayDelegate() final;
+private:
+    Ref<NicosiaImageBufferPipeSource> m_source;
+    Ref<NicosiaImageBufferPipeSourceDisplayDelegate> m_layerContentsDisplayDelegate;
+};
+
+}

Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2022-01-14 12:55:03 UTC (rev 288014)
@@ -1,217 +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 "NicosiaGCGLANGLELayer.h"
-
-#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-
-#include "ANGLEHeaders.h"
-#include "Logging.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, config, context, EGL_NO_SURFACE));
-}
-
-GCGLANGLELayer::ANGLEContext::ANGLEContext(EGLDisplay display, EGLConfig config, EGLContext context, EGLSurface surface)
-    : m_display(display)
-    , m_config(config)
-    , 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;
-}
-
-PlatformGraphicsContextGLDisplay GCGLANGLELayer::ANGLEContext::platformDisplay() const
-{
-    return m_display;
-}
-
-PlatformGraphicsContextGLConfig GCGLANGLELayer::ANGLEContext::platformConfig() const
-{
-    return m_config;
-}
-
-GCGLANGLELayer::GCGLANGLELayer(GraphicsContextGLANGLE& context)
-    : GCGLLayer(context)
-    , m_angleContext(ANGLEContext::createContext())
-{
-}
-
-GCGLANGLELayer::~GCGLANGLELayer()
-{
-}
-
-bool GCGLANGLELayer::makeContextCurrent()
-{
-    ASSERT(m_angleContext);
-    return m_angleContext->makeContextCurrent();
-
-}
-
-PlatformGraphicsContextGL GCGLANGLELayer::platformContext() const
-{
-    ASSERT(m_angleContext);
-    return m_angleContext->platformContext();
-}
-
-PlatformGraphicsContextGLDisplay GCGLANGLELayer::platformDisplay() const
-{
-    ASSERT(m_angleContext);
-    return m_angleContext->platformDisplay();
-}
-
-PlatformGraphicsContextGLConfig GCGLANGLELayer::platformConfig() const
-{
-    ASSERT(m_angleContext);
-    return m_angleContext->platformContext();
-}
-
-} // namespace Nicosia
-
-#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h	2022-01-14 12:55:03 UTC (rev 288014)
@@ -1,92 +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 "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(WEBGL)
-        PlatformGraphicsContextGL platformContext() const;
-        PlatformGraphicsContextGLDisplay platformDisplay() const;
-        PlatformGraphicsContextGLConfig platformConfig() const;
-#endif
-
-    private:
-        ANGLEContext(EGLDisplay, EGLConfig, EGLContext, EGLSurface);
-
-        EGLDisplay m_display { nullptr };
-        EGLConfig m_config { nullptr };
-        EGLContext m_context { nullptr };
-        EGLSurface m_surface { nullptr };
-    };
-
-    GCGLANGLELayer(WebCore::GraphicsContextGLANGLE&);
-    virtual ~GCGLANGLELayer();
-
-    bool makeContextCurrent() override;
-    PlatformGraphicsContextGL platformContext() const override;
-    PlatformGraphicsContextGLDisplay platformDisplay() const;
-    PlatformGraphicsContextGLConfig platformConfig() const;
-private:
-    std::unique_ptr<ANGLEContext> m_angleContext;
-};
-
-} // namespace Nicosia
-
-#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp (from rev 288013, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp) (0 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp	2022-01-14 12:55:03 UTC (rev 288014)
@@ -0,0 +1,258 @@
+/*
+ * 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 "NicosiaGCGLANGLEPipe.h"
+
+#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
+
+#include "ANGLEHeaders.h"
+#include "ImageBuffer.h"
+#include "Logging.h"
+#include "TextureMapperGL.h"
+#include "TextureMapperPlatformLayerBuffer.h"
+#include "TextureMapperPlatformLayerProxy.h"
+
+namespace Nicosia {
+
+using namespace WebCore;
+
+GCGLANGLEPipeSource::GCGLANGLEPipeSource(WebCore::GraphicsContextGLANGLE& context)
+    : m_context(context)
+{
+}
+
+GCGLANGLEPipeSource::~GCGLANGLEPipeSource()
+{
+}
+
+void GCGLANGLEPipeSource::swapBuffersIfNeeded()
+{
+    if (m_context.layerComposited())
+        return;
+
+    m_context.prepareTexture();
+    RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(m_context.getInternalFramebufferSize(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    if (!imageBuffer)
+        return;
+
+    m_context.paintRenderingResultsToCanvas(*imageBuffer.get());
+
+    handle(WTFMove(imageBuffer));
+
+    m_context.markLayerComposited();
+}
+
+const char* GCGLANGLEPipe::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* GCGLANGLEPipe::ANGLEContext::lastErrorString()
+{
+    return errorString(EGL_GetError());
+}
+
+std::unique_ptr<GCGLANGLEPipe::ANGLEContext> GCGLANGLEPipe::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, config, context, EGL_NO_SURFACE));
+}
+
+GCGLANGLEPipe::ANGLEContext::ANGLEContext(EGLDisplay display, EGLConfig config, EGLContext context, EGLSurface surface)
+    : m_display(display)
+    , m_config(config)
+    , m_context(context)
+    , m_surface(surface)
+{
+}
+
+GCGLANGLEPipe::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 GCGLANGLEPipe::ANGLEContext::makeContextCurrent()
+{
+    ASSERT(m_context);
+
+    if (EGL_GetCurrentContext() != m_context)
+        return EGL_MakeCurrent(m_display, m_surface, m_surface, m_context);
+    return true;
+}
+
+PlatformGraphicsContextGL GCGLANGLEPipe::ANGLEContext::platformContext() const
+{
+    return m_context;
+}
+
+PlatformGraphicsContextGLDisplay GCGLANGLEPipe::ANGLEContext::platformDisplay() const
+{
+    return m_display;
+}
+
+PlatformGraphicsContextGLConfig GCGLANGLEPipe::ANGLEContext::platformConfig() const
+{
+    return m_config;
+}
+
+GCGLANGLEPipe::GCGLANGLEPipe(GraphicsContextGLANGLE& context)
+    : m_angleContext(ANGLEContext::createContext())
+    , m_source(adoptRef(*new GCGLANGLEPipeSource(context)))
+    , m_layerContentsDisplayDelegate(NicosiaImageBufferPipeSourceDisplayDelegate::create(m_source->platformLayer()))
+{
+}
+
+GCGLANGLEPipe::~GCGLANGLEPipe()
+{
+}
+
+bool GCGLANGLEPipe::makeContextCurrent()
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->makeContextCurrent();
+
+}
+
+PlatformGraphicsContextGL GCGLANGLEPipe::platformContext() const
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->platformContext();
+}
+
+PlatformGraphicsContextGLDisplay GCGLANGLEPipe::platformDisplay() const
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->platformDisplay();
+}
+
+PlatformGraphicsContextGLConfig GCGLANGLEPipe::platformConfig() const
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->platformContext();
+}
+
+RefPtr<ImageBufferPipe::Source> GCGLANGLEPipe::source() const
+{
+    return m_source.ptr();
+}
+
+RefPtr<GraphicsLayerContentsDisplayDelegate> GCGLANGLEPipe::layerContentsDisplayDelegate()
+{
+    return m_layerContentsDisplayDelegate.ptr();
+}
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h (from rev 288013, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h) (0 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h	2022-01-14 12:55:03 UTC (rev 288014)
@@ -0,0 +1,110 @@
+/*
+ * 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 "GraphicsContextGLANGLE.h"
+#include "NicosiaImageBufferPipe.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 GCGLANGLEPipeSource : public NicosiaImageBufferPipeSource {
+public:
+    GCGLANGLEPipeSource(WebCore::GraphicsContextGLANGLE&);
+    virtual ~GCGLANGLEPipeSource();
+
+    // ContentLayerTextureMapperImpl::Client overrides.
+    void swapBuffersIfNeeded() final;
+private:
+    WebCore::GraphicsContextGLANGLE& m_context;
+};
+
+class GCGLANGLEPipe final : public WebCore::ImageBufferPipe {
+    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(WEBGL)
+        PlatformGraphicsContextGL platformContext() const;
+        PlatformGraphicsContextGLDisplay platformDisplay() const;
+        PlatformGraphicsContextGLConfig platformConfig() const;
+#endif
+
+    private:
+        ANGLEContext(EGLDisplay, EGLConfig, EGLContext, EGLSurface);
+
+        EGLDisplay m_display { nullptr };
+        EGLConfig m_config { nullptr };
+        EGLContext m_context { nullptr };
+        EGLSurface m_surface { nullptr };
+    };
+
+    GCGLANGLEPipe(WebCore::GraphicsContextGLANGLE&);
+    virtual ~GCGLANGLEPipe();
+
+    bool makeContextCurrent();
+    PlatformGraphicsContextGL platformContext() const;
+    PlatformGraphicsContextGLDisplay platformDisplay() const;
+    PlatformGraphicsContextGLConfig platformConfig() const;
+
+    // ImageBufferPipe overrides.
+    RefPtr<WebCore::ImageBufferPipe::Source> source() const final;
+    RefPtr<WebCore::GraphicsLayerContentsDisplayDelegate> layerContentsDisplayDelegate() final;
+
+private:
+    std::unique_ptr<ANGLEContext> m_angleContext;
+    Ref<GCGLANGLEPipeSource> m_source;
+    Ref<NicosiaImageBufferPipeSourceDisplayDelegate> m_layerContentsDisplayDelegate;
+};
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2022-01-14 12:55:03 UTC (rev 288014)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "NicosiaGCGLLayer.h"
 
-#if ENABLE(WEBGL) && USE(NICOSIA) && USE(TEXTURE_MAPPER)
+#if ENABLE(WEBGL) && USE(NICOSIA) && USE(TEXTURE_MAPPER) && !USE(ANGLE)
 
 #if USE(COORDINATED_GRAPHICS)
 #include "TextureMapperGL.h"
@@ -37,13 +37,6 @@
 #include "TextureMapperPlatformLayerProxy.h"
 #endif
 
-#if USE(ANGLE)
-#include "ImageBuffer.h"
-#if USE(CAIRO)
-#include <cairo.h>
-#endif
-#endif
-
 #include "GLContext.h"
 
 namespace Nicosia {
@@ -50,7 +43,7 @@
 
 using namespace WebCore;
 
-GCGLLayer::GCGLLayer(GraphicsContextGLType& context)
+GCGLLayer::GCGLLayer(GraphicsContextGLOpenGL& context)
     : m_context(context)
     , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
 {
@@ -82,64 +75,15 @@
 
     m_context.prepareTexture();
     IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight);
-#if USE(ANGLE)
-    RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(textureSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
-    if (!imageBuffer)
-        return;
 
-    m_context.paintRenderingResultsToCanvas(*imageBuffer.get());
-#else
     TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture;
     if (m_context.contextAttributes().alpha)
         flags |= TextureMapperGL::ShouldBlend;
-#endif
 
     {
         auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy();
-#if USE(ANGLE)
-        // FIXME: This is duplicated from NicosiaImageBufferPipe, but should be shared somehow.
-        auto proxyOperation =
-            [this, imageBuffer = WTFMove(imageBuffer)] () mutable {
-                auto nativeImage = ImageBuffer::sinkIntoNativeImage(WTFMove(imageBuffer));
-                if (!nativeImage)
-                    return;
-
-                auto size = nativeImage->size();
-                auto flags = nativeImage->hasAlpha() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag;
-
-                auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy();
-                Locker locker { proxy.lock() };
-
-                std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = proxy.getAvailableBuffer(size, flags);
-
-                if (!layerBuffer) {
-                    auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get());
-                    texture->reset(size, flags);
-                    layerBuffer = makeUnique<TextureMapperPlatformLayerBuffer>(WTFMove(texture), nativeImage->hasAlpha() ? TextureMapperGL::ShouldBlend : TextureMapperGL::NoFlag);
-                }
-
-#if USE(CAIRO)
-                auto* surface = nativeImage->platformImage().get();
-                auto* imageData = cairo_image_surface_get_data(surface);
-                layerBuffer->textureGL().updateContents(imageData, IntRect(IntPoint(), size), IntPoint(), cairo_image_surface_get_stride(surface));
-#else
-                notImplemented();
-#endif
-
-                proxy.pushNextBuffer(WTFMove(layerBuffer));
-
-                m_context.markLayerComposited();
-            };
-
-        proxy.scheduleUpdateOnCompositorThread([proxyOperation] () mutable {
-            proxyOperation();
-        });
-
-        return;
-#else
         Locker locker { proxy.lock() };
         proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
-#endif
     }
 
     m_context.markLayerComposited();

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.h	2022-01-14 12:55:03 UTC (rev 288014)
@@ -28,17 +28,12 @@
 
 #pragma once
 
-#if ENABLE(WEBGL) && USE(NICOSIA) && USE(TEXTURE_MAPPER)
+#if ENABLE(WEBGL) && USE(NICOSIA) && USE(TEXTURE_MAPPER) && !USE(ANGLE)
 
+#include "GraphicsContextGLOpenGL.h"
 #include "NicosiaContentLayerTextureMapperImpl.h"
 #include <memory>
 
-#if USE(ANGLE)
-#include "GraphicsContextGLANGLE.h"
-#else
-#include "GraphicsContextGLOpenGL.h"
-#endif
-
 namespace WebCore {
 class GLContext;
 }
@@ -48,12 +43,7 @@
 class GCGLLayer : public ContentLayerTextureMapperImpl::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-#if USE(ANGLE)
-    using GraphicsContextGLType = WebCore::GraphicsContextGLANGLE;
-#else
-    using GraphicsContextGLType = WebCore::GraphicsContextGLOpenGL;
-#endif
-    explicit GCGLLayer(GraphicsContextGLType&);
+    explicit GCGLLayer(WebCore::GraphicsContextGLOpenGL&);
 
     virtual ~GCGLLayer();
 
@@ -64,7 +54,7 @@
     void swapBuffersIfNeeded() override;
 
 private:
-    GraphicsContextGLType& m_context;
+    WebCore::GraphicsContextGLOpenGL& m_context;
     std::unique_ptr<WebCore::GLContext> m_glContext;
 
     Ref<ContentLayer> m_contentLayer;

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2022-01-14 12:55:03 UTC (rev 288014)
@@ -60,7 +60,7 @@
 
 #if USE(NICOSIA)
 #if USE(ANGLE)
-#include "NicosiaGCGLANGLELayer.h"
+#include "NicosiaGCGLANGLEPipe.h"
 #else
 #include "NicosiaGCGLLayer.h"
 #endif
@@ -116,7 +116,11 @@
 GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper(GraphicsContextGLAttributes&& attributes)
     : GraphicsContextGLTextureMapperBase(WTFMove(attributes))
 #if USE(NICOSIA)
+#if USE(ANGLE)
+    , m_layerContentsDisplayDelegate(*m_nicosiaPipe->layerContentsDisplayDelegate())
+#else
     , m_layerContentsDisplayDelegate(PlatformLayerDisplayDelegate::create(&m_nicosiaLayer->contentLayer()))
+#endif
 #else
     , m_layerContentsDisplayDelegate(PlatformLayerDisplayDelegate::create(m_texmapLayer.get()))
 #endif

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp (288013 => 288014)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp	2022-01-14 12:08:58 UTC (rev 288013)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp	2022-01-14 12:55:03 UTC (rev 288014)
@@ -36,7 +36,7 @@
 #include "PixelBuffer.h"
 
 #if USE(NICOSIA)
-#include "NicosiaGCGLANGLELayer.h"
+#include "NicosiaGCGLANGLEPipe.h"
 #else
 #include "TextureMapperGCGLPlatformLayer.h"
 #endif
@@ -50,7 +50,7 @@
     m_isForWebGL2 = attributes.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2;
 #endif
 #if USE(NICOSIA)
-    m_nicosiaLayer = makeUnique<Nicosia::GCGLANGLELayer>(*this);
+    m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this);
 #else
     m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this);
 #endif
@@ -144,7 +144,7 @@
 PlatformGraphicsContextGLDisplay GraphicsContextGLANGLE::platformDisplay() const
 {
 #if USE(NICOSIA)
-    return m_nicosiaLayer->platformDisplay();
+    return m_nicosiaPipe->platformDisplay();
 #else
     return m_texmapLayer->platformDisplay();
 #endif
@@ -153,7 +153,7 @@
 PlatformGraphicsContextGLConfig GraphicsContextGLANGLE::platformConfig() const
 {
 #if USE(NICOSIA)
-    return m_nicosiaLayer->platformConfig();
+    return m_nicosiaPipe->platformConfig();
 #else
     return m_texmapLayer->platformConfig();
 #endif
@@ -162,7 +162,7 @@
 bool GraphicsContextGLANGLE::makeContextCurrent()
 {
 #if USE(NICOSIA)
-    return m_nicosiaLayer->makeContextCurrent();
+    return m_nicosiaPipe->makeContextCurrent();
 #else
     return m_texmapLayer->makeContextCurrent();
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to