Title: [291610] trunk/Source/WebCore
Revision
291610
Author
[email protected]
Date
2022-03-22 03:18:22 -0700 (Tue, 22 Mar 2022)

Log Message

[TextureMapper] Split GraphicsContextGLTextureMapper into two classes
https://bugs.webkit.org/show_bug.cgi?id=238141

Patch by Zan Dobersek <[email protected]> on 2022-03-22
Reviewed by Alejandro G. Castro.

Split GraphicsContextGLTextureMapper into two distinct classes. The
current class unconditionally inherits from GraphicsContextGLOpenGL, and
the new GraphicsContextGLTextureMapperANGLE inherits from
GraphicsContextGLANGLE. This reduces complexity and avoids the
implementation to span across two separate files. The two classes can
also be developed independently, with more changes and cleanups already
planned for the ANGLE variant.

No new tests due to no actual change in behavior.

* platform/TextureMapper.cmake:
* platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
(WebCore::createWebProcessGraphicsContextGL):
(WebCore::GraphicsContextGLTextureMapper::create):
(WebCore::GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper):
(WebCore::GraphicsContextGLTextureMapper::layerContentsDisplayDelegate):
(WebCore::GraphicsContextGLTextureMapper::copyTextureFromMedia):
(WebCore::GraphicsContextGLTextureMapper::paintCompositedResultsToVideoFrame):
(WebCore::GraphicsContextGLTextureMapper::platformInitialize):
* platform/graphics/texmap/GraphicsContextGLTextureMapper.h:
* platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
(WebCore::GraphicsContextGLANGLE::platformDisplay const):
(WebCore::GraphicsContextGLANGLE::platformConfig const):
(WebCore::GraphicsContextGLANGLE::makeContextCurrent):
(WebCore::GraphicsContextGLANGLE::checkGPUStatus):
(WebCore::GraphicsContextGLANGLE::platformReleaseThreadResources):
(WebCore::GraphicsContextGLANGLE::readCompositedResults):
(WebCore::createWebProcessGraphicsContextGL):
(WebCore::GraphicsContextGLTextureMapperANGLE::create):
(WebCore::GraphicsContextGLTextureMapperANGLE::GraphicsContextGLTextureMapperANGLE):
(WebCore::GraphicsContextGLTextureMapperANGLE::~GraphicsContextGLTextureMapperANGLE):
(WebCore::GraphicsContextGLTextureMapperANGLE::layerContentsDisplayDelegate):
(WebCore::GraphicsContextGLTextureMapperANGLE::copyTextureFromMedia):
(WebCore::GraphicsContextGLTextureMapperANGLE::paintCompositedResultsToVideoFrame):
(WebCore::GraphicsContextGLTextureMapperANGLE::platformInitializeContext):
(WebCore::GraphicsContextGLTextureMapperANGLE::platformInitialize):
(WebCore::GraphicsContextGLTextureMapperANGLE::setContextVisibility):
(WebCore::GraphicsContextGLTextureMapperANGLE::reshapeDisplayBufferBacking):
(WebCore::GraphicsContextGLTextureMapperANGLE::prepareForDisplay):
(WebCore::GraphicsContextGLTextureMapper::platformInitializeContext): Deleted.
(WebCore::GraphicsContextGLTextureMapper::platformInitialize): Deleted.
(WebCore::GraphicsContextGLTextureMapper::setContextVisibility): Deleted.
(WebCore::GraphicsContextGLTextureMapper::prepareForDisplay): Deleted.
(WebCore::GraphicsContextGLTextureMapper::reshapeDisplayBufferBacking): Deleted.
* platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h: Copied from Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291609 => 291610)


