Title: [270899] trunk
Revision
270899
Author
[email protected]
Date
2020-12-16 12:04:41 -0800 (Wed, 16 Dec 2020)

Log Message

[WinCairo] Enable USE_ANGLE
https://bugs.webkit.org/show_bug.cgi?id=219421

Reviewed by Don Olmstead.

.:

* Source/cmake/OptionsWinCairo.cmake:

Source/ThirdParty/ANGLE:

* CMakeLists.txt: Added entry_points_egl_ext.h to libglesv2_entry_points_headers.

Source/WebCore:

Switch GraphicsContextGLOpenGL implementation from old one
(GraphicsContextGLOpenGLES.cpp) to new one
(GraphicsContextGLANGLE.cpp), which is using ANGLE's internal API
and verification code, for WinCairo port. I will enable WebGL2 for
WinCairo in a follow-up patch.

GL_TEXTURE_RECTANGLE_ANGLE is not available for ANGLE D3D backend.
Use GL_TEXTURE_2D instead.

Add a new class WebCore::ANGLEContext by copying
Nicosia::GCGLANGLELayer::ANGLEContext. It'd be better to merge
them after GTK and WPE will also switch.

* PlatformWin.cmake:
* platform/TextureMapper.cmake:
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLOpenGL::reshapeFBOs):
(WebCore::GraphicsContextGLOpenGL::compileShader):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:
* platform/graphics/texmap/ANGLEContext.cpp: Added.
(WebCore::ANGLEContext::errorString):
(WebCore::ANGLEContext::lastErrorString):
(WebCore::ANGLEContext::createContext):
(WebCore::ANGLEContext::ANGLEContext):
(WebCore::ANGLEContext::~ANGLEContext):
(WebCore::ANGLEContext::makeContextCurrent):
(WebCore::ANGLEContext::platformContext const):
* platform/graphics/texmap/ANGLEContext.h: Added.
* platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
(WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::isGLES2Compliant const):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTarget):
* platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp:
(WebCore::TextureMapperGCGLPlatformLayer::TextureMapperGCGLPlatformLayer):
(WebCore::TextureMapperGCGLPlatformLayer::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h:

LayoutTests:

* platform/wincairo/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (270898 => 270899)


--- trunk/ChangeLog	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/ChangeLog	2020-12-16 20:04:41 UTC (rev 270899)
@@ -1,3 +1,12 @@
+2020-12-16  Fujii Hironori  <[email protected]>
+
+        [WinCairo] Enable USE_ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=219421
+
+        Reviewed by Don Olmstead.
+
+        * Source/cmake/OptionsWinCairo.cmake:
+
 2020-12-13  Don Olmstead  <[email protected]>
 
         [CMake] Version of LibPSL not reported

Modified: trunk/LayoutTests/ChangeLog (270898 => 270899)


--- trunk/LayoutTests/ChangeLog	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/LayoutTests/ChangeLog	2020-12-16 20:04:41 UTC (rev 270899)
@@ -1,3 +1,12 @@
+2020-12-16  Fujii Hironori  <[email protected]>
+
+        [WinCairo] Enable USE_ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=219421
+
+        Reviewed by Don Olmstead.
+
+        * platform/wincairo/TestExpectations:
+
 2020-12-16  Chris Fleizach  <[email protected]>
 
         AX: Update list heuristics to include linked lists inside navigation containers

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (270898 => 270899)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2020-12-16 20:04:41 UTC (rev 270899)
@@ -2131,30 +2131,26 @@
 performance-api/paint-timing/performance-observer-first-contentful-paint.html [ Timeout ]
 storage/indexeddb/storage-limit-with-indices.html [ Failure ]
 webgl/1.0.3/conformance/canvas/drawingbuffer-test.html [ Skip ] # Timeout
-webgl/1.0.3/conformance/context/context-lost-restored.html [ Failure ]
 webgl/1.0.3/conformance/context/premultiplyalpha-test.html [ Failure ]
+webgl/1.0.3/conformance/extensions/oes-element-index-uint.html [ Failure ]
 webgl/1.0.3/conformance/extensions/oes-texture-float-with-video.html [ Skip ] # Timeout
-webgl/1.0.3/conformance/extensions/oes-texture-float.html [ Failure ]
 webgl/1.0.3/conformance/extensions/oes-texture-half-float-with-video.html [ Skip ] # Timeout
-webgl/1.0.3/conformance/extensions/oes-texture-half-float.html [ Failure ]
-webgl/1.0.3/conformance/extensions/webgl-compressed-texture-size-limit.html [ Failure ]
+webgl/1.0.3/conformance/glsl/bugs/array-of-struct-with-int-first-position.html [ Skip ] # This test makes DumpRenderTree process unable to exit
 webgl/1.0.3/conformance/glsl/bugs/long-expressions-should-not-crash.html [ Skip ] # Timeout
-webgl/1.0.3/conformance/more/functions/copyTexImage2DBadArgs.html [ Skip ] # Timeout
+webgl/1.0.3/conformance/misc/uninitialized-test.html [ Failure ]
 webgl/1.0.3/conformance/more/functions/readPixelsBadArgs.html [ Failure ]
 webgl/1.0.3/conformance/more/functions/texImage2DHTML.html [ Failure ]
 webgl/1.0.3/conformance/more/functions/texSubImage2DHTML.html [ Failure ]
-webgl/1.0.3/conformance/more/functions/texSubImage2DHTMLBadArgs.html [ Skip ] # Crash
-webgl/1.0.3/conformance/renderbuffers/feedback-loop.html [ Failure ]
+webgl/1.0.3/conformance/programs/program-test.html [ Failure ]
 webgl/1.0.3/conformance/renderbuffers/framebuffer-object-attachment.html [ Failure ]
-webgl/1.0.3/conformance/rendering/point-no-attributes.html [ Failure ]
+webgl/1.0.3/conformance/renderbuffers/framebuffer-state-restoration.html [ Failure ]
+webgl/1.0.3/conformance/renderbuffers/renderbuffer-initialization.html [ Failure ]
 webgl/1.0.3/conformance/textures/default-texture.html [ Failure ]
 webgl/1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgb565.html [ Skip ] # Timeout
 webgl/1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba4444.html [ Skip ] # Timeout
 webgl/1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video-rgba5551.html [ Skip ] # Timeout
 webgl/1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-video.html [ Skip ] # Timeout
-webgl/1.0.3/conformance/textures/tex-sub-image-2d-bad-args.html [ Skip ] # Crash
-webgl/1.0.3/conformance/textures/texture-copying-feedback-loops.html [ Failure ]
+webgl/1.0.3/conformance/textures/texture-attachment-formats.html [ Failure ]
+webgl/1.0.3/conformance/textures/texture-mips.html [ Failure ]
 webgl/1.0.3/conformance/textures/texture-upload-size.html [ Skip ] # Timeout
-webgl/conformance/extensions/ext-texture-compression-rgtc.html [ Failure ]
-webgl/conformance/extensions/s3tc-and-rgtc.html [ Failure ]
 webgl/webgl-vertex-array-object-defined.html [ Failure ]

Modified: trunk/Source/ThirdParty/ANGLE/CMakeLists.txt (270898 => 270899)


--- trunk/Source/ThirdParty/ANGLE/CMakeLists.txt	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/ThirdParty/ANGLE/CMakeLists.txt	2020-12-16 20:04:41 UTC (rev 270899)
@@ -170,6 +170,7 @@
 if (USE_ANGLE_WEBGL)
     set(libglesv2_entry_points_headers
         src/libGLESv2/entry_points_egl.h
+        src/libGLESv2/entry_points_egl_ext.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

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (270898 => 270899)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2020-12-16 20:04:41 UTC (rev 270899)
@@ -1,3 +1,12 @@
+2020-12-16  Fujii Hironori  <[email protected]>
+
+        [WinCairo] Enable USE_ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=219421
+
+        Reviewed by Don Olmstead.
+
+        * CMakeLists.txt: Added entry_points_egl_ext.h to libglesv2_entry_points_headers.
+
 2020-12-14  Alex Christensen  <[email protected]>
 
         Fix build.

Modified: trunk/Source/WebCore/ChangeLog (270898 => 270899)


--- trunk/Source/WebCore/ChangeLog	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/ChangeLog	2020-12-16 20:04:41 UTC (rev 270899)
@@ -1,3 +1,47 @@
+2020-12-16  Fujii Hironori  <[email protected]>
+
+        [WinCairo] Enable USE_ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=219421
+
+        Reviewed by Don Olmstead.
+
+        Switch GraphicsContextGLOpenGL implementation from old one
+        (GraphicsContextGLOpenGLES.cpp) to new one
+        (GraphicsContextGLANGLE.cpp), which is using ANGLE's internal API
+        and verification code, for WinCairo port. I will enable WebGL2 for
+        WinCairo in a follow-up patch.
+
+        GL_TEXTURE_RECTANGLE_ANGLE is not available for ANGLE D3D backend.
+        Use GL_TEXTURE_2D instead.
+
+        Add a new class WebCore::ANGLEContext by copying
+        Nicosia::GCGLANGLELayer::ANGLEContext. It'd be better to merge
+        them after GTK and WPE will also switch.
+
+        * PlatformWin.cmake:
+        * platform/TextureMapper.cmake:
+        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+        (WebCore::GraphicsContextGLOpenGL::reshapeFBOs):
+        (WebCore::GraphicsContextGLOpenGL::compileShader):
+        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
+        * platform/graphics/texmap/ANGLEContext.cpp: Added.
+        (WebCore::ANGLEContext::errorString):
+        (WebCore::ANGLEContext::lastErrorString):
+        (WebCore::ANGLEContext::createContext):
+        (WebCore::ANGLEContext::ANGLEContext):
+        (WebCore::ANGLEContext::~ANGLEContext):
+        (WebCore::ANGLEContext::makeContextCurrent):
+        (WebCore::ANGLEContext::platformContext const):
+        * platform/graphics/texmap/ANGLEContext.h: Added.
+        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
+        (WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL):
+        (WebCore::GraphicsContextGLOpenGL::isGLES2Compliant const):
+        (WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTarget):
+        * platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp:
+        (WebCore::TextureMapperGCGLPlatformLayer::TextureMapperGCGLPlatformLayer):
+        (WebCore::TextureMapperGCGLPlatformLayer::paintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h:
+
 2020-12-16  Chris Fleizach  <[email protected]>
 
         AX: Update list heuristics to include linked lists inside navigation containers

Modified: trunk/Source/WebCore/PlatformWin.cmake (270898 => 270899)


--- trunk/Source/WebCore/PlatformWin.cmake	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/PlatformWin.cmake	2020-12-16 20:04:41 UTC (rev 270899)
@@ -6,6 +6,7 @@
     "${WEBCORE_DIR}/accessibility/win"
     "${WEBCORE_DIR}/page/win"
     "${WEBCORE_DIR}/platform/graphics/egl"
+    "${WEBCORE_DIR}/platform/graphics/angle"
     "${WEBCORE_DIR}/platform/graphics/opengl"
     "${WEBCORE_DIR}/platform/graphics/opentype"
     "${WEBCORE_DIR}/platform/graphics/win"
@@ -37,13 +38,12 @@
 
     platform/audio/PlatformMediaSessionManager.cpp
 
+    platform/graphics/angle/ExtensionsGLANGLE.cpp
+    platform/graphics/angle/GraphicsContextGLANGLE.cpp
+    platform/graphics/angle/TemporaryANGLESetting.cpp
+
     platform/graphics/egl/GLContextEGL.cpp
 
-    platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp
-    platform/graphics/opengl/ExtensionsGLOpenGLES.cpp
-    platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp
-    platform/graphics/opengl/GraphicsContextGLOpenGLES.cpp
-    platform/graphics/opengl/GraphicsContextGLOpenGLPrivate.cpp
     platform/graphics/opengl/TemporaryOpenGLSetting.cpp
 
     platform/graphics/opentype/OpenTypeUtilities.cpp

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (270898 => 270899)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2020-12-16 20:04:41 UTC (rev 270899)
@@ -5,6 +5,8 @@
 
 list(APPEND WebCore_SOURCES
     platform/graphics/nicosia/NicosiaAnimation.cpp
+
+    platform/graphics/texmap/ANGLEContext.cpp
     platform/graphics/texmap/BitmapTexture.cpp
     platform/graphics/texmap/BitmapTexturePool.cpp
     platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp
@@ -18,6 +20,8 @@
 
 list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
     platform/graphics/nicosia/NicosiaAnimation.h
+
+    platform/graphics/texmap/ANGLEContext.h
     platform/graphics/texmap/BitmapTexture.h
     platform/graphics/texmap/ClipStack.h
     platform/graphics/texmap/GraphicsLayerTextureMapper.h

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (270898 => 270899)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-12-16 20:04:41 UTC (rev 270899)
@@ -223,20 +223,22 @@
         gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
     } else
         gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, drawingBufferTextureTarget(), 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);
+#else
+    GLenum textureTarget = drawingBufferTextureTarget();
+    GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat;
+    gl::BindTexture(textureTarget, m_texture);
+    gl::TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+    gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0);
+#if USE(COORDINATED_GRAPHICS)
     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);
