Title: [291616] trunk/Source/WebCore
Revision
291616
Author
commit-qu...@webkit.org
Date
2022-03-22 07:48:05 -0700 (Tue, 22 Mar 2022)

Log Message

Move TextureMapper member variables, types and code out of GraphicsContextGLANGLE
https://bugs.webkit.org/show_bug.cgi?id=238200

Patch by Zan Dobersek <zdober...@igalia.com> on 2022-03-22
Reviewed by Alejandro G. Castro.

Move member variables and code specific to the TextureMapper-oriented
GraphicsContextGLTextureMapperANGLE class from the parent
GraphicsContextGLANGLE class into GraphicsContextGLTextureMapperANGLE.

This means moving down various member variables and types as well as
friendship declarations. For behavior to remain the same, the
prepareTextureImpl() method is made virtual and overridden in the
TextureMapper class, but otherwise matches the previous behavior.

Nicosia::GCGLANGLELayer is adjusted to operate on a reference to the
derived class, not on the base GraphicsContextGLANGLE.

No new tests as there's no change in behavior.

* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::prepareTextureImpl):
* platform/graphics/angle/GraphicsContextGLANGLE.h:
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp:
(Nicosia::GCGLANGLELayer::GCGLANGLELayer):
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h:
* platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
(WebCore::GraphicsContextGLTextureMapperANGLE::prepareTextureImpl):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::EGLImageBacking):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::~EGLImageBacking):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::format const):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::stride const):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::releaseResources):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::isReleased):
(WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::reset):
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking): Deleted.
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking): Deleted.
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::format const): Deleted.
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::stride const): Deleted.
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::releaseResources): Deleted.
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::isReleased): Deleted.
(WebCore::GraphicsContextGLANGLE::EGLImageBacking::reset): Deleted.
* platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291615 => 291616)


--- trunk/Source/WebCore/ChangeLog	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/ChangeLog	2022-03-22 14:48:05 UTC (rev 291616)
@@ -1,3 +1,49 @@
+2022-03-22  Zan Dobersek  <zdober...@igalia.com>
+
+        Move TextureMapper member variables, types and code out of GraphicsContextGLANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=238200
+
+        Reviewed by Alejandro G. Castro.
+
+        Move member variables and code specific to the TextureMapper-oriented
+        GraphicsContextGLTextureMapperANGLE class from the parent
+        GraphicsContextGLANGLE class into GraphicsContextGLTextureMapperANGLE.
+
+        This means moving down various member variables and types as well as
+        friendship declarations. For behavior to remain the same, the
+        prepareTextureImpl() method is made virtual and overridden in the
+        TextureMapper class, but otherwise matches the previous behavior.
+
+        Nicosia::GCGLANGLELayer is adjusted to operate on a reference to the
+        derived class, not on the base GraphicsContextGLANGLE.
+
+        No new tests as there's no change in behavior.
+
+        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+        (WebCore::GraphicsContextGLANGLE::prepareTextureImpl):
+        * platform/graphics/angle/GraphicsContextGLANGLE.h:
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp:
+        (Nicosia::GCGLANGLELayer::GCGLANGLELayer):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h:
+        * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
+        (WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::prepareTextureImpl):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::EGLImageBacking):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::~EGLImageBacking):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::format const):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::stride const):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::releaseResources):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::isReleased):
+        (WebCore::GraphicsContextGLTextureMapperANGLE::EGLImageBacking::reset):
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking): Deleted.
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking): Deleted.
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::format const): Deleted.
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::stride const): Deleted.
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::releaseResources): Deleted.
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::isReleased): Deleted.
+        (WebCore::GraphicsContextGLANGLE::EGLImageBacking::reset): Deleted.
+        * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h:
+
 2022-03-22  Alejandro G. Castro  <a...@igalia.com>
 
         [WPE][GTK] VideoFrameGStreamer missing include after -r291610 refactor

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


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2022-03-22 14:48:05 UTC (rev 291616)
@@ -560,21 +560,7 @@
     if (contextAttributes().antialias)
         resolveMultisamplingIfNecessary();
 