--- trunk/Source/WebCore/ChangeLog	2022-03-22 09:43:25 UTC (rev 291609)
+++ trunk/Source/WebCore/ChangeLog	2022-03-22 10:18:22 UTC (rev 291610)
@@ -1,3 +1,57 @@
+2022-03-22  Zan Dobersek  <[email protected]>
+
+        [TextureMapper] Split GraphicsContextGLTextureMapper into two classes
+        https://bugs.webkit.org/show_bug.cgi?id=238141
+
+        Reviewed by Alejandro G. Castro.
+
+        Split GraphicsContextGLTextureMapper into two distinct classes. The
+        current class unconditionally inherits from GraphicsContextGLOpenGL, and
+        the new GraphicsContextGLTextureMapperANGLE inherits from
+        GraphicsContextGLANGLE. This reduces complexity and avoids the
+        implementation to span across two separate files. The two classes can
+        also be developed independently, with more changes and cleanups already
+        planned for the ANGLE variant.
+
+        No new tests due to no actual change in behavior.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
+        (WebCore::createWebProcessGraphicsContextGL):
+        (WebCore::GraphicsContextGLTextureMapper::create):
+        (WebCore::GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper):
+        (WebCore::GraphicsContextGLTextureMapper::layerContentsDisplayDelegate):
+        (WebCore::GraphicsContextGLTextureMapper::copyTextureFromMedia):
+        (WebCore::GraphicsContextGLTextureMapper::paintCompositedResultsToVideoFrame):
+        (WebCore::GraphicsContextGLTextureMapper::platformInitialize):
+        * platform/graphics/texmap/GraphicsContextGLTextureMapper.h:
+        * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
+        (WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
+        (WebCore::GraphicsContextGLANGLE::platformDisplay const):
+        (WebCore::GraphicsContextGLANGLE::platformConfig const):
+        (WebCore::GraphicsContextGLANGLE::makeContextCurrent):
+        (WebCore::GraphicsContextGLANGLE::checkGPUStatus):
+        (WebCore::GraphicsContextGLANGLE::platformReleaseThreadResources):
+        (WebCore::GraphicsContextGLANGLE::readCompositedResults):
+        (WebCore::createWebProcessGraphicsContextGL):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::create):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::GraphicsContextGLTextureMapperANGLE):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::~GraphicsContextGLTextureMapperANGLE):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::layerContentsDisplayDelegate):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::copyTextureFromMedia):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::paintCompositedResultsToVideoFrame):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::platformInitializeContext):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::platformInitialize):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::setContextVisibility):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::reshapeDisplayBufferBacking):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::prepareForDisplay):
+        (WebCore::GraphicsContextGLTextureMapper::platformInitializeContext): Deleted.
+        (WebCore::GraphicsContextGLTextureMapper::platformInitialize): Deleted.
+        (WebCore::GraphicsContextGLTextureMapper::setContextVisibility): Deleted.
+        (WebCore::GraphicsContextGLTextureMapper::prepareForDisplay): Deleted.
+        (WebCore::GraphicsContextGLTextureMapper::reshapeDisplayBufferBacking): Deleted.
+        * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h: Copied from Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h.
+
 2022-03-22  Ziran Sun  <[email protected]>
 
         [selection] Change form's selection attribute to unsigned long

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (291609 => 291610)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2022-03-22 09:43:25 UTC (rev 291609)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2022-03-22 10:18:22 UTC (rev 291610)
@@ -24,6 +24,7 @@
     platform/graphics/texmap/BitmapTexture.h
     platform/graphics/texmap/ClipStack.h
     platform/graphics/texmap/GraphicsContextGLTextureMapper.h
+    platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h
     platform/graphics/texmap/GraphicsLayerTextureMapper.h
     platform/graphics/texmap/TextureMapper.h
     platform/graphics/texmap/TextureMapperBackingStore.h

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2022-03-22 09:43:25 UTC (rev 291609)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2022-03-22 10:18:22 UTC (rev 291610)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "GraphicsContextGLTextureMapper.h"
 
-#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER)
+#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && !USE(ANGLE)
 
 #include "PixelBuffer.h"
 #include "TextureMapperGCGLPlatformLayer.h"
@@ -36,9 +36,7 @@
 #include <wtf/Deque.h>
 #include <wtf/NeverDestroyed.h>
 
-#if USE(ANGLE)
-#include "ANGLEHeaders.h"
-#elif USE(LIBEPOXY)
+#if USE(LIBEPOXY)
 #include <epoxy/gl.h>
 #elif !USE(OPENGL_ES)
 #include "GLContext.h"