+        gl::BindTexture(textureTarget, m_compositorTexture);
+        gl::TexImage2D(textureTarget, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+        gl::BindTexture(textureTarget, 0);
+        gl::BindTexture(textureTarget, m_intermediateTexture);
+        gl::TexImage2D(textureTarget, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+        gl::BindTexture(textureTarget, 0);
     }
-#else
-#error FIXME: Port to non-Cocoa platforms.
+#endif
 #endif // PLATFORM(COCOA)
 
     attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height);
@@ -1070,12 +1072,16 @@
     if (!makeContextCurrent())
         return;
 
+#if !PLATFORM(WIN)
     // We need the ANGLE_texture_rectangle extension to support IOSurface
     // backbuffers, but we don't want it exposed to WebGL user shaders.
     // Temporarily disable it during shader compilation.
     gl::Disable(GL_TEXTURE_RECTANGLE_ANGLE);
+#endif
     gl::CompileShader(shader);
+#if !PLATFORM(WIN)
     gl::Enable(GL_TEXTURE_RECTANGLE_ANGLE);
+#endif
 }
 
 void GraphicsContextGLOpenGL::compileShaderDirect(PlatformGLObject shader)

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


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h	2020-12-16 20:04:41 UTC (rev 270899)
@@ -102,12 +102,14 @@
     CALayer* platformLayer() const final { return reinterpret_cast<CALayer*>(m_webGLLayer.get()); }
     PlatformGraphicsContextGLDisplay platformDisplay() const { return m_displayObj; }
     PlatformGraphicsContextGLConfig platformConfig() const { return m_configObj; }