-#if USE(TEXTURE_MAPPER)
-    std::swap(m_texture, m_compositorTexture);
-#if USE(COORDINATED_GRAPHICS)
-    std::swap(m_texture, m_intermediateTexture);
-    std::swap(m_textureBacking, m_compositorTextureBacking);
-    std::swap(m_textureBacking, m_intermediateTextureBacking);
-#endif
-
-    GL_BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
-    GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, drawingBufferTextureTarget(), m_texture, 0);
-    GL_Flush();
-
-    if (m_state.boundDrawFBO != m_fbo)
-        GL_BindFramebuffer(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
-#else
+#if PLATFORM(COCOA)
     if (m_preserveDrawingBufferTexture) {
         // Blit m_preserveDrawingBufferTexture into m_texture.
         ScopedGLCapability scopedScissor(GL_SCISSOR_TEST, GL_FALSE);

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h (291615 => 291616)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h	2022-03-22 14:48:05 UTC (rev 291616)
@@ -39,25 +39,8 @@
 #include "ProcessIdentity.h"
 #endif
 
-
-#if USE(NICOSIA)
-namespace Nicosia {
-class GCGLANGLELayer;
-class GCGLLayer;
-}
-
-struct gbm_device;
-struct gbm_bo;
-
-typedef void *EGLImage;
-#endif
-
 namespace WebCore {
 
-#if USE(TEXTURE_MAPPER)
-class TextureMapperGCGLPlatformLayer;
-#endif
-
 // Base class for GraphicsContextGL contexts that use ANGLE.
 class WEBCORE_EXPORT GraphicsContextGLANGLE : public GraphicsContextGL {
 public:
@@ -386,7 +369,7 @@
     std::optional<PixelBuffer> readPixelsForPaintResults();
 
     bool reshapeFBOs(const IntSize&);
-    void prepareTextureImpl();
+    virtual void prepareTextureImpl();
     void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
     void attachDepthAndStencilBufferIfNeeded(GCGLuint internalDepthStencilFormat, int width, int height);
 #if PLATFORM(COCOA)
@@ -447,53 +430,7 @@
     // When preserveDrawingBuffer == true, this is blitted to during display prepare.
     std::unique_ptr<IOSurface> m_displayBufferBacking;
     void* m_displayBufferPbuffer { nullptr };
-#elif USE(TEXTURE_MAPPER)
-    GCGLuint m_compositorTexture { 0 };
-#if USE(COORDINATED_GRAPHICS)
-    GCGLuint m_intermediateTexture { 0 };
 #endif
-#endif
-#if USE(NICOSIA)
-    std::unique_ptr<Nicosia::GCGLANGLELayer> m_nicosiaLayer;
-
-    class EGLImageBacking {
-    WTF_MAKE_FAST_ALLOCATED;
-    public:
-        EGLImageBacking(GCGLDisplay);
-        ~EGLImageBacking();
-
-        bool reset(int width, int height, bool hasAlpha);
-
-        EGLImage image() const { return m_image; }
-        int fd() const { return m_FD; }
-
-        uint32_t format() const;
-        uint32_t stride() const;
-
-        bool isReleased();
-    private:
-        void releaseResources();
-
-        GCGLDisplay m_display;
-
-        gbm_bo* m_BO { nullptr };
-        int m_FD { -1 };
-        EGLImage m_image;
-    };
-
-    std::unique_ptr<EGLImageBacking> m_textureBacking;
-    std::unique_ptr<EGLImageBacking> m_compositorTextureBacking;
-    std::unique_ptr<EGLImageBacking> m_intermediateTextureBacking;
-#elif USE(TEXTURE_MAPPER)
-    std::unique_ptr<TextureMapperGCGLPlatformLayer> m_texmapLayer;
-#endif
-
-#if USE(NICOSIA)
-    friend class Nicosia::GCGLANGLELayer;
-    friend class Nicosia::GCGLLayer;
-#elif USE(TEXTURE_MAPPER)
-    friend class TextureMapperGCGLPlatformLayer;
-#endif
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp (291615 => 291616)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2022-03-22 14:48:05 UTC (rev 291616)
@@ -32,6 +32,7 @@
 #if USE(NICOSIA) && USE(TEXTURE_MAPPER)
 
 #include "ANGLEHeaders.h"
+#include "GraphicsContextGLTextureMapperANGLE.h"
 #include "ImageBuffer.h"
 #include "Logging.h"
 #include "TextureMapperGL.h"
@@ -92,7 +93,7 @@
     m_context.markLayerComposited();
 }
 
-GCGLANGLELayer::GCGLANGLELayer(GraphicsContextGLANGLE& context)
+GCGLANGLELayer::GCGLANGLELayer(GraphicsContextGLTextureMapperANGLE& context)
     : m_context(context)
     , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
 {

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h (291615 => 291616)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.h	2022-03-22 14:48:05 UTC (rev 291616)
@@ -30,7 +30,6 @@
 
 #if USE(NICOSIA) && USE(TEXTURE_MAPPER)
 
-#include "GraphicsContextGLANGLE.h"
 #include "NicosiaContentLayerTextureMapperImpl.h"
 #include <memory>
 
@@ -42,6 +41,7 @@
 namespace WebCore {
 class IntSize;
 class GLContext;
+class GraphicsContextGLTextureMapperANGLE;
 class PlatformDisplay;
 }
 
@@ -50,7 +50,7 @@
 class GCGLANGLELayer final : public ContentLayerTextureMapperImpl::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    GCGLANGLELayer(WebCore::GraphicsContextGLANGLE&);
+    GCGLANGLELayer(WebCore::GraphicsContextGLTextureMapperANGLE&);
     virtual ~GCGLANGLELayer();
 
     ContentLayer& contentLayer() const { return m_contentLayer; }
@@ -57,7 +57,7 @@
     void swapBuffersIfNeeded() final;
 
 private:
-    WebCore::GraphicsContextGLANGLE& m_context;
+    WebCore::GraphicsContextGLTextureMapperANGLE& m_context;
     Ref<ContentLayer> m_contentLayer;
 };
 

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp	2022-03-22 14:48:05 UTC (rev 291616)
@@ -64,8 +64,6 @@
     ASSERT_UNUSED(success, success);
     if (m_texture)
         GL_DeleteTextures(1, &m_texture);
-    if (m_compositorTexture)
-        GL_DeleteTextures(1, &m_compositorTexture);
 
     auto attributes = contextAttributes();
 
@@ -79,9 +77,6 @@
             GL_DeleteRenderbuffers(1, &m_depthStencilBuffer);
     }
     GL_DeleteFramebuffers(1, &m_fbo);
-#if USE(COORDINATED_GRAPHICS)
-    GL_DeleteTextures(1, &m_intermediateTexture);
-#endif
 }
 
 GCGLDisplay GraphicsContextGLANGLE::platformDisplay() const
@@ -351,6 +346,28 @@
     return GraphicsContextGLANGLE::platformInitialize();
 }
 
+void GraphicsContextGLTextureMapperANGLE::prepareTextureImpl()
+{
+    ASSERT(!m_layerComposited);
+
+    if (contextAttributes().antialias)
+        resolveMultisamplingIfNecessary();
+
+    std::swap(m_texture, m_compositorTexture);
+#if USE(COORDINATED_GRAPHICS)
+    std::swap(m_texture, m_intermediateTexture);
+    std::swap(m_textureBacking, m_compositorTextureBacking);
+    std::swap(m_textureBacking, m_intermediateTextureBacking);
+#endif
+
+    GL_BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+    GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, drawingBufferTextureTarget(), m_texture, 0);
+    GL_Flush();
+
+    if (m_state.boundDrawFBO != m_fbo)
+        GL_BindFramebuffer(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
+}
+
 void GraphicsContextGLTextureMapperANGLE::setContextVisibility(bool)
 {
 }
@@ -409,18 +426,18 @@
 }
 
 #if USE(NICOSIA)
-GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking(GCGLDisplay display)
+GraphicsContextGLTextureMapperANGLE::EGLImageBacking::EGLImageBacking(GCGLDisplay display)
     : m_display(display)
     , m_image(EGL_NO_IMAGE)
 {
 }
 
-GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking()
+GraphicsContextGLTextureMapperANGLE::EGLImageBacking::~EGLImageBacking()
 {
     releaseResources();
 }
 
-uint32_t GraphicsContextGLANGLE::EGLImageBacking::format() const
+uint32_t GraphicsContextGLTextureMapperANGLE::EGLImageBacking::format() const
 {
     if (m_BO)
         return gbm_bo_get_format(m_BO);
@@ -427,7 +444,7 @@
     return 0;
 }
 
-uint32_t GraphicsContextGLANGLE::EGLImageBacking::stride() const
+uint32_t GraphicsContextGLTextureMapperANGLE::EGLImageBacking::stride() const
 {
     if (m_BO)
         return gbm_bo_get_stride(m_BO);
@@ -434,7 +451,7 @@
     return 0;
 }
 
-void GraphicsContextGLANGLE::EGLImageBacking::releaseResources()
+void GraphicsContextGLTextureMapperANGLE::EGLImageBacking::releaseResources()
 {
     if (m_BO) {
         gbm_bo_destroy(m_BO);
@@ -450,12 +467,12 @@
     }
 }
 
-bool GraphicsContextGLANGLE::EGLImageBacking::isReleased()
+bool GraphicsContextGLTextureMapperANGLE::EGLImageBacking::isReleased()
 {
     return !m_BO;
 }
 
-bool GraphicsContextGLANGLE::EGLImageBacking::reset(int width, int height, bool hasAlpha)
+bool GraphicsContextGLTextureMapperANGLE::EGLImageBacking::reset(int width, int height, bool hasAlpha)
 {
     releaseResources();
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h (291615 => 291616)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h	2022-03-22 14:41:52 UTC (rev 291615)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h	2022-03-22 14:48:05 UTC (rev 291616)
@@ -29,8 +29,22 @@
 
 #include "GraphicsContextGLANGLE.h"
 
+#if USE(NICOSIA)
+namespace Nicosia {
+class GCGLANGLELayer;
+class GCGLLayer;
+}
+
+struct gbm_device;
+struct gbm_bo;
+
+typedef void *EGLImage;
+#endif
+
 namespace WebCore {
 
+class TextureMapperGCGLPlatformLayer;
+
 class WEBCORE_EXPORT GraphicsContextGLTextureMapperANGLE : public GraphicsContextGLANGLE {
 public:
     static RefPtr<GraphicsContextGLTextureMapperANGLE> create(WebCore::GraphicsContextGLAttributes&&);
@@ -55,7 +69,56 @@
     bool platformInitializeContext() final;
     bool platformInitialize() final;
 
+    void prepareTextureImpl() final;
+
     RefPtr<GraphicsLayerContentsDisplayDelegate> m_layerContentsDisplayDelegate;
+
+    GCGLuint m_compositorTexture { 0 };
+#if USE(COORDINATED_GRAPHICS)
+    GCGLuint m_intermediateTexture { 0 };
+#endif
+
+#if USE(NICOSIA)
+    std::unique_ptr<Nicosia::GCGLANGLELayer> m_nicosiaLayer;
+
+    class EGLImageBacking {
+    WTF_MAKE_FAST_ALLOCATED;
+    public:
+        EGLImageBacking(GCGLDisplay);
+        ~EGLImageBacking();
+
+        bool reset(int width, int height, bool hasAlpha);
+
+        EGLImage image() const { return m_image; }
+        int fd() const { return m_FD; }
+
+        uint32_t format() const;
+        uint32_t stride() const;
+
+        bool isReleased();
+    private:
+        void releaseResources();
+
+        GCGLDisplay m_display;
+
+        gbm_bo* m_BO { nullptr };
+        int m_FD { -1 };
+        EGLImage m_image;
+    };
+
+    std::unique_ptr<EGLImageBacking> m_textureBacking;
+    std::unique_ptr<EGLImageBacking> m_compositorTextureBacking;
+    std::unique_ptr<EGLImageBacking> m_intermediateTextureBacking;
+#else
+    std::unique_ptr<TextureMapperGCGLPlatformLayer> m_texmapLayer;
+#endif
+
+#if USE(NICOSIA)
+    friend class Nicosia::GCGLANGLELayer;
+    friend class Nicosia::GCGLLayer;
+#else
+    friend class TextureMapperGCGLPlatformLayer;
+#endif
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to