@@ -45,18 +43,12 @@
 #include "OpenGLShims.h"
 #endif
 
-#if !USE(ANGLE)
 #include <ANGLE/ShaderLang.h>
-#endif
 
 #if USE(NICOSIA)
-#if USE(ANGLE)
-#include "NicosiaGCGLANGLELayer.h"
-#else
 #include "NicosiaGCGLLayer.h"
 #include "PlatformLayerDisplayDelegate.h"
 #endif
-#endif
 
 #if ENABLE(MEDIA_STREAM)
 #include "VideoFrame.h"
@@ -72,32 +64,12 @@
 
 namespace WebCore {
 
-RefPtr<GraphicsContextGLTextureMapper> GraphicsContextGLTextureMapper::create(GraphicsContextGLAttributes&& attributes)
-{
-    auto context = adoptRef(*new GraphicsContextGLTextureMapper(WTFMove(attributes)));
-    if (!context->initialize())
-        return nullptr;
-    return context;
-}
-
-GraphicsContextGLTextureMapper::~GraphicsContextGLTextureMapper() = default;
-
-GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper(GraphicsContextGLAttributes&& attributes)
-    : GraphicsContextGLTextureMapperBase(WTFMove(attributes))
-{
-}
-
-RefPtr<GraphicsLayerContentsDisplayDelegate> GraphicsContextGLTextureMapper::layerContentsDisplayDelegate()
-{
-    return m_layerContentsDisplayDelegate;
-}
-
 RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes& attributes)
 {
     static bool initialized = false;
     static bool success = true;
     if (!initialized) {
-#if !USE(OPENGL_ES) && !USE(LIBEPOXY) && !USE(ANGLE)
+#if !USE(OPENGL_ES) && !USE(LIBEPOXY)
         success = initializeOpenGLShims();
 #endif
         initialized = true;
@@ -117,6 +89,33 @@
     return context;
 }
 
+RefPtr<GraphicsContextGLTextureMapper> GraphicsContextGLTextureMapper::create(GraphicsContextGLAttributes&& attributes)
+{
+    auto context = adoptRef(*new GraphicsContextGLTextureMapper(WTFMove(attributes)));
+    if (!context->initialize())
+        return nullptr;
+    return context;
+}
+
+GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper(GraphicsContextGLAttributes&& attributes)
+    : GraphicsContextGLOpenGL(WTFMove(attributes))
+{
+}
+
+GraphicsContextGLTextureMapper::~GraphicsContextGLTextureMapper() = default;
+
+RefPtr<GraphicsLayerContentsDisplayDelegate> GraphicsContextGLTextureMapper::layerContentsDisplayDelegate()
+{
+    return m_layerContentsDisplayDelegate;
+}
+
+#if ENABLE(VIDEO)
+bool GraphicsContextGLTextureMapper::copyTextureFromMedia(MediaPlayer& player, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
+{
+    return player.copyVideoTextureToPlatformTexture(this, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY);
+}
+#endif
+
 #if ENABLE(MEDIA_STREAM)
 RefPtr<VideoFrame> GraphicsContextGLTextureMapper::paintCompositedResultsToVideoFrame()
 {
@@ -128,29 +127,6 @@
 }
 #endif
 
-#if ENABLE(VIDEO)
-bool GraphicsContextGLTextureMapper::copyTextureFromMedia(MediaPlayer& player, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)
-{
-#if USE(ANGLE) && USE(GSTREAMER_GL)
-    UNUSED_PARAM(player);
-    UNUSED_PARAM(outputTexture);
-    UNUSED_PARAM(outputTarget);
-    UNUSED_PARAM(level);
-    UNUSED_PARAM(internalFormat);
-    UNUSED_PARAM(format);
-    UNUSED_PARAM(type);
-    UNUSED_PARAM(premultiplyAlpha);
-    UNUSED_PARAM(flipY);
-
-    // FIXME: Implement copy-free (or at least, software copy-free) texture transfer via dmabuf.
-    return false;
-#else
-    return player.copyVideoTextureToPlatformTexture(this, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY);
-#endif
-}
-#endif
-
-#if USE(NICOSIA) && !USE(ANGLE)
 bool GraphicsContextGLTextureMapper::platformInitialize()
 {
     m_layerContentsDisplayDelegate = PlatformLayerDisplayDelegate::create(&m_nicosiaLayer->contentLayer());
@@ -157,8 +133,7 @@
 
     return true;
 }
-#endif
 
 } // namespace WebCore
 
-#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER)
+#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && !USE(ANGLE)

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h (291609 => 291610)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h	2022-03-22 09:43:25 UTC (rev 291609)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h	2022-03-22 10:18:22 UTC (rev 291610)
@@ -25,28 +25,18 @@
 
 #pragma once
 
-#if ENABLE(WEBGL)
+#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && !USE(ANGLE)
 
-#if USE(ANGLE)
-#include "GraphicsContextGLANGLE.h"
-#else
 #include "GraphicsContextGLOpenGL.h"
-#endif
 
 namespace WebCore {
 
-#if USE(ANGLE)
-using GraphicsContextGLTextureMapperBase = GraphicsContextGLANGLE;
-#else
-using GraphicsContextGLTextureMapperBase = GraphicsContextGLOpenGL;
-#endif
-
-class WEBCORE_EXPORT GraphicsContextGLTextureMapper : public GraphicsContextGLTextureMapperBase {
+class WEBCORE_EXPORT GraphicsContextGLTextureMapper : public GraphicsContextGLOpenGL {
 public:
     static RefPtr<GraphicsContextGLTextureMapper> create(WebCore::GraphicsContextGLAttributes&&);
     ~GraphicsContextGLTextureMapper();
 
-    // GraphicsContextGLTextureMapperBase overrides.
+    // GraphicsContextGLOpenGL overrides.
     RefPtr<GraphicsLayerContentsDisplayDelegate> layerContentsDisplayDelegate() final;
 #if ENABLE(VIDEO)
     bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
@@ -54,21 +44,15 @@
 #if ENABLE(MEDIA_STREAM)
     RefPtr<VideoFrame> paintCompositedResultsToVideoFrame() final;
 #endif
-#if USE(ANGLE)
-    void setContextVisibility(bool) final;
-    bool reshapeDisplayBufferBacking() final;
-    void prepareForDisplay() final;
-#endif
 
 private:
-#if USE(ANGLE)
-    bool platformInitializeContext() final;
-#endif
+    GraphicsContextGLTextureMapper(WebCore::GraphicsContextGLAttributes&&);
+
     bool platformInitialize() final;
-    GraphicsContextGLTextureMapper(WebCore::GraphicsContextGLAttributes&&);
+
     RefPtr<GraphicsLayerContentsDisplayDelegate> m_layerContentsDisplayDelegate;
 };
 
-}
+} // namespace WebCore
 
-#endif
+#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && !USE(ANGLE)

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp	2022-03-22 09:43:25 UTC (rev 291609)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp	2022-03-22 10:18:22 UTC (rev 291610)
@@ -25,9 +25,9 @@
  */
 
 #include "config.h"
-#include "GraphicsContextGLTextureMapper.h"
+#include "GraphicsContextGLTextureMapperANGLE.h"
 
-#if ENABLE(WEBGL) && USE(ANGLE) && USE(TEXTURE_MAPPER)
+#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(ANGLE)
 
 #include "ANGLEHeaders.h"
 #include "ANGLEUtilities.h"
@@ -54,8 +54,119 @@
 {
 }
 
-bool GraphicsContextGLTextureMapper::platformInitializeContext()
+GraphicsContextGLANGLE::~GraphicsContextGLANGLE()
 {
+    bool success = makeContextCurrent();
+    ASSERT_UNUSED(success, success);
+    if (m_texture)
+        GL_DeleteTextures(1, &m_texture);
+    if (m_compositorTexture)
+        GL_DeleteTextures(1, &m_compositorTexture);
+
+    auto attributes = contextAttributes();
+
+    if (attributes.antialias) {
+        GL_DeleteRenderbuffers(1, &m_multisampleColorBuffer);
+        if (attributes.stencil || attributes.depth)
+            GL_DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+        GL_DeleteFramebuffers(1, &m_multisampleFBO);
+    } else if (attributes.stencil || attributes.depth) {
+        if (m_depthStencilBuffer)
+            GL_DeleteRenderbuffers(1, &m_depthStencilBuffer);
+    }
+    GL_DeleteFramebuffers(1, &m_fbo);
+#if USE(COORDINATED_GRAPHICS)
+    GL_DeleteTextures(1, &m_intermediateTexture);
+#endif
+}
+
+GCGLDisplay GraphicsContextGLANGLE::platformDisplay() const
+{
+    return m_displayObj;
+}
+
+GCGLConfig GraphicsContextGLANGLE::platformConfig() const
+{
+    return m_configObj;
+}
+
+bool GraphicsContextGLANGLE::makeContextCurrent()
+{
+    if (EGL_GetCurrentContext() == m_contextObj)
+        return true;
+    return EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
+}
+
+void GraphicsContextGLANGLE::checkGPUStatus()
+{
+}
+
+void GraphicsContextGLANGLE::platformReleaseThreadResources()
+{
+}
+
+std::optional<PixelBuffer> GraphicsContextGLANGLE::readCompositedResults()
+{
+    return readRenderingResults();
+}
+
+RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes& attributes)
+{
+    return GraphicsContextGLTextureMapperANGLE::create(GraphicsContextGLAttributes { attributes });
+}
+
+RefPtr<GraphicsContextGLTextureMapperANGLE> GraphicsContextGLTextureMapperANGLE::create(GraphicsContextGLAttributes&& attributes)
+{
+    auto context = adoptRef(*new GraphicsContextGLTextureMapperANGLE(WTFMove(attributes)));
+    if (!context->initialize())
+        return nullptr;
+    return context;
+}
+
+GraphicsContextGLTextureMapperANGLE::GraphicsContextGLTextureMapperANGLE(GraphicsContextGLAttributes&& attributes)
+    : GraphicsContextGLANGLE(WTFMove(attributes))
+{
+}
+
+GraphicsContextGLTextureMapperANGLE::~GraphicsContextGLTextureMapperANGLE()
+{
+    bool success = makeContextCurrent();
+    ASSERT_UNUSED(success, success);
+
+    if (m_compositorTexture)
+        GL_DeleteTextures(1, &m_compositorTexture);
+#if USE(COORDINATED_GRAPHICS)
+    if (m_intermediateTexture)
+        GL_DeleteTextures(1, &m_intermediateTexture);
+#endif
+}
+
+RefPtr<GraphicsLayerContentsDisplayDelegate> GraphicsContextGLTextureMapperANGLE::layerContentsDisplayDelegate()
+{
+    return m_layerContentsDisplayDelegate;
+}
+
+#if ENABLE(VIDEO)
+bool GraphicsContextGLTextureMapperANGLE::copyTextureFromMedia(MediaPlayer&, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool)
+{
+    // FIXME: Implement copy-free (or at least, software copy-free) texture transfer via dmabuf.
+    return false;
+}
+#endif
+
+#if ENABLE(MEDIA_STREAM)
+RefPtr<VideoFrame> GraphicsContextGLTextureMapperANGLE::paintCompositedResultsToVideoFrame()
+{
+#if USE(GSTREAMER)
+    if (auto pixelBuffer = readCompositedResults())
+        return VideoFrameGStreamer::createFromPixelBuffer(WTFMove(*pixelBuffer));
+#endif
+    return nullptr;
+}
+#endif
+
+bool GraphicsContextGLTextureMapperANGLE::platformInitializeContext()
+{
     GraphicsContextGLAttributes attributes = contextAttributes();
 #if ENABLE(WEBGL2)
     m_isForWebGL2 = attributes.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2;
@@ -157,7 +268,7 @@
     return true;
 }
 
-bool GraphicsContextGLTextureMapper::platformInitialize()
+bool GraphicsContextGLTextureMapperANGLE::platformInitialize()
 {
 #if USE(NICOSIA)
     m_nicosiaLayer = makeUnique<Nicosia::GCGLANGLELayer>(*this);
@@ -236,6 +347,63 @@
     return GraphicsContextGLANGLE::platformInitialize();
 }
 
+void GraphicsContextGLTextureMapperANGLE::setContextVisibility(bool)
+{
+}
+
+bool GraphicsContextGLTextureMapperANGLE::reshapeDisplayBufferBacking()
+{
+    auto attrs = contextAttributes();
+    const auto size = getInternalFramebufferSize();
+    const int width = size.width();
+    const int height = size.height();
+    GLuint colorFormat = attrs.alpha ? GL_RGBA : GL_RGB;
+    GLenum textureTarget = drawingBufferTextureTarget();
+    GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat;
+
+#if USE(COORDINATED_GRAPHICS)
+    if (m_textureBacking)
+        m_textureBacking->reset(width, height, attrs.alpha);
+    if (m_compositorTextureBacking)
+        m_compositorTextureBacking->reset(width, height, attrs.alpha);
+    if (m_intermediateTextureBacking)
+        m_intermediateTextureBacking->reset(width, height, attrs.alpha);
+#endif
+
+    ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
+#if USE(COORDINATED_GRAPHICS)
+    if (m_compositorTexture) {
+        GL_BindTexture(textureTarget, m_compositorTexture);
+        if (m_compositorTextureBacking && m_compositorTextureBacking->image())
+            GL_EGLImageTargetTexture2DOES(textureTarget, m_compositorTextureBacking->image());
+        else
+            GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+        GL_BindTexture(textureTarget, m_intermediateTexture);
+        if (m_intermediateTextureBacking && m_intermediateTextureBacking->image())
+            GL_EGLImageTargetTexture2DOES(textureTarget, m_intermediateTextureBacking->image());
+        else
+            GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+    }
+    GL_BindTexture(textureTarget, m_texture);
+    if (m_textureBacking && m_textureBacking->image())
+        GL_EGLImageTargetTexture2DOES(textureTarget, m_textureBacking->image());
+    else
+        GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+#else
+    GL_BindTexture(textureTarget, m_compositorTexture);
+    GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+    GL_BindTexture(textureTarget, m_texture);
+    GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+#endif
+    GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0);
+
+    return true;
+}
+
+void GraphicsContextGLTextureMapperANGLE::prepareForDisplay()
+{
+}
+
 #if USE(NICOSIA)
 GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking(GCGLDisplay display)
     : m_display(display)
@@ -315,119 +483,6 @@
 }
 #endif
 
-GraphicsContextGLANGLE::~GraphicsContextGLANGLE()
-{
-    bool success = makeContextCurrent();
-    ASSERT_UNUSED(success, success);
-    if (m_texture)
-        GL_DeleteTextures(1, &m_texture);
-    if (m_compositorTexture)
-        GL_DeleteTextures(1, &m_compositorTexture);
+} // namespace WebCore
 
-    auto attributes = contextAttributes();
-
-    if (attributes.antialias) {
-        GL_DeleteRenderbuffers(1, &m_multisampleColorBuffer);
-        if (attributes.stencil || attributes.depth)
-            GL_DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
-        GL_DeleteFramebuffers(1, &m_multisampleFBO);
-    } else if (attributes.stencil || attributes.depth) {
-        if (m_depthStencilBuffer)
-            GL_DeleteRenderbuffers(1, &m_depthStencilBuffer);
-    }
-    GL_DeleteFramebuffers(1, &m_fbo);
-#if USE(COORDINATED_GRAPHICS)
-    GL_DeleteTextures(1, &m_intermediateTexture);
-#endif
-}
-
-GCGLDisplay GraphicsContextGLANGLE::platformDisplay() const
-{
-    return m_displayObj;
-}
-
-GCGLConfig GraphicsContextGLANGLE::platformConfig() const
-{
-    return m_configObj;
-}
-
-bool GraphicsContextGLANGLE::makeContextCurrent()
-{
-    if (EGL_GetCurrentContext() == m_contextObj)
-        return true;
-    return EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
-}
-
-void GraphicsContextGLANGLE::checkGPUStatus()
-{
-}
-
-void GraphicsContextGLTextureMapper::setContextVisibility(bool)
-{
-}
-
-void GraphicsContextGLTextureMapper::prepareForDisplay()
-{
-}
-
-bool GraphicsContextGLTextureMapper::reshapeDisplayBufferBacking()
-{
-    auto attrs = contextAttributes();
-    const auto size = getInternalFramebufferSize();
-    const int width = size.width();
-    const int height = size.height();
-    GLuint colorFormat = attrs.alpha ? GL_RGBA : GL_RGB;
-    GLenum textureTarget = drawingBufferTextureTarget();
-    GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat;
-
-#if USE(COORDINATED_GRAPHICS)
-    if (m_textureBacking)
-        m_textureBacking->reset(width, height, attrs.alpha);
-    if (m_compositorTextureBacking)
-        m_compositorTextureBacking->reset(width, height, attrs.alpha);
-    if (m_intermediateTextureBacking)
-        m_intermediateTextureBacking->reset(width, height, attrs.alpha);
-#endif
-
-    ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
-#if USE(COORDINATED_GRAPHICS)
-    if (m_compositorTexture) {
-        GL_BindTexture(textureTarget, m_compositorTexture);
-        if (m_compositorTextureBacking && m_compositorTextureBacking->image())
-            GL_EGLImageTargetTexture2DOES(textureTarget, m_compositorTextureBacking->image());
-        else
-            GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
-        GL_BindTexture(textureTarget, m_intermediateTexture);
-        if (m_intermediateTextureBacking && m_intermediateTextureBacking->image())
-            GL_EGLImageTargetTexture2DOES(textureTarget, m_intermediateTextureBacking->image());
-        else
-            GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
-    }
-    GL_BindTexture(textureTarget, m_texture);
-    if (m_textureBacking && m_textureBacking->image())
-        GL_EGLImageTargetTexture2DOES(textureTarget, m_textureBacking->image());
-    else
-        GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
-#else
-    GL_BindTexture(textureTarget, m_compositorTexture);
-    GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
-    GL_BindTexture(textureTarget, m_texture);
-    GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
-#endif
-    GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0);
-
-    return true;
-}
-
-void GraphicsContextGLANGLE::platformReleaseThreadResources()
-{
-}
-
-std::optional<PixelBuffer> GraphicsContextGLANGLE::readCompositedResults()
-{
-    return readRenderingResults();
-}
-
-}
-
-#endif
+#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(ANGLE)

Copied: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h (from rev 291609, trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h) (0 => 291610)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h	2022-03-22 10:18:22 UTC (rev 291610)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. 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 ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(ANGLE)
+
+#include "GraphicsContextGLANGLE.h"
+
+namespace WebCore {
+
+class WEBCORE_EXPORT GraphicsContextGLTextureMapperANGLE : public GraphicsContextGLANGLE {
+public:
+    static RefPtr<GraphicsContextGLTextureMapperANGLE> create(WebCore::GraphicsContextGLAttributes&&);
+    ~GraphicsContextGLTextureMapperANGLE();
+
+    // GraphicsContextGLANGLE overrides.
+    RefPtr<GraphicsLayerContentsDisplayDelegate> layerContentsDisplayDelegate() final;
+#if ENABLE(VIDEO)
+    bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
+#endif
+#if ENABLE(MEDIA_STREAM)
+    RefPtr<VideoFrame> paintCompositedResultsToVideoFrame() final;
+#endif
+
+    void setContextVisibility(bool) final;
+    bool reshapeDisplayBufferBacking() final;
+    void prepareForDisplay() final;
+
+private:
+    GraphicsContextGLTextureMapperANGLE(WebCore::GraphicsContextGLAttributes&&);
+
+    bool platformInitializeContext() final;
+    bool platformInitialize() final;
+
+    RefPtr<GraphicsLayerContentsDisplayDelegate> m_layerContentsDisplayDelegate;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL) && USE(TEXTURE_MAPPER) && USE(ANGLE)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to