-    static GCGLenum drawingBufferTextureTarget();
     static GCGLenum drawingBufferTextureTargetQuery();
     static GCGLint EGLDrawingBufferTextureTarget();
 #else
     PlatformLayer* platformLayer() const final;
 #endif
+#if USE(ANGLE)
+    static GCGLenum drawingBufferTextureTarget();
+#endif
 
 #if PLATFORM(IOS_FAMILY)
     enum class ReleaseBehavior {

Added: trunk/Source/WebCore/platform/graphics/texmap/ANGLEContext.cpp (0 => 270899)


--- trunk/Source/WebCore/platform/graphics/texmap/ANGLEContext.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/ANGLEContext.cpp	2020-12-16 20:04:41 UTC (rev 270899)
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018, 2019 Igalia S.L.
+ * Copyright (C) 2009-2018 Apple Inc.
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc.
+ *
+ * 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 "ANGLEContext.h"
+
+#if USE(TEXTURE_MAPPER) && USE(ANGLE) && !USE(NICOSIA)
+
+#include "ANGLEHeaders.h"
+#include "Logging.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+const char* 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* ANGLEContext::lastErrorString()
+{
+    return errorString(EGL_GetError());
+}
+
+std::unique_ptr<ANGLEContext> ANGLEContext::createContext(EGLContext sharingContext, bool isForWebGL2)
+{
+    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;
+    }
+
+    Vector<EGLint> contextAttributes;
+    if (isForWebGL2) {
+        contextAttributes.append(EGL_CONTEXT_CLIENT_VERSION);
+        contextAttributes.append(3);
+    } else {
+        contextAttributes.append(EGL_CONTEXT_CLIENT_VERSION);
+        contextAttributes.append(2);
+        // ANGLE will upgrade the context to ES3 automatically unless this is specified.
+        contextAttributes.append(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE);
+        contextAttributes.append(EGL_FALSE);
+    }
+    contextAttributes.append(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
+    contextAttributes.append(EGL_TRUE);
+    if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
+        contextAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
+        // EGL_LOW_POWER_ANGLE is the default. Change to
+        // EGL_HIGH_POWER_ANGLE if desired.
+        contextAttributes.append(EGL_LOW_POWER_ANGLE);
+    }
+    contextAttributes.append(EGL_NONE);
+
+    EGLContext context = EGL_CreateContext(display, config, sharingContext, 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));
+}
+
+ANGLEContext::ANGLEContext(EGLDisplay display, EGLContext context, EGLSurface surface)
+    : m_display(display)
+    , m_context(context)
+    , m_surface(surface)
+{
+}
+
+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 ANGLEContext::makeContextCurrent()
+{
+    ASSERT(m_context);
+
+    if (EGL_GetCurrentContext() != m_context)
+        return EGL_MakeCurrent(m_display, m_surface, m_surface, m_context);
+    return true;
+}
+
+EGLContext ANGLEContext::platformContext() const
+{
+    return m_context;
+}
+
+} // namespace WebCore
+
+#endif

Added: trunk/Source/WebCore/platform/graphics/texmap/ANGLEContext.h (0 => 270899)


--- trunk/Source/WebCore/platform/graphics/texmap/ANGLEContext.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/ANGLEContext.h	2020-12-16 20:04:41 UTC (rev 270899)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018, 2019 Igalia S.L.
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc.
+ *
+ * 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(TEXTURE_MAPPER) && USE(ANGLE) && !USE(NICOSIA)
+
+#include <wtf/Noncopyable.h>
+
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+
+namespace WebCore {
+
+class ANGLEContext {
+    WTF_MAKE_NONCOPYABLE(ANGLEContext);
+public:
+    static const char* errorString(int statusCode);
+    static const char* lastErrorString();
+
+    static std::unique_ptr<ANGLEContext> createContext(EGLContext sharingContext, bool isForWebGL2);
+    ~ANGLEContext();
+
+    bool makeContextCurrent();
+    EGLContext platformContext() const;
+
+private:
+    ANGLEContext(EGLDisplay, EGLContext, EGLSurface);
+
+    EGLDisplay m_display { nullptr };
+    EGLContext m_context { nullptr };
+    EGLSurface m_surface { nullptr };
+};
+
+} // namespace WebCore
+
+#endif

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2020-12-16 20:04:41 UTC (rev 270899)
@@ -2,6 +2,7 @@
  * Copyright (C) 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -113,6 +114,7 @@
     : GraphicsContextGL(attributes, destination, sharedContext)
 {
     ASSERT_UNUSED(sharedContext, !sharedContext);
+    m_isForWebGL2 = attributes.isWebGL2;
 #if USE(NICOSIA)
     m_nicosiaLayer = WTF::makeUnique<Nicosia::GCGLANGLELayer>(*this, destination);
 #else
@@ -125,14 +127,15 @@
     attributes = contextAttributes(); // They may have changed during validation.
 
     if (destination == Destination::Offscreen) {
+        GLenum textureTarget = drawingBufferTextureTarget();
         // 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);
+        gl::BindTexture(textureTarget, m_texture);
+        gl::TexParameterf(textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        gl::TexParameterf(textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        gl::TexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        gl::TexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        gl::BindTexture(textureTarget, 0);
 
         // Create an FBO.
         gl::GenFramebuffers(1, &m_fbo);
@@ -140,20 +143,20 @@
 
 #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::BindTexture(texureType, m_compositorTexture);
+        gl::TexParameterf(texureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        gl::TexParameterf(texureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        gl::TexParameteri(texureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        gl::TexParameteri(texureType, 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(texureType, m_intermediateTexture);
+        gl::TexParameterf(texureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        gl::TexParameterf(texureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        gl::TexParameteri(texureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        gl::TexParameteri(texureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
-        gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0);
+        gl::BindTexture(texureType, 0);
 #endif
 
         // Create a multisample FBO.
@@ -412,7 +415,9 @@
 
 bool GraphicsContextGLOpenGL::isGLES2Compliant() const
 {
-#if USE(OPENGL_ES)
+#if USE(ANGLE)
+    return m_isForWebGL2;
+#elif USE(OPENGL_ES)
     return true;
 #else
     return false;
@@ -428,6 +433,17 @@
 #endif
 }
 
+#if USE(ANGLE)
+GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTarget()
+{
+#if PLATFORM(WIN)
+    return GL_TEXTURE_2D;
+#else
+    return GL_TEXTURE_RECTANGLE_ANGLE;
+#endif
+}
+#endif
+
 #if PLATFORM(GTK) && !USE(ANGLE)
 ExtensionsGL& GraphicsContextGLOpenGL::getExtensions()
 {

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp (270898 => 270899)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.cpp	2020-12-16 20:04:41 UTC (rev 270899)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, 2012, 2017 Igalia S.L.
+ * Copyright (C) 2020 Sony Interactive Entertainment Inc.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -22,6 +23,8 @@
 
 #if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && !USE(NICOSIA)
 
+#include "ANGLEContext.h"
+#include "ANGLEHeaders.h"
 #include "BitmapTextureGL.h"
 #include "GLContext.h"
 #include "TextureMapperGLHeaders.h"
@@ -34,9 +37,11 @@
     : m_context(context)
 {
     switch (destination) {
-    case GraphicsContextGLOpenGL::Destination::Offscreen:
-        m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
+    case GraphicsContextGLOpenGL::Destination::Offscreen: {
+        auto sharingContext = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext()->platformContext();
+        m_glContext = ANGLEContext::createContext(sharingContext, context.contextAttributes().isWebGL2);
         break;
+    }
     case GraphicsContextGLOpenGL::Destination::DirectlyToHostWindow:
         ASSERT_NOT_REACHED();
         break;
@@ -101,13 +106,12 @@
     ASSERT(m_context.m_state.boundReadFBO == m_context.m_state.boundDrawFBO);
     if (attrs.antialias && m_context.m_state.boundDrawFBO == m_context.m_multisampleFBO) {
         GLContext* previousActiveContext = GLContext::current();
-        if (previousActiveContext != m_glContext.get())
-            m_context.makeContextCurrent();
+        m_context.makeContextCurrent();
 
         m_context.resolveMultisamplingIfNecessary();
-        ::glBindFramebuffer(GraphicsContextGLOpenGL::FRAMEBUFFER, m_context.m_state.boundDrawFBO);
+        gl::BindFramebuffer(GL_FRAMEBUFFER, m_context.m_state.boundDrawFBO);
 
-        if (previousActiveContext && previousActiveContext != m_glContext.get())
+        if (previousActiveContext)
             previousActiveContext->makeContextCurrent();
     }
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h (270898 => 270899)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGCGLPlatformLayer.h	2020-12-16 20:04:41 UTC (rev 270899)
@@ -28,7 +28,7 @@
 
 namespace WebCore {
 
-class GLContext;
+class ANGLEContext;
 class TextureMapperPlatformLayerProxy;
 
 class TextureMapperGCGLPlatformLayer : public PlatformLayer {
@@ -49,7 +49,7 @@
 
 private:
     GraphicsContextGLOpenGL& m_context;
-    std::unique_ptr<GLContext> m_glContext;
+    std::unique_ptr<ANGLEContext> m_glContext;
 
 #if USE(COORDINATED_GRAPHICS)
     RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;

Modified: trunk/Source/cmake/OptionsWinCairo.cmake (270898 => 270899)


--- trunk/Source/cmake/OptionsWinCairo.cmake	2020-12-16 19:14:16 UTC (rev 270898)
+++ trunk/Source/cmake/OptionsWinCairo.cmake	2020-12-16 20:04:41 UTC (rev 270899)
@@ -45,7 +45,9 @@
 # https://bugs.webkit.org/show_bug.cgi?id=206635
 
 set(USE_ANGLE_EGL ON)
+set(USE_ANGLE_WEBGL ON)
 
+SET_AND_EXPOSE_TO_BUILD(USE_ANGLE ON)
 SET_AND_EXPOSE_TO_BUILD(USE_CAIRO ON)
 SET_AND_EXPOSE_TO_BUILD(USE_CF ON)
 SET_AND_EXPOSE_TO_BUILD(USE_CURL ON)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to