Title: [275373] trunk/Source/WebCore
Revision
275373
Author
[email protected]
Date
2021-04-01 13:01:59 -0700 (Thu, 01 Apr 2021)

Log Message

[WebGL] Use GraphicsContextGLOpenGLManager for ports using TextureMapper
https://bugs.webkit.org/show_bug.cgi?id=224035

Reviewed by Don Olmstead.

Use GraphicsContextGLOpenGLManager for GTK, WPE and WinCairo ports
to reduce duplicated code.

GraphicsContextGLOpenGLBase.cpp isn't used by Cocoa ports.

No behavior change.

* PlatformMac.cmake:
* Sources.txt:
* SourcesCocoa.txt:
* platform/graphics/opengl/GraphicsContextGLOpenGLManager.h:
* platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
(WebCore::GraphicsContextGLOpenGL::create):
(WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
(WebCore::activeContexts): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275372 => 275373)


--- trunk/Source/WebCore/ChangeLog	2021-04-01 18:53:27 UTC (rev 275372)
+++ trunk/Source/WebCore/ChangeLog	2021-04-01 20:01:59 UTC (rev 275373)
@@ -1,3 +1,26 @@
+2021-04-01  Fujii Hironori  <[email protected]>
+
+        [WebGL] Use GraphicsContextGLOpenGLManager for ports using TextureMapper
+        https://bugs.webkit.org/show_bug.cgi?id=224035
+
+        Reviewed by Don Olmstead.
+
+        Use GraphicsContextGLOpenGLManager for GTK, WPE and WinCairo ports
+        to reduce duplicated code.
+
+        GraphicsContextGLOpenGLBase.cpp isn't used by Cocoa ports.
+
+        No behavior change.
+
+        * PlatformMac.cmake:
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * platform/graphics/opengl/GraphicsContextGLOpenGLManager.h:
+        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
+        (WebCore::GraphicsContextGLOpenGL::create):
+        (WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
+        (WebCore::activeContexts): Deleted.
+
 2021-04-01  Chris Lord  <[email protected]>
 
         Make FontCache constructable and safe to use off the main thread

Modified: trunk/Source/WebCore/PlatformMac.cmake (275372 => 275373)


--- trunk/Source/WebCore/PlatformMac.cmake	2021-04-01 18:53:27 UTC (rev 275372)
+++ trunk/Source/WebCore/PlatformMac.cmake	2021-04-01 20:01:59 UTC (rev 275373)
@@ -344,8 +344,6 @@
     platform/graphics/mac/SimpleFontDataCoreText.cpp
     platform/graphics/mac/WebLayer.mm
 
-    platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp
-
     platform/graphics/opentype/OpenTypeCG.cpp
     platform/graphics/opentype/OpenTypeMathData.cpp
 

Modified: trunk/Source/WebCore/Sources.txt (275372 => 275373)


--- trunk/Source/WebCore/Sources.txt	2021-04-01 18:53:27 UTC (rev 275372)
+++ trunk/Source/WebCore/Sources.txt	2021-04-01 20:01:59 UTC (rev 275373)
@@ -2070,6 +2070,7 @@
 platform/graphics/iso/ISOTrackEncryptionBox.cpp
 platform/graphics/iso/ISOVTTCue.cpp
 platform/graphics/opengl/GraphicsContextGLOpenGL.cpp
+platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp
 platform/graphics/opentype/OpenTypeMathData.cpp
 platform/graphics/transforms/AffineTransform.cpp
 platform/graphics/transforms/Matrix3DTransformOperation.cpp

Modified: trunk/Source/WebCore/SourcesCocoa.txt (275372 => 275373)


--- trunk/Source/WebCore/SourcesCocoa.txt	2021-04-01 18:53:27 UTC (rev 275372)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2021-04-01 20:01:59 UTC (rev 275373)
@@ -428,8 +428,6 @@
 platform/graphics/mac/SwitchingGPUClient.cpp
 platform/graphics/mac/WebKitNSImageExtras.mm
 platform/graphics/mac/WebLayer.mm
-platform/graphics/opengl/GraphicsContextGLOpenGLBase.cpp
-platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp
 platform/graphics/opentype/OpenTypeCG.cpp
 platform/ios/ColorIOS.mm
 platform/ios/Device.cpp

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h (275372 => 275373)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h	2021-04-01 18:53:27 UTC (rev 275372)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h	2021-04-01 20:01:59 UTC (rev 275373)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <wtf/HashSet.h>
+#include <wtf/Vector.h>
 
 #if PLATFORM(MAC)
 #include <CoreGraphics/CGDisplayConfiguration.h>

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


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2021-04-01 18:53:27 UTC (rev 275372)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp	2021-04-01 20:01:59 UTC (rev 275373)
@@ -32,6 +32,7 @@
 #if ENABLE(WEBGL) && USE(TEXTURE_MAPPER)
 
 #include "GLContext.h"
+#include "GraphicsContextGLOpenGLManager.h"
 #include "TextureMapperGCGLPlatformLayer.h"
 #include <ANGLE/ShaderLang.h>
 #include <wtf/Deque.h>
@@ -63,13 +64,6 @@
 
 namespace WebCore {
 
-static const size_t MaxActiveContexts = 16;
-static Deque<GraphicsContextGLOpenGL*, MaxActiveContexts>& activeContexts()
-{
-    static NeverDestroyed<Deque<GraphicsContextGLOpenGL*, MaxActiveContexts>> s_activeContexts;
-    return s_activeContexts;
-}
-
 RefPtr<GraphicsContextGLOpenGL> GraphicsContextGLOpenGL::create(GraphicsContextGLAttributes attributes, HostWindow* hostWindow)
 {
     static bool initialized = false;
@@ -83,13 +77,9 @@
     if (!success)
         return nullptr;
 
-    auto& contexts = activeContexts();
-    if (contexts.size() >= MaxActiveContexts)
-        contexts.first()->recycleContext();
-
-    // Calling recycleContext() above should have lead to the graphics context being
-    // destroyed and thus removed from the active contexts list.
-    if (contexts.size() >= MaxActiveContexts)
+    // Make space for the incoming context if we're full.
+    GraphicsContextGLOpenGLManager::sharedManager().recycleContextIfNecessary();
+    if (GraphicsContextGLOpenGLManager::sharedManager().hasTooManyContexts())
         return nullptr;
 
     // Create the GraphicsContextGLOpenGL object first in order to establist a current context on this thread.
@@ -101,7 +91,8 @@
         return nullptr;
 #endif
 
-    contexts.append(context.get());
+    GraphicsContextGLOpenGLManager::sharedManager().addContext(context.get());
+
     return context;
 }
 
@@ -309,6 +300,7 @@
 #if USE(ANGLE)
 GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL()
 {
+    GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
     bool success = makeContextCurrent();
     ASSERT_UNUSED(success, success);
     if (m_texture)
@@ -345,15 +337,11 @@
     if (m_vao)
         deleteVertexArray(m_vao);
 #endif
-
-    auto* activeContext = activeContexts().takeLast([this](auto* it) {
-        return it == this;
-    });
-    ASSERT_UNUSED(activeContext, !!activeContext);
 }
 #else
 GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL()
 {
+    GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
     bool success = makeContextCurrent();
     ASSERT_UNUSED(success, success);
     if (m_texture)
@@ -390,11 +378,6 @@
     if (m_vao)
         deleteVertexArray(m_vao);
 #endif
-
-    auto* activeContext = activeContexts().takeLast([this](auto* it) {
-        return it == this;
-    });
-    ASSERT_UNUSED(activeContext, !!activeContext);
 }
 #endif // USE(ANGLE)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to