Diff
Modified: trunk/Source/WebCore/ChangeLog (289417 => 289418)
--- trunk/Source/WebCore/ChangeLog 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/ChangeLog 2022-02-08 20:45:41 UTC (rev 289418)
@@ -1,3 +1,27 @@
+2022-02-08 Chris Lord <[email protected]>
+
+ [GTK][WPE] Fallback path for WebGL rendering with ANGLE is incorrectly scheduling on the compositor thread
+ https://bugs.webkit.org/show_bug.cgi?id=236290
+
+ Reviewed by Alejandro G. Castro.
+
+ Fix the WebGL ANGLE fallback path on nicosia to not incorrectly
+ schedule on the compositor thread.
+
+ No new tests, no change in behaviour.
+
+ * platform/TextureMapper.cmake:
+ * platform/graphics/angle/GraphicsContextGLANGLE.h:
+ * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp.
+ * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h: Renamed from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.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-02-08 Razvan Caliman <[email protected]>
Web Inspector: [Flexbox] Add support for showing/hiding flex container overlays and basic overlay drawing
Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (289417 => 289418)
--- trunk/Source/WebCore/platform/TextureMapper.cmake 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake 2022-02-08 20:45:41 UTC (rev 289418)
@@ -127,7 +127,7 @@
if (USE_ANGLE_WEBGL)
list(APPEND WebCore_SOURCES
- platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp
+ platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp
)
endif ()
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h (289417 => 289418)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h 2022-02-08 20:45:41 UTC (rev 289418)
@@ -42,8 +42,7 @@
#if USE(NICOSIA)
namespace Nicosia {
-class GCGLANGLEPipe;
-class GCGLANGLEPipeSource;
+class GCGLANGLELayer;
class GCGLLayer;
}
@@ -455,7 +454,7 @@
GCGLuint m_intermediateTexture { 0 };
#endif
#if USE(NICOSIA)
- std::unique_ptr<Nicosia::GCGLANGLEPipe> m_nicosiaPipe;
+ std::unique_ptr<Nicosia::GCGLANGLELayer> m_nicosiaLayer;
class EGLImageBacking {
WTF_MAKE_FAST_ALLOCATED;
@@ -490,7 +489,7 @@
friend class ExtensionsGLANGLE;
#if USE(NICOSIA)
- friend class Nicosia::GCGLANGLEPipeSource;
+ friend class Nicosia::GCGLANGLELayer;
friend class Nicosia::GCGLLayer;
#elif USE(TEXTURE_MAPPER)
friend class TextureMapperGCGLPlatformLayer;
Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp (from rev 289417, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp) (0 => 289418)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp 2022-02-08 20:45:41 UTC (rev 289418)
@@ -0,0 +1,268 @@
+/*
+ * 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 "ImageBuffer.h"
+#include "Logging.h"
+#include "TextureMapperGL.h"
+#include "TextureMapperPlatformLayerDmabuf.h"
+#include "TextureMapperPlatformLayerProxy.h"
+
+namespace Nicosia {
+
+using namespace WebCore;
+
+void GCGLANGLELayer::swapBuffersIfNeeded()
+{
+ if (m_context.layerComposited())
+ return;
+
+ m_context.prepareTexture();
+
+ auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(contentLayer().impl()).proxy();
+ auto size = m_context.getInternalFramebufferSize();
+
+ if (m_context.m_compositorTextureBacking) {
+ auto format = m_context.m_compositorTextureBacking->format();
+ auto stride = m_context.m_compositorTextureBacking->stride();
+ auto fd = m_context.m_compositorTextureBacking->fd();
+
+ {
+ Locker locker { proxy.lock() };
+ proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerDmabuf>(size, format, stride, fd));
+ }
+
+ m_context.markLayerComposited();
+ return;
+ }
+
+ // Fallback path, read back texture to main memory
+ RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(size, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+ if (!imageBuffer)
+ return;
+ m_context.paintRenderingResultsToCanvas(*imageBuffer.get());
+
+ auto flags = m_context.contextAttributes().alpha ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag;
+ {
+ Locker locker { proxy.lock() };
+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = proxy.getAvailableBuffer(size, m_context.m_internalColorFormat);
+ if (!layerBuffer) {
+ auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get(), flags, m_context.m_internalColorFormat);
+ layerBuffer = makeUnique<TextureMapperPlatformLayerBuffer>(WTFMove(texture), flags);
+ }
+
+ layerBuffer->textureGL().setPendingContents(ImageBuffer::sinkIntoImage(WTFMove(imageBuffer)));
+ proxy.pushNextBuffer(WTFMove(layerBuffer));
+ }
+ m_context.markLayerComposited();
+}
+
+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)
+ : m_context(context)
+ , m_angleContext(ANGLEContext::createContext())
+ , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
+{
+}
+
+GCGLANGLELayer::~GCGLANGLELayer()
+{
+ downcast<ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient();
+}
+
+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)
Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h (from rev 289417, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h) (0 => 289418)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h 2022-02-08 20:45:41 UTC (rev 289418)
@@ -0,0 +1,98 @@
+/*
+ * 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 "NicosiaContentLayerTextureMapperImpl.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 ContentLayerTextureMapperImpl::Client {
+ 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();
+ PlatformGraphicsContextGL platformContext() const;
+ PlatformGraphicsContextGLDisplay platformDisplay() const;
+ PlatformGraphicsContextGLConfig platformConfig() const;
+
+ ContentLayer& contentLayer() const { return m_contentLayer; }
+ void swapBuffersIfNeeded() final;
+
+private:
+ WebCore::GraphicsContextGLANGLE& m_context;
+ std::unique_ptr<ANGLEContext> m_angleContext;
+ Ref<ContentLayer> m_contentLayer;
+};
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)
Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp (289417 => 289418)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.cpp 2022-02-08 20:45:41 UTC (rev 289418)
@@ -1,276 +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 "NicosiaGCGLANGLEPipe.h"
-
-#if USE(NICOSIA) && USE(TEXTURE_MAPPER)
-
-#include "ANGLEHeaders.h"
-#include "ImageBuffer.h"
-#include "Logging.h"
-#include "TextureMapperGL.h"
-#include "TextureMapperPlatformLayerDmabuf.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();
-
- if (m_context.m_compositorTextureBacking) {
- auto size = m_context.getInternalFramebufferSize();
- auto format = m_context.m_compositorTextureBacking->format();
- auto stride = m_context.m_compositorTextureBacking->stride();
- auto fd = m_context.m_compositorTextureBacking->fd();
-
- auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(platformLayer()->impl()).proxy();
- {
- Locker locker { proxy.lock() };
- proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerDmabuf>(size, format, stride, fd));
- }
-
- m_context.markLayerComposited();
- return;
- }
-
- // Fallback path, read back texture to main memory
- 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)
Deleted: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h (289417 => 289418)
--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLEPipe.h 2022-02-08 20:45:41 UTC (rev 289418)
@@ -1,110 +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 "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/texmap/GraphicsContextGLTextureMapper.cpp (289417 => 289418)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp 2022-02-08 20:45:41 UTC (rev 289418)
@@ -60,7 +60,7 @@
#if USE(NICOSIA)
#if USE(ANGLE)
-#include "NicosiaGCGLANGLEPipe.h"
+#include "NicosiaGCGLANGLELayer.h"
#else
#include "NicosiaGCGLLayer.h"
#endif
@@ -116,11 +116,7 @@
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 (289417 => 289418)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-02-08 20:42:04 UTC (rev 289417)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-02-08 20:45:41 UTC (rev 289418)
@@ -37,7 +37,7 @@
#if USE(NICOSIA)
#include "GBMDevice.h"
-#include "NicosiaGCGLANGLEPipe.h"
+#include "NicosiaGCGLANGLELayer.h"
#include <fcntl.h>
#include <gbm.h>
@@ -54,7 +54,7 @@
m_isForWebGL2 = attributes.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2;
#endif
#if USE(NICOSIA)
- m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this);
+ m_nicosiaLayer = makeUnique<Nicosia::GCGLANGLELayer>(*this);
const auto& gbmDevice = GBMDevice::get();
if (auto* device = gbmDevice.device()) {
@@ -228,7 +228,7 @@
PlatformGraphicsContextGLDisplay GraphicsContextGLANGLE::platformDisplay() const
{
#if USE(NICOSIA)
- return m_nicosiaPipe->platformDisplay();
+ return m_nicosiaLayer->platformDisplay();
#else
return m_texmapLayer->platformDisplay();
#endif
@@ -237,7 +237,7 @@
PlatformGraphicsContextGLConfig GraphicsContextGLANGLE::platformConfig() const
{
#if USE(NICOSIA)
- return m_nicosiaPipe->platformConfig();
+ return m_nicosiaLayer->platformConfig();
#else
return m_texmapLayer->platformConfig();
#endif
@@ -246,7 +246,7 @@
bool GraphicsContextGLANGLE::makeContextCurrent()
{
#if USE(NICOSIA)
- return m_nicosiaPipe->makeContextCurrent();
+ return m_nicosiaLayer->makeContextCurrent();
#else
return m_texmapLayer->makeContextCurrent();
#endif