Title: [252717] trunk
Revision
252717
Author
[email protected]
Date
2019-11-20 15:59:11 -0800 (Wed, 20 Nov 2019)

Log Message

[GTK] Add ANGLE backend to GTK port
https://bugs.webkit.org/show_bug.cgi?id=199060

Reviewed by Žan Doberšek.

.:

This change brings ANGLE support for WebGL to GTK port. USE_ANGLE_WEBGL
is newly defined in OptionGTK.cmake, and turns on the USE_ANGLE_EGL flag.

* Source/cmake/OptionsGTK.cmake: USE_ANGLE_WEBGL added.

Source/ThirdParty/ANGLE:

* CMakeLists.txt: When USE_ANGLE_WEBGL is enabled, necessary glesv2 entry points headers
  are installed in the derived source directory. And then adjust-angle-include-path.sh is applied
  to change include paths in the entry points header files.
* GLESv2.cmake: libglesv2_entry_points_headers is newly defined, which is a gathering of
  entry point headers of libGLESv2.
* PlatformGTK.cmake: In this file, we append gl and glx related angle code as a build target.
  Since we want gl context and gles context simultaneously, we remove gl prototype calls
  from the generated libGLESv2 library. Instead, we invoke egl and gl calls of ANGLE
  via their non-prototype function names.
* adjust-angle-include-paths.sh: sed is slightly different in unix and linux systems.
  In particular, its inplace option needs to be changed for better compatibility on linux.
* include/CMakeLists.txt: ANGLE_WEBGL_HEADERS is newly defined. It gathers header files of ANGLE
  for WebGL support.

Source/WebCore:

This change aims to bring ANGLE support for WebGL to GTK port. The port
wants to have a gl context for texture mapper and a gles/egl context for webgl
simultaneously, we adopt the readPixel-copyToTexture approach for now because
sharing textures between the two different contextes is not a feasible direction.
Also, to avoid conflicts between gl and gles calls, we use non-prototype functions
of ANGLE for WebGL context (i.e., GraphicsContext3D). Although many combinations
of graphic configurations exist, only default configuration (Nicosia layers
running on ANGLE + GLX is supported. Other combinations like ANGLE + GLES or WPE
will be covered by following patches.

No new tests since no functionality changed.

* Headers.cmake:
* PlatformGTK.cmake:
* SourcesGTK.txt:
* platform/TextureMapper.cmake:
* platform/graphics/ANGLEWebKitBridge.h:
* platform/graphics/GLContext.cpp:
* platform/graphics/GLContext.h:
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/OpenGLShims.cpp:
(WebCore::initializeOpenGLShims):
* platform/graphics/OpenGLShims.h:
* platform/graphics/PlatformDisplay.cpp:
* platform/graphics/angle/GraphicsContext3DANGLE.cpp:
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::prepareTexture):
* platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp: Added.
(Nicosia::GC3DANGLELayer::ANGLEContext::errorString):
(Nicosia::GC3DANGLELayer::ANGLEContext::lastErrorString):
(Nicosia::GC3DANGLELayer::ANGLEContext::createContext):
(Nicosia::GC3DANGLELayer::ANGLEContext::ANGLEContext):
(Nicosia::GC3DANGLELayer::ANGLEContext::~ANGLEContext):
(Nicosia::GC3DANGLELayer::ANGLEContext::makeContextCurrent):
(Nicosia::GC3DANGLELayer::ANGLEContext::platformContext):
(Nicosia::GC3DANGLELayer::GC3DANGLELayer):
(Nicosia::GC3DANGLELayer::~GC3DANGLELayer):
(Nicosia::GC3DANGLELayer::makeContextCurrent):
(Nicosia::GC3DANGLELayer::platformContext):
* platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h: Copied from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h.
* platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp:
(Nicosia::GC3DLayer::GC3DLayer):
(Nicosia::GC3DLayer::swapBuffersIfNeeded):
* platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h:
* platform/graphics/texmap/BitmapTextureGL.cpp:
(WebCore::BitmapTextureGL::setPendingContents):
(WebCore::BitmapTextureGL::updatePendingContents):
* platform/graphics/texmap/BitmapTextureGL.h:
* platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp:
(WebCore::GraphicsContext3D::create):
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::~GraphicsContext3D):
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
(WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
(WebCore::TextureMapperPlatformLayerProxy::pushNextBuffer):

Source/WebKit:

* UIProcess/API/glib/WebKitProtocolHandler.cpp: Extention3DANGLE is used instead
  where ANGLE for WebGL is enabled.
* UIProcess/gtk/AcceleratedBackingStoreWayland.cpp: Append gl extensions for ANGLE.
(WebKit::AcceleratedBackingStoreWayland::checkRequirements):

Source/WTF:

The GTK port uses TEXTURE_MAPPER that has a gl context for accelerated rendering,
and ANGLE has an egl context for WebGL. We want to make both live together
so an exception is made where TEXTURE_MAPPER is enabled.

* wtf/Platform.h:

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (252716 => 252717)


--- trunk/ChangeLog	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/ChangeLog	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1,3 +1,15 @@
+2019-11-20  ChangSeok Oh  <[email protected]>
+
+        [GTK] Add ANGLE backend to GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=199060
+
+        Reviewed by Žan Doberšek.
+
+        This change brings ANGLE support for WebGL to GTK port. USE_ANGLE_WEBGL
+        is newly defined in OptionGTK.cmake, and turns on the USE_ANGLE_EGL flag.
+
+        * Source/cmake/OptionsGTK.cmake: USE_ANGLE_WEBGL added.
+
 2019-11-19  Devin Rousso  <[email protected]>
 
         Web Inspector: DOM.highlightSelector should work for "div, div::before"

Modified: trunk/Source/ThirdParty/ANGLE/CMakeLists.txt (252716 => 252717)


--- trunk/Source/ThirdParty/ANGLE/CMakeLists.txt	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/ThirdParty/ANGLE/CMakeLists.txt	2019-11-20 23:59:11 UTC (rev 252717)
@@ -136,6 +136,27 @@
     )
 endif ()
 
+if (USE_ANGLE_WEBGL)
+    WEBKIT_COPY_FILES(LibGLESv2EntryPointsHeaders
+        DESTINATION ${ANGLE_FRAMEWORK_HEADERS_DIR}/ANGLE
+        FILES ${libglesv2_entry_points_headers}
+        FLATTENED
+    )
+
+    add_custom_command(
+        OUTPUT ${ANGLE_FRAMEWORK_HEADERS_DIR}/ANGLE/angle.timestamp
+        DEPENDS LibGLESv2EntryPointsHeaders ANGLEWebGLHeaders
+        COMMAND BUILT_PRODUCTS_DIR=${ANGLE_FRAMEWORK_HEADERS_DIR}
+            PUBLIC_HEADERS_FOLDER_PATH=ANGLE
+            ${CMAKE_CURRENT_SOURCE_DIR}/adjust-angle-include-paths.sh
+        VERBATIM
+    )
+    add_custom_target(ANGLE-webgl-headers
+        DEPENDS ${ANGLE_FRAMEWORK_HEADERS_DIR}/ANGLE/angle.timestamp
+    )
+    add_dependencies(ANGLEFramework ANGLE-webgl-headers)
+endif ()
+
 if (COMPILER_IS_GCC_OR_CLANG)
     WEBKIT_ADD_TARGET_CXX_FLAGS(ANGLE -Wno-cast-align
                                       -Wno-suggest-attribute=format

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (252716 => 252717)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1,3 +1,24 @@
+2019-11-20  ChangSeok Oh  <[email protected]>
+
+        [GTK] Add ANGLE backend to GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=199060
+
+        Reviewed by Žan Doberšek.
+
+        * CMakeLists.txt: When USE_ANGLE_WEBGL is enabled, necessary glesv2 entry points headers
+          are installed in the derived source directory. And then adjust-angle-include-path.sh is applied
+          to change include paths in the entry points header files.
+        * GLESv2.cmake: libglesv2_entry_points_headers is newly defined, which is a gathering of
+          entry point headers of libGLESv2.
+        * PlatformGTK.cmake: In this file, we append gl and glx related angle code as a build target.
+          Since we want gl context and gles context simultaneously, we remove gl prototype calls
+          from the generated libGLESv2 library. Instead, we invoke egl and gl calls of ANGLE
+          via their non-prototype function names.
+        * adjust-angle-include-paths.sh: sed is slightly different in unix and linux systems.
+          In particular, its inplace option needs to be changed for better compatibility on linux.
+        * include/CMakeLists.txt: ANGLE_WEBGL_HEADERS is newly defined. It gathers header files of ANGLE
+          for WebGL support.
+
 2019-11-08  Dean Jackson  <[email protected]>
 
         Add ANGLE backend for iOS device

Modified: trunk/Source/ThirdParty/ANGLE/GLESv2.cmake (252716 => 252717)


--- trunk/Source/ThirdParty/ANGLE/GLESv2.cmake	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/ThirdParty/ANGLE/GLESv2.cmake	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1101,6 +1101,13 @@
     src/libGLESv2/resource.h
 )
 
+set(libglesv2_entry_points_headers
+    src/libGLESv2/entry_points_egl.h
+    src/libGLESv2/entry_points_gles_2_0_autogen.h
+    src/libGLESv2/entry_points_gles_3_0_autogen.h
+    src/libGLESv2/entry_points_gles_ext_autogen.h
+)
+
 set(libglesv1_cm_sources
     src/libGLESv1_CM/libGLESv1_CM.cpp
     src/libGLESv1_CM/libGLESv1_CM.def

Modified: trunk/Source/ThirdParty/ANGLE/PlatformGTK.cmake (252716 => 252717)


--- trunk/Source/ThirdParty/ANGLE/PlatformGTK.cmake	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/ThirdParty/ANGLE/PlatformGTK.cmake	2019-11-20 23:59:11 UTC (rev 252717)
@@ -13,3 +13,27 @@
     # Allow building ANGLE on platforms which may not provide X11 headers.
     list(APPEND ANGLE_DEFINITIONS USE_SYSTEM_EGL)
 endif ()
+
+if (USE_ANGLE_EGL)
+    list(APPEND ANGLE_SOURCES
+        ${angle_system_utils_sources_linux}
+        ${angle_system_utils_sources_posix}
+        ${libangle_gl_sources}
+        ${libangle_gl_glx_sources}
+    )
+
+    list(APPEND ANGLE_DEFINITIONS
+        ANGLE_ENABLE_OPENGL
+        ANGLE_USE_X11
+    )
+
+    list(APPEND ANGLEGLESv2_LIBRARIES
+        dl
+        pthread
+        X11
+    )
+
+    string(REPLACE src/libGLESv2/libGLESv2_autogen.cpp "" libglesv2_sources "${libglesv2_sources}")
+    string(REPLACE src/libEGL/libEGL.cpp "" libegl_sources "${libegl_sources}")
+endif ()
+

Modified: trunk/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh (252716 => 252717)


--- trunk/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh	2019-11-20 23:59:11 UTC (rev 252717)
@@ -27,6 +27,12 @@
     output_dir=$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH
 fi
 
+if [ $(uname) == "Linux" ]; then
+    inplace_opt="-i"
+else
+    inplace_opt="-i ''"
+fi
+
 for i in $output_dir/*.h ; do
     if [ ! -f $output_dir/angle.timestamp ] || [ $i -nt $output_dir/angle.timestamp ] ; then
         sed -e '
@@ -37,7 +43,7 @@
 s/^#include [<"]KHR\/\(.*\)[>"]/#include <ANGLE\/\1>/
 s/^#include [<"]export.h[>"]/#include <ANGLE\/export.h>/
 s/^#include "\(eglext_angle\|gl2ext_angle\|ShaderVars\).h"/#include <ANGLE\/\1.h>/
-' -i "" $i
+' $inplace_opt $i
         echo Postprocessed ANGLE header3 $i
     fi
 done

Modified: trunk/Source/ThirdParty/ANGLE/include/CMakeLists.txt (252716 => 252717)


--- trunk/Source/ThirdParty/ANGLE/include/CMakeLists.txt	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/ThirdParty/ANGLE/include/CMakeLists.txt	2019-11-20 23:59:11 UTC (rev 252717)
@@ -49,6 +49,23 @@
     )
 endif ()
 
+if (USE_ANGLE_WEBGL)
+    set(ANGLE_WEBGL_HEADERS
+        export.h
+        ${khr_headers}
+        ${egl_headers}
+        ${gles_headers}
+        ${gles2_headers}
+        ${gles3_headers}
+    )
+
+    WEBKIT_COPY_FILES(ANGLEWebGLHeaders
+        DESTINATION ${ANGLE_FRAMEWORK_HEADERS_DIR}/ANGLE
+        FILES ${ANGLE_WEBGL_HEADERS}
+        FLATTENED
+    )
+endif ()
+
 # Cocoa expects headers in an ANGLE directory
 WEBKIT_COPY_FILES(GLSLANGHeaders
     DESTINATION ${ANGLE_FRAMEWORK_HEADERS_DIR}/ANGLE

Modified: trunk/Source/WTF/ChangeLog (252716 => 252717)


--- trunk/Source/WTF/ChangeLog	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WTF/ChangeLog	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1,3 +1,16 @@
+2019-11-20  ChangSeok Oh  <[email protected]>
+
+        [GTK] Add ANGLE backend to GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=199060
+
+        Reviewed by Žan Doberšek.
+
+        The GTK port uses TEXTURE_MAPPER that has a gl context for accelerated rendering,
+        and ANGLE has an egl context for WebGL. We want to make both live together
+        so an exception is made where TEXTURE_MAPPER is enabled.
+
+        * wtf/Platform.h:
+
 2019-11-20  Fujii Hironori  <[email protected]>
 
         [Win] Implement WTF::ThreadSpecific in WTF::Thread

Modified: trunk/Source/WTF/wtf/Platform.h (252716 => 252717)


--- trunk/Source/WTF/wtf/Platform.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WTF/wtf/Platform.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1146,7 +1146,7 @@
 #define USE_ANGLE 0
 #endif
 
-#if (USE_ANGLE && (USE_OPENGL || USE_OPENGL_ES || (defined(USE_EGL) && USE_EGL)))
+#if (USE_ANGLE && (USE_OPENGL || USE_OPENGL_ES || (defined(USE_EGL) && USE_EGL))) && !USE(TEXTURE_MAPPER)
 #error USE_ANGLE is incompatible with USE_OPENGL, USE_OPENGL_ES and USE_EGL
 #endif
 #endif

Modified: trunk/Source/WebCore/ChangeLog (252716 => 252717)


--- trunk/Source/WebCore/ChangeLog	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/ChangeLog	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1,3 +1,67 @@
+2019-11-20  ChangSeok Oh  <[email protected]>
+
+        [GTK] Add ANGLE backend to GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=199060
+
+        Reviewed by Žan Doberšek.
+
+        This change aims to bring ANGLE support for WebGL to GTK port. The port
+        wants to have a gl context for texture mapper and a gles/egl context for webgl
+        simultaneously, we adopt the readPixel-copyToTexture approach for now because
+        sharing textures between the two different contextes is not a feasible direction.
+        Also, to avoid conflicts between gl and gles calls, we use non-prototype functions
+        of ANGLE for WebGL context (i.e., GraphicsContext3D). Although many combinations
+        of graphic configurations exist, only default configuration (Nicosia layers
+        running on ANGLE + GLX is supported. Other combinations like ANGLE + GLES or WPE
+        will be covered by following patches.
+
+        No new tests since no functionality changed.
+
+        * Headers.cmake:
+        * PlatformGTK.cmake:
+        * SourcesGTK.txt:
+        * platform/TextureMapper.cmake:
+        * platform/graphics/ANGLEWebKitBridge.h:
+        * platform/graphics/GLContext.cpp:
+        * platform/graphics/GLContext.h:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/OpenGLShims.cpp:
+        (WebCore::initializeOpenGLShims):
+        * platform/graphics/OpenGLShims.h:
+        * platform/graphics/PlatformDisplay.cpp:
+        * platform/graphics/angle/GraphicsContext3DANGLE.cpp:
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        (WebCore::GraphicsContext3D::prepareTexture):
+        * platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp: Added.
+        (Nicosia::GC3DANGLELayer::ANGLEContext::errorString):
+        (Nicosia::GC3DANGLELayer::ANGLEContext::lastErrorString):
+        (Nicosia::GC3DANGLELayer::ANGLEContext::createContext):
+        (Nicosia::GC3DANGLELayer::ANGLEContext::ANGLEContext):
+        (Nicosia::GC3DANGLELayer::ANGLEContext::~ANGLEContext):
+        (Nicosia::GC3DANGLELayer::ANGLEContext::makeContextCurrent):
+        (Nicosia::GC3DANGLELayer::ANGLEContext::platformContext):
+        (Nicosia::GC3DANGLELayer::GC3DANGLELayer):
+        (Nicosia::GC3DANGLELayer::~GC3DANGLELayer):
+        (Nicosia::GC3DANGLELayer::makeContextCurrent):
+        (Nicosia::GC3DANGLELayer::platformContext):
+        * platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h: Copied from Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h.
+        * platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp:
+        (Nicosia::GC3DLayer::GC3DLayer):
+        (Nicosia::GC3DLayer::swapBuffersIfNeeded):
+        * platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h:
+        * platform/graphics/texmap/BitmapTextureGL.cpp:
+        (WebCore::BitmapTextureGL::setPendingContents):
+        (WebCore::BitmapTextureGL::updatePendingContents):
+        * platform/graphics/texmap/BitmapTextureGL.h:
+        * platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp:
+        (WebCore::GraphicsContext3D::create):
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        (WebCore::GraphicsContext3D::~GraphicsContext3D):
+        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
+        (WebCore::TextureMapperPlatformLayerBuffer::paintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
+        (WebCore::TextureMapperPlatformLayerProxy::pushNextBuffer):
+
 2019-11-20  Zalan Bujtas  <[email protected]>
 
         Flexbox sizing logic triggers full repaint on the flex items.

Modified: trunk/Source/WebCore/Headers.cmake (252716 => 252717)


--- trunk/Source/WebCore/Headers.cmake	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/Headers.cmake	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1121,6 +1121,8 @@
     platform/graphics/WidthCache.h
     platform/graphics/WindRule.h
 
+    platform/graphics/angle/Extensions3DANGLE.h
+
     platform/graphics/cv/ImageTransferSessionVT.h
 
     platform/graphics/filters/FilterOperation.h

Modified: trunk/Source/WebCore/PlatformGTK.cmake (252716 => 252717)


--- trunk/Source/WebCore/PlatformGTK.cmake	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2019-11-20 23:59:11 UTC (rev 252717)
@@ -36,6 +36,12 @@
     "${WEBCORE_DIR}/platform/text/gtk"
 )
 
+if (USE_ANGLE_WEBGL)
+    list(APPEND WebCore_PRIVATE_INCLUDE_DIRECTORIES
+        "${WEBCORE_DIR}/platform/graphics/angle"
+    )
+endif ()
+
 if (USE_WPE_RENDERER)
     list(APPEND WebCore_INCLUDE_DIRECTORIES
         "${WEBCORE_DIR}/platform/graphics/libwpe"
@@ -117,20 +123,38 @@
     )
 endif ()
 
-if (USE_OPENGL_ES)
+if (USE_OPENGL)
     list(APPEND WebCore_SOURCES
-        platform/graphics/opengl/Extensions3DOpenGLES.cpp
-        platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
+        platform/graphics/OpenGLShims.cpp
     )
 endif ()
 
-if (USE_OPENGL)
+if (USE_ANGLE_WEBGL)
     list(APPEND WebCore_SOURCES
-        platform/graphics/OpenGLShims.cpp
+        platform/graphics/angle/Extensions3DANGLE.cpp
+        platform/graphics/angle/GraphicsContext3DANGLE.cpp
+        platform/graphics/angle/TemporaryANGLESetting.cpp
+    )
+else ()
+    list(APPEND WebCore_SOURCES
+        platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
+        platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
+        platform/graphics/opengl/TemporaryOpenGLSetting.cpp
+    )
 
-        platform/graphics/opengl/Extensions3DOpenGL.cpp
-        platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
-    )
+    if (USE_OPENGL_ES)
+        list(APPEND WebCore_SOURCES
+            platform/graphics/opengl/Extensions3DOpenGLES.cpp
+            platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
+        )
+    endif ()
+
+    if (USE_OPENGL)
+        list(APPEND WebCore_SOURCES
+            platform/graphics/opengl/Extensions3DOpenGL.cpp
+            platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
+        )
+    endif ()
 endif ()
 
 if (ENABLE_WAYLAND_TARGET)

Modified: trunk/Source/WebCore/SourcesGTK.txt (252716 => 252717)


--- trunk/Source/WebCore/SourcesGTK.txt	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/SourcesGTK.txt	2019-11-20 23:59:11 UTC (rev 252717)
@@ -92,10 +92,6 @@
 
 platform/graphics/libwpe/PlatformDisplayLibWPE.cpp
 
-platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
-platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
-platform/graphics/opengl/TemporaryOpenGLSetting.cpp
-
 platform/graphics/opentype/OpenTypeVerticalData.cpp
 
 platform/graphics/wayland/PlatformDisplayWayland.cpp

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (252716 => 252717)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2019-11-20 23:59:11 UTC (rev 252717)
@@ -115,3 +115,9 @@
         platform/graphics/texmap/TextureMapperTiledBackingStore.cpp
     )
 endif ()
+
+if (USE_ANGLE_WEBGL)
+    list(APPEND WebCore_SOURCES
+        platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp
+    )
+endif ()

Modified: trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -36,14 +36,14 @@
 #include <ANGLE/ShaderLang.h>
 #include <wtf/text/WTFString.h>
 
-#if PLATFORM(COCOA)
+#if USE(ANGLE)
+#include <ANGLE/gl2.h>
 
+#elif PLATFORM(COCOA)
 #if USE(OPENGL_ES)
 #import <OpenGLES/ES2/glext.h>
 #elif USE(OPENGL)
 #include <OpenGL/gl.h>
-#elif USE(ANGLE)
-#include <ANGLE/gl2.h>
 #else
 #error Unsupported configuration
 #endif

Modified: trunk/Source/WebCore/platform/graphics/GLContext.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/GLContext.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/GLContext.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -26,12 +26,6 @@
 #include "GLContextEGL.h"
 #endif
 
-#if USE(LIBEPOXY)
-#include <epoxy/gl.h>
-#elif USE(OPENGL_ES)
-#include <GLES2/gl2.h>
-#endif
-
 #if USE(GLX)
 #include "GLContextGLX.h"
 #include "OpenGLShims.h"

Modified: trunk/Source/WebCore/platform/graphics/GLContext.h (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/GLContext.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/GLContext.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -20,11 +20,16 @@
 #ifndef GLContext_h
 #define GLContext_h
 
-#include "ANGLEWebKitBridge.h"
 #include "IntSize.h"
 #include "PlatformDisplay.h"
 #include <wtf/Noncopyable.h>
 
+#if USE(LIBEPOXY)
+#include <epoxy/gl.h>
+#elif USE(OPENGL_ES)
+#include <GLES2/gl2.h>
+#endif
+
 #if USE(EGL) && !PLATFORM(GTK)
 #if PLATFORM(WPE)
 // FIXME: For now default to the GBM EGL platform, but this should really be

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -101,12 +101,12 @@
 
 namespace WebCore {
 class Extensions3D;
-#if !PLATFORM(COCOA) && USE(OPENGL_ES)
+#if USE(ANGLE)
+class Extensions3DANGLE;
+#elif !PLATFORM(COCOA) && USE(OPENGL_ES)
 class Extensions3DOpenGLES;
 #elif USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES))
 class Extensions3DOpenGL;
-#elif USE(ANGLE)
-class Extensions3DANGLE;
 #endif
 class HostWindow;
 class Image;
@@ -1456,7 +1456,10 @@
     std::unique_ptr<ShaderNameHash> nameHashMapForShaders;
 #endif // !USE(ANGLE)
 
-#if !PLATFORM(COCOA) && USE(OPENGL_ES)
+#if USE(ANGLE)
+    friend class Extensions3DANGLE;
+    std::unique_ptr<Extensions3DANGLE> m_extensions;
+#elif !PLATFORM(COCOA) && USE(OPENGL_ES)
     friend class Extensions3DOpenGLES;
     friend class Extensions3DOpenGLCommon;
     std::unique_ptr<Extensions3DOpenGLES> m_extensions;
@@ -1464,9 +1467,6 @@
     friend class Extensions3DOpenGL;
     friend class Extensions3DOpenGLCommon;
     std::unique_ptr<Extensions3DOpenGL> m_extensions;
-#elif USE(ANGLE)
-    friend class Extensions3DANGLE;
-    std::unique_ptr<Extensions3DANGLE> m_extensions;
 #endif
 
     GraphicsContext3DAttributes m_attrs;
@@ -1492,7 +1492,7 @@
     bool m_layerComposited { false };
     GC3Duint m_internalColorFormat { 0 };
 
-#if USE(ANGLE)
+#if USE(ANGLE) && PLATFORM(COCOA)
     PlatformGraphicsContext3DSurface m_pbuffer;
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -162,6 +162,7 @@
     ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderInfoLog, success);
     ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderiv, success);
     ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderSource, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetString, success);
     // glGetStringi is only available on OpenGL or GLES versions >= 3.0.
     // Add it with _EXT so it doesn't cause an initialization failure on lower versions.
     ASSIGN_FUNCTION_TABLE_ENTRY_EXT(glGetStringi);

Modified: trunk/Source/WebCore/platform/graphics/OpenGLShims.h (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/OpenGLShims.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/OpenGLShims.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -98,6 +98,7 @@
 typedef void (GLAPIENTRY *glGetShaderInfoLogType) (GLuint, GLsizei, GLsizei*, char*);
 typedef void (GLAPIENTRY *glGetShaderivType) (GLuint, GLenum, GLint*);
 typedef void (GLAPIENTRY *glGetShaderSourceType) (GLuint, GLsizei, GLsizei*, char*);
+typedef const GLubyte* (GLAPIENTRY *glGetStringType) (GLenum);
 typedef const GLubyte* (GLAPIENTRY *glGetStringiType) (GLenum, GLuint);
 typedef GLint (GLAPIENTRY *glGetUniformLocationType) (GLuint, const char*);
 typedef void (GLAPIENTRY *glGetUniformfvType) (GLuint, GLint, GLfloat*);
@@ -205,6 +206,7 @@
     FUNCTION_TABLE_ENTRY(glGetShaderInfoLog);
     FUNCTION_TABLE_ENTRY(glGetShaderiv);
     FUNCTION_TABLE_ENTRY(glGetShaderSource);
+    FUNCTION_TABLE_ENTRY(glGetString);
     FUNCTION_TABLE_ENTRY(glGetStringi);
     FUNCTION_TABLE_ENTRY(glGetUniformfv);
     FUNCTION_TABLE_ENTRY(glGetUniformiv);
@@ -333,6 +335,7 @@
 #define glGetShaderInfoLog                     LOOKUP_GL_FUNCTION(glGetShaderInfoLog)
 #define glGetShaderiv                          LOOKUP_GL_FUNCTION(glGetShaderiv)
 #define glGetShaderSource                      LOOKUP_GL_FUNCTION(glGetShaderSource)
+#define glGetString                            LOOKUP_GL_FUNCTION(glGetString)
 #define glGetStringi                           LOOKUP_GL_FUNCTION(glGetStringi)
 #define glGetUniformfv                         LOOKUP_GL_FUNCTION(glGetUniformfv)
 #define glGetUniformiv                         LOOKUP_GL_FUNCTION(glGetUniformiv)

Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -52,7 +52,10 @@
 
 #if PLATFORM(GTK) && PLATFORM(X11)
 #include <gdk/gdkx.h>
+#if defined(None)
+#undef None
 #endif
+#endif
 
 #if PLATFORM(GTK) && PLATFORM(WAYLAND)
 #include <gdk/gdkwayland.h>

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -69,6 +69,11 @@
 // would need more work to be included from WebCore.
 #define GL_MAX_SAMPLES_EXT 0x8D57
 
+#if USE(COORDINATED_GRAPHICS) && USE(TEXTURE_MAPPER)
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#endif
+
 namespace WebCore {
 
 static const char* packedDepthStencilExtensionName = "GL_OES_packed_depth_stencil";
@@ -191,6 +196,18 @@
     allocateIOSurfaceBackingStore(IntSize(width, height));
     updateFramebufferTextureBackingStoreFromLayer();
     gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ANGLE, m_texture, 0);
+#elif PLATFORM(GTK)
+    gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_texture);
+    gl::TexImage2D(GL_TEXTURE_RECTANGLE_ANGLE, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+    gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ANGLE, m_texture, 0);
+    if (m_compositorTexture) {
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_compositorTexture);
+        gl::TexImage2D(GL_TEXTURE_RECTANGLE_ANGLE, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_intermediateTexture);
+        gl::TexImage2D(GL_TEXTURE_RECTANGLE_ANGLE, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0);
+    }
 #else
 #error FIXME: Port to non-Cocoa platforms.
 #endif // PLATFORM(COCOA)
@@ -476,7 +493,20 @@
     if (m_attrs.antialias)
         resolveMultisamplingIfNecessary();
 
+#if USE(COORDINATED_GRAPHICS)
+    std::swap(m_texture, m_compositorTexture);
+    std::swap(m_texture, m_intermediateTexture);
+    gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+    gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ANGLE, m_texture, 0);
     gl::Flush();
+
+    if (m_state.boundFBO != m_fbo)
+        gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);
+    else
+        gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+#else
+    gl::Flush();
+#endif
 }
 
 void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize)

Added: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp (0 => 252717)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -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 "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;
+}
+
+PlatformGraphicsContext3D GC3DANGLELayer::ANGLEContext::platformContext()
+{
+    return m_context;
+}
+
+GC3DANGLELayer::GC3DANGLELayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle)
+    : GC3DLayer(context)
+{
+    switch (renderStyle) {
+    case GraphicsContext3D::RenderOffscreen:
+        m_angleContext = ANGLEContext::createContext();
+        break;
+    case GraphicsContext3D::RenderDirectlyToHostWindow:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+GC3DANGLELayer::~GC3DANGLELayer()
+{
+}
+
+bool GC3DANGLELayer::makeContextCurrent()
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->makeContextCurrent();
+
+}
+
+PlatformGraphicsContext3D GC3DANGLELayer::platformContext()
+{
+    ASSERT(m_angleContext);
+    return m_angleContext->platformContext();
+}
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Copied: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h (from rev 252716, trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h) (0 => 252717)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -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 "GraphicsContext3D.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_3D)
+        PlatformGraphicsContext3D platformContext();
+#endif
+
+    private:
+        ANGLEContext(EGLDisplay, EGLContext, EGLSurface);
+
+        EGLDisplay m_display { nullptr };
+        EGLContext m_context { nullptr };
+        EGLSurface m_surface { nullptr };
+    };
+
+    GC3DANGLELayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::RenderStyle);
+    virtual ~GC3DANGLELayer();
+
+    bool makeContextCurrent() override;
+    PlatformGraphicsContext3D platformContext() override;
+
+private:
+    std::unique_ptr<ANGLEContext> m_angleContext;
+};
+
+} // namespace Nicosia
+
+#endif // USE(NICOSIA) && USE(TEXTURE_MAPPER)

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -37,6 +37,10 @@
 #include "TextureMapperPlatformLayerProxy.h"
 #endif
 
+#if USE(ANGLE)
+#include "ImageBuffer.h"
+#endif
+
 #include "GLContext.h"
 
 namespace Nicosia {
@@ -43,6 +47,12 @@
 
 using namespace WebCore;
 
+GC3DLayer::GC3DLayer(GraphicsContext3D& context)
+    : m_context(context)
+    , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
+{
+}
+
 GC3DLayer::GC3DLayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle)
     : m_context(context)
     , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
@@ -82,13 +92,38 @@
 
     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);
+    TextureMapperGL::Flags flags = m_context.m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0;
+#if USE(ANGLE)
+    std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(textureSize, 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(), 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();

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -43,12 +43,14 @@
 class GC3DLayer : public ContentLayerTextureMapperImpl::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
+    explicit GC3DLayer(WebCore::GraphicsContext3D&);
     GC3DLayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::RenderStyle);
+
     virtual ~GC3DLayer();
 
     ContentLayer& contentLayer() const { return m_contentLayer; }
-    bool makeContextCurrent();
-    PlatformGraphicsContext3D platformContext();
+    virtual bool makeContextCurrent();
+    virtual PlatformGraphicsContext3D platformContext();
 
     void swapBuffersIfNeeded() override;
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -26,7 +26,6 @@
 
 #include "Extensions3D.h"
 #include "FilterOperations.h"
-#include "Image.h"
 #include "LengthFunctions.h"
 #include "NativeImage.h"
 #include "NotImplemented.h"
@@ -169,6 +168,25 @@
     updateContents(imageData, targetRect, offset, bytesPerLine);
 }
 
+#if USE(ANGLE)
+void BitmapTextureGL::setPendingContents(RefPtr<Image>&& image)
+{
+    m_pendingContents = image;
+}
+
+void BitmapTextureGL::updatePendingContents(const IntRect& targetRect, const IntPoint& offset)
+{
+    if (!m_pendingContents)
+        return;
+
+    if (!isValid()) {
+        IntSize textureSize(m_pendingContents->size());
+        reset(textureSize);
+    }
+    updateContents(m_pendingContents.get(), targetRect, offset);
+}
+#endif
+
 static unsigned getPassesRequiredForFilter(FilterOperation::OperationType type)
 {
     switch (type) {

Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h	2019-11-20 23:59:11 UTC (rev 252717)
@@ -26,6 +26,7 @@
 #include "BitmapTexture.h"
 #include "ClipStack.h"
 #include "FilterOperation.h"
+#include "Image.h"
 #include "IntSize.h"
 #include "TextureMapperContextAttributes.h"
 #include "TextureMapperGL.h"
@@ -77,6 +78,10 @@
     GLint internalFormat() const { return m_internalFormat; }
 
     void copyFromExternalTexture(GLuint textureID);
+#if USE(ANGLE)
+    void setPendingContents(RefPtr<Image>&&);
+    void updatePendingContents(const IntRect& targetRect, const IntPoint& offset);
+#endif
 
     TextureMapperGL::Flags colorConvertFlags() const { return m_colorConvertFlags; }
 
@@ -94,6 +99,10 @@
     TextureMapperContextAttributes m_contextAttributes;
     TextureMapperGL::Flags m_colorConvertFlags { TextureMapperGL::NoFlag };
 
+#if USE(ANGLE)
+    RefPtr<Image> m_pendingContents { nullptr };
+#endif
+
     void clearIfNeeded();
     void createFboIfNeeded();
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -37,13 +37,38 @@
 
 #include <ANGLE/ShaderLang.h>
 
-#if USE(LIBEPOXY)
+#if USE(ANGLE)
+#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>
+#if defined(Above)
+#undef Above
+#endif
+#if defined(Below)
+#undef Below
+#endif
+#if defined(None)
+#undef None
+#endif
+#elif USE(LIBEPOXY)
 #include <epoxy/gl.h>
 #elif !USE(OPENGL_ES)
 #include "OpenGLShims.h"
 #endif
 
-#if USE(OPENGL_ES)
+#if USE(ANGLE)
+#include "Extensions3DANGLE.h"
+#elif USE(OPENGL_ES)
 #include "Extensions3DOpenGLES.h"
 #else
 #include "Extensions3DOpenGL.h"
@@ -50,8 +75,12 @@
 #endif
 
 #if USE(NICOSIA)
+#if USE(ANGLE)
+#include "NicosiaGC3DANGLELayer.h"
+#else
 #include "NicosiaGC3DLayer.h"
 #endif
+#endif
 
 namespace WebCore {
 
@@ -71,7 +100,7 @@
     static bool initialized = false;
     static bool success = true;
     if (!initialized) {
-#if !USE(OPENGL_ES) && !USE(LIBEPOXY)
+#if !USE(OPENGL_ES) && !USE(LIBEPOXY) && !USE(ANGLE)
         success = initializeOpenGLShims();
 #endif
         initialized = true;
@@ -101,11 +130,84 @@
     return context;
 }
 
+#if USE(ANGLE)
 GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attributes, HostWindow*, GraphicsContext3D::RenderStyle renderStyle, GraphicsContext3D* sharedContext)
     : m_attrs(attributes)
 {
     ASSERT_UNUSED(sharedContext, !sharedContext);
 #if USE(NICOSIA)
+    m_nicosiaLayer = WTF::makeUnique<Nicosia::GC3DANGLELayer>(*this, renderStyle);
+#else
+    m_texmapLayer = WTF::makeUnique<TextureMapperGC3DPlatformLayer>(*this, renderStyle);
+#endif
+    makeContextCurrent();
+
+
+    validateAttributes();
+
+    if (renderStyle == RenderOffscreen) {
+        // Create a texture to render into.
+        gl::GenTextures(1, &m_texture);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_texture);
+        gl::TexParameterf(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        gl::TexParameterf(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0);
+
+        // Create an FBO.
+        gl::GenFramebuffers(1, &m_fbo);
+        gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+
+#if USE(COORDINATED_GRAPHICS)
+        gl::GenTextures(1, &m_compositorTexture);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_compositorTexture);
+        gl::TexParameterf(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        gl::TexParameterf(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+        gl::GenTextures(1, &m_intermediateTexture);
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_intermediateTexture);
+        gl::TexParameterf(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        gl::TexParameterf(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0);
+#endif
+
+        // Create a multisample FBO.
+        if (m_attrs.antialias) {
+            gl::GenFramebuffers(1, &m_multisampleFBO);
+            gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
+            m_state.boundFBO = m_multisampleFBO;
+            gl::GenRenderbuffers(1, &m_multisampleColorBuffer);
+            if (m_attrs.stencil || m_attrs.depth)
+                gl::GenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+        } else {
+            // Bind canvas FBO.
+            gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+            m_state.boundFBO = m_fbo;
+#if USE(OPENGL_ES)
+            if (m_attrs.depth)
+                gl::GenRenderbuffers(1, &m_depthBuffer);
+            if (m_attrs.stencil)
+                gl::GenRenderbuffers(1, &m_stencilBuffer);
+#endif
+            if (m_attrs.stencil || m_attrs.depth)
+                gl::GenRenderbuffers(1, &m_depthStencilBuffer);
+        }
+    }
+
+    gl::ClearColor(0, 0, 0, 0);
+}
+#else
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attributes, HostWindow*, GraphicsContext3D::RenderStyle renderStyle, GraphicsContext3D* sharedContext)
+    : m_attrs(attributes)
+{
+    ASSERT_UNUSED(sharedContext, !sharedContext);
+#if USE(NICOSIA)
     m_nicosiaLayer = makeUnique<Nicosia::GC3DLayer>(*this, renderStyle);
 #else
     m_texmapLayer = makeUnique<TextureMapperGC3DPlatformLayer>(*this, renderStyle);
@@ -225,11 +327,55 @@
 
     ::glClearColor(0, 0, 0, 0);
 }
+#endif
 
+#if USE(ANGLE)
 GraphicsContext3D::~GraphicsContext3D()
 {
     makeContextCurrent();
     if (m_texture)
+        gl::DeleteTextures(1, &m_texture);
+#if USE(COORDINATED_GRAPHICS)
+    if (m_compositorTexture)
+        gl::DeleteTextures(1, &m_compositorTexture);
+#endif
+
+    if (m_attrs.antialias) {
+        gl::DeleteRenderbuffers(1, &m_multisampleColorBuffer);
+        if (m_attrs.stencil || m_attrs.depth)
+            gl::DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+        gl::DeleteFramebuffers(1, &m_multisampleFBO);
+    } else if (m_attrs.stencil || m_attrs.depth) {
+#if USE(OPENGL_ES)
+        if (m_depthBuffer)
+            glDeleteRenderbuffers(1, &m_depthBuffer);
+
+        if (m_stencilBuffer)
+            glDeleteRenderbuffers(1, &m_stencilBuffer);
+#endif
+        if (m_depthStencilBuffer)
+            gl::DeleteRenderbuffers(1, &m_depthStencilBuffer);
+    }
+    gl::DeleteFramebuffers(1, &m_fbo);
+#if USE(COORDINATED_GRAPHICS)
+    gl::DeleteTextures(1, &m_intermediateTexture);
+#endif
+
+#if USE(CAIRO)
+    if (m_vao)
+        deleteVertexArray(m_vao);
+#endif
+
+    auto* activeContext = activeContexts().takeLast([this](auto* it) {
+        return it == this;
+    });
+    ASSERT_UNUSED(activeContext, !!activeContext);
+}
+#else
+GraphicsContext3D::~GraphicsContext3D()
+{
+    makeContextCurrent();
+    if (m_texture)
         ::glDeleteTextures(1, &m_texture);
 #if USE(COORDINATED_GRAPHICS)
     if (m_compositorTexture)
@@ -262,9 +408,12 @@
         deleteVertexArray(m_vao);
 #endif
 
-    auto* activeContext = activeContexts().takeLast([this](auto* it) { return it == this; });
+    auto* activeContext = activeContexts().takeLast([this](auto* it) {
+        return it == this;
+    });
     ASSERT_UNUSED(activeContext, !!activeContext);
 }
+#endif // USE(ANGLE)
 
 void GraphicsContext3D::setContextLostCallback(std::unique_ptr<ContextLostCallback>)
 {
@@ -319,7 +468,7 @@
 #endif
 }
 
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) && !USE(ANGLE)
 Extensions3D& GraphicsContext3D::getExtensions()
 {
     if (!m_extensions) {

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -97,6 +97,9 @@
     if (m_hasManagedTexture) {
         ASSERT(m_texture);
         BitmapTextureGL* textureGL = static_cast<BitmapTextureGL*>(m_texture.get());
+#if USE(ANGLE)
+        textureGL->updatePendingContents(IntRect(IntPoint(), textureGL->contentSize()), IntPoint());
+#endif
         texmapGL.drawTexture(textureGL->id(), m_extraFlags | textureGL->colorConvertFlags(), textureGL->size(), targetRect, modelViewMatrix, opacity);
         return;
     }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp (252716 => 252717)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -113,6 +113,12 @@
 void TextureMapperPlatformLayerProxy::pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer> newBuffer)
 {
     ASSERT(m_lock.isHeld());
+#if USE(ANGLE)
+    // When the newBuffer overwrites m_pendingBuffer that is not swapped yet,
+    // the layer related to m_pendingBuffer is flickering since its texture is destroyed.
+    if (m_pendingBuffer && m_pendingBuffer->hasManagedTexture())
+        return;
+#endif
     m_pendingBuffer = WTFMove(newBuffer);
     m_wasBufferDropped = false;
 

Modified: trunk/Source/WebKit/ChangeLog (252716 => 252717)


--- trunk/Source/WebKit/ChangeLog	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebKit/ChangeLog	2019-11-20 23:59:11 UTC (rev 252717)
@@ -1,3 +1,15 @@
+2019-11-20  ChangSeok Oh  <[email protected]>
+
+        [GTK] Add ANGLE backend to GTK port
+        https://bugs.webkit.org/show_bug.cgi?id=199060
+
+        Reviewed by Žan Doberšek.
+
+        * UIProcess/API/glib/WebKitProtocolHandler.cpp: Extention3DANGLE is used instead
+          where ANGLE for WebGL is enabled.
+        * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp: Append gl extensions for ANGLE.
+        (WebKit::AcceleratedBackingStoreWayland::checkRequirements):
+
 2019-11-20  Chris Dumez  <[email protected]>
 
         [iOS] Make sure WebContent process does not get suspended while it is holding a process assertion for the UIProcess

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp (252716 => 252717)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -64,6 +64,7 @@
 
 #if USE(GLX)
 #include <GL/glx.h>
+#include <WebCore/OpenGLShims.h>
 #endif
 
 namespace WebKit {

Modified: trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp (252716 => 252717)


--- trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp	2019-11-20 23:59:11 UTC (rev 252717)
@@ -38,7 +38,10 @@
 #include <WebCore/CairoUtilities.h>
 #include <WebCore/GLContext.h>
 
-#if USE(OPENGL_ES)
+#if USE(ANGLE)
+#include <WebCore/Extensions3DANGLE.h>
+#include <WebCore/OpenGLShims.h>
+#elif USE(OPENGL_ES)
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 #include <WebCore/Extensions3DOpenGLES.h>
@@ -78,7 +81,9 @@
         if (!eglContext->makeContextCurrent())
             return false;
 
-#if USE(OPENGL_ES)
+#if USE(ANGLE)
+        std::unique_ptr<Extensions3DANGLE> glExtensions = makeUnique<Extensions3DANGLE>(nullptr, GLContext::current()->version() >= 320);
+#elif USE(OPENGL_ES)
         std::unique_ptr<Extensions3DOpenGLES> glExtensions = makeUnique<Extensions3DOpenGLES>(nullptr,  false);
 #else
         std::unique_ptr<Extensions3DOpenGL> glExtensions = makeUnique<Extensions3DOpenGL>(nullptr, GLContext::current()->version() >= 320);

Modified: trunk/Source/cmake/OptionsGTK.cmake (252716 => 252717)


--- trunk/Source/cmake/OptionsGTK.cmake	2019-11-20 23:52:40 UTC (rev 252716)
+++ trunk/Source/cmake/OptionsGTK.cmake	2019-11-20 23:59:11 UTC (rev 252717)
@@ -90,6 +90,7 @@
 
 # Private options specific to the GTK port. Changing these options is
 # completely unsupported. They are intended for use only by WebKit developers.
+WEBKIT_OPTION_DEFINE(USE_ANGLE_WEBGL "Whether to use ANGLE as WebGL backend." PRIVATE OFF)
 WEBKIT_OPTION_DEFINE(USE_OPENVR "Whether to use OpenVR as WebVR backend." PRIVATE OFF)
 
 # FIXME: Can we use cairo-glesv2 to avoid this conflict?
@@ -100,6 +101,7 @@
 WEBKIT_OPTION_DEPEND(ENABLE_ASYNC_SCROLLING ENABLE_OPENGL)
 WEBKIT_OPTION_DEPEND(ENABLE_GLES2 ENABLE_OPENGL)
 WEBKIT_OPTION_DEPEND(ENABLE_WEBGL ENABLE_OPENGL)
+WEBKIT_OPTION_DEPEND(USE_ANGLE_WEBGL ENABLE_WEBGL)
 WEBKIT_OPTION_DEPEND(USE_WPE_RENDERER ENABLE_OPENGL)
 WEBKIT_OPTION_DEPEND(USE_WPE_RENDERER ENABLE_WAYLAND_TARGET)
 
@@ -306,6 +308,11 @@
     SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
 endif ()
 
+if (USE_ANGLE_WEBGL)
+    SET_AND_EXPOSE_TO_BUILD(USE_ANGLE TRUE)
+    SET_AND_EXPOSE_TO_BUILD(USE_ANGLE_EGL TRUE)
+endif ()
+
 if (ENABLE_SPELLCHECK)
     find_package(Enchant)
     if (NOT PC_ENCHANT_FOUND)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to