Title: [287920] trunk
Revision
287920
Author
cl...@igalia.com
Date
2022-01-12 05:02:19 -0800 (Wed, 12 Jan 2022)

Log Message

[WPE] Enable WebGL ANGLE support
https://bugs.webkit.org/show_bug.cgi?id=235064

Reviewed by Alejandro G. Castro.

.:

Add the USE_ANGLE_WEBGL option for WPE. This is currently incompatible
with WebXR as there isn't an ANGLE GL context code-path there.

* Source/cmake/OptionsWPE.cmake:

Source/ThirdParty/ANGLE:

Enable building on WPE (mostly copying the GTK build file).

* PlatformWPE.cmake:

Source/WebCore:

Enable ANGLE WebGL support when building the WPE port.

* platform/graphics/angle/ANGLEHeaders.h:
* platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp:
(Nicosia::GCGLLayer::swapBuffersIfNeeded):

Modified Paths

Diff

Modified: trunk/ChangeLog (287919 => 287920)


--- trunk/ChangeLog	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/ChangeLog	2022-01-12 13:02:19 UTC (rev 287920)
@@ -1,3 +1,15 @@
+2022-01-12  Chris Lord  <cl...@igalia.com>
+
+        [WPE] Enable WebGL ANGLE support
+        https://bugs.webkit.org/show_bug.cgi?id=235064
+
+        Reviewed by Alejandro G. Castro.
+
+        Add the USE_ANGLE_WEBGL option for WPE. This is currently incompatible
+        with WebXR as there isn't an ANGLE GL context code-path there.
+
+        * Source/cmake/OptionsWPE.cmake:
+
 2022-01-11  Fujii Hironori  <hironori.fu...@sony.com>
 
         Remove Direct2D code (part 2)

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (287919 => 287920)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2022-01-12 13:02:19 UTC (rev 287920)
@@ -1,3 +1,14 @@
+2022-01-12  Chris Lord  <cl...@igalia.com>
+
+        [WPE] Enable WebGL ANGLE support
+        https://bugs.webkit.org/show_bug.cgi?id=235064
+
+        Reviewed by Alejandro G. Castro.
+
+        Enable building on WPE (mostly copying the GTK build file).
+
+        * PlatformWPE.cmake:
+
 2022-01-11  Kyle Piddington  <kpidding...@apple.com>
 
         ANGLE: ASTC-HDR is not available on TVOS

Modified: trunk/Source/ThirdParty/ANGLE/PlatformWPE.cmake (287919 => 287920)


--- trunk/Source/ThirdParty/ANGLE/PlatformWPE.cmake	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/Source/ThirdParty/ANGLE/PlatformWPE.cmake	2022-01-12 13:02:19 UTC (rev 287920)
@@ -1,2 +1,52 @@
-# Allow building ANGLE on platforms that don't provide X11 headers.
-list(APPEND ANGLE_DEFINITIONS USE_SYSTEM_EGL)
+list(APPEND ANGLE_DEFINITIONS ANGLE_PLATFORM_LINUX)
+include(linux.cmake)
+
+if (USE_OPENGL)
+    # Enable GLSL compiler output.
+    list(APPEND ANGLE_DEFINITIONS ANGLE_ENABLE_GLSL)
+endif ()
+
+if (USE_ANGLE_EGL OR USE_ANGLE_WEBGL)
+    list(APPEND ANGLE_SOURCES
+        ${_gl_backend_sources}
+
+        ${angle_system_utils_sources_linux}
+        ${angle_system_utils_sources_posix}
+
+        ${angle_dma_buf_sources}
+
+        ${libangle_gl_egl_dl_sources}
+        ${libangle_gl_egl_sources}
+        ${libangle_gl_sources}
+
+        ${libangle_gpu_info_util_sources}
+        ${libangle_gpu_info_util_linux_sources}
+    )
+
+    list(APPEND ANGLE_DEFINITIONS
+        ANGLE_ENABLE_OPENGL
+        ANGLE_USE_GBM
+        USE_SYSTEM_EGL
+    )
+
+    find_package(LibDRM REQUIRED)
+    find_package(GBM REQUIRED)
+
+    list(APPEND ANGLE_PRIVATE_INCLUDE_DIRECTORIES
+        ${LIBDRM_INCLUDE_DIR}
+        {GBM_INCLUDE_DIR}
+    )
+
+    list(APPEND ANGLEGLESv2_LIBRARIES
+        ${CMAKE_DL_LIBS}
+        ${LIBDRM_LIBRARIES}
+        ${GBM_LIBRARIES}
+        Threads::Threads
+    )
+
+    if (USE_OPENGL)
+        list(APPEND ANGLEGLESv2_LIBRARIES ${OPENGL_LIBRARIES})
+    else ()
+        list(APPEND ANGLEGLESv2_LIBRARIES ${OPENGLES_LIBRARIES})
+    endif ()
+endif ()

Modified: trunk/Source/WebCore/ChangeLog (287919 => 287920)


--- trunk/Source/WebCore/ChangeLog	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/Source/WebCore/ChangeLog	2022-01-12 13:02:19 UTC (rev 287920)
@@ -1,3 +1,16 @@
+2022-01-12  Chris Lord  <cl...@igalia.com>
+
+        [WPE] Enable WebGL ANGLE support
+        https://bugs.webkit.org/show_bug.cgi?id=235064
+
+        Reviewed by Alejandro G. Castro.
+
+        Enable ANGLE WebGL support when building the WPE port.
+
+        * platform/graphics/angle/ANGLEHeaders.h:
+        * platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp:
+        (Nicosia::GCGLLayer::swapBuffersIfNeeded):
+
 2022-01-12  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][a11y] Defer the emission of AddAccessible signal with ATSPI

Modified: trunk/Source/WebCore/platform/graphics/angle/ANGLEHeaders.h (287919 => 287920)


--- trunk/Source/WebCore/platform/graphics/angle/ANGLEHeaders.h	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/Source/WebCore/platform/graphics/angle/ANGLEHeaders.h	2022-01-12 13:02:19 UTC (rev 287920)
@@ -41,6 +41,11 @@
 #define GL_GLEXT_PROTOTYPES 0
 #endif
 
+#if USE(LIBEPOXY)
+#include <epoxy/gl.h>
+typedef uint64_t EGLFrameTokenANGLE;
+#endif
+
 #include <ANGLE/entry_points_egl_autogen.h>
 #include <ANGLE/entry_points_egl_ext_autogen.h>
 #include <ANGLE/entry_points_gles_2_0_autogen.h>

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


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2022-01-12 13:02:19 UTC (rev 287920)
@@ -39,7 +39,10 @@
 
 #if USE(ANGLE)
 #include "ImageBuffer.h"
+#if USE(CAIRO)
+#include <cairo.h>
 #endif
+#endif
 
 #include "GLContext.h"
 
@@ -79,7 +82,6 @@
 
     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)
     RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(textureSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!imageBuffer)
@@ -87,36 +89,49 @@
 
     m_context.paintRenderingResultsToCanvas(*imageBuffer.get());
 #else
-    flags |= TextureMapperGL::ShouldFlipTexture;
+    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, textureSize, flags, imageBuffer = WTFMove(imageBuffer)] () {
-                RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
-                if (!image)
+            [this, imageBuffer = WTFMove(imageBuffer)] () mutable {
+                auto nativeImage = ImageBuffer::sinkIntoNativeImage(WTFMove(imageBuffer));
+                if (!nativeImage)
                     return;
 
-                std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer;
+                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() };
-                layerBuffer = proxy.getAvailableBuffer(textureSize, m_context.m_internalColorFormat);
 
+                std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = proxy.getAvailableBuffer(size, flags);
+
                 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));
+                    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] {
+        proxy.scheduleUpdateOnCompositorThread([proxyOperation] () mutable {
             proxyOperation();
         });
 

Modified: trunk/Source/cmake/OptionsWPE.cmake (287919 => 287920)


--- trunk/Source/cmake/OptionsWPE.cmake	2022-01-12 12:25:27 UTC (rev 287919)
+++ trunk/Source/cmake/OptionsWPE.cmake	2022-01-12 13:02:19 UTC (rev 287920)
@@ -86,7 +86,11 @@
 # Private options specific to the WPE port.
 WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepunch" PRIVATE OFF)
 WEBKIT_OPTION_DEFINE(USE_EXTERNAL_HOLEPUNCH "Whether to enable external holepunch" PRIVATE OFF)
+WEBKIT_OPTION_DEFINE(USE_ANGLE_WEBGL "Whether to use ANGLE as WebGL backend." PRIVATE OFF)
+WEBKIT_OPTION_DEPEND(USE_ANGLE_WEBGL ENABLE_WEBGL)
 
+WEBKIT_OPTION_CONFLICT(USE_ANGLE_WEBGL ENABLE_WEBXR)
+
 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC ON)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PRIVATE ON)
@@ -171,6 +175,10 @@
     endif ()
 endif ()
 
+if (USE_ANGLE_WEBGL)
+    SET_AND_EXPOSE_TO_BUILD(USE_ANGLE TRUE)
+endif ()
+
 if (USE_JPEGXL)
     find_package(JPEGXL)
     if (NOT JPEGXL_FOUND)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to