Skip to content

Commit 3baf50e

Browse files
authored
Merge pull request #1230 from asurdej-comcast/window_context
[2.38] Destroy acc surface and egl target in nonCompositedWebGL mode
2 parents 65c9cc4 + e410cf3 commit 3baf50e

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ namespace Nicosia {
4444
using namespace WebCore;
4545

4646
static std::unique_ptr<GLContext> s_windowContext;
47-
48-
static void terminateWindowContext()
49-
{
50-
s_windowContext = nullptr;
51-
}
47+
static int s_windowContextRefCount = 0;
5248

5349
std::unique_ptr<GCGLLayer> GCGLLayer::create(WebCore::GraphicsContextGLOpenGL& context)
5450
{
@@ -60,7 +56,6 @@ std::unique_ptr<GCGLLayer> GCGLLayer::create(WebCore::GraphicsContextGLOpenGL& c
6056
} else {
6157
if (!s_windowContext) {
6258
s_windowContext = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(attributes.nativeWindowID), &PlatformDisplay::sharedDisplayForCompositing());
63-
std::atexit(terminateWindowContext);
6459
}
6560
if (s_windowContext)
6661
return makeUnique<GCGLLayer>(context);
@@ -80,11 +75,21 @@ GCGLLayer::GCGLLayer(GraphicsContextGLOpenGL& context)
8075
: m_context(context)
8176
, m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
8277
{
78+
ASSERT(s_windowContext);
79+
s_windowContextRefCount++;
8380
}
8481

8582
GCGLLayer::~GCGLLayer()
8683
{
8784
downcast<ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient();
85+
86+
if (m_context.contextAttributes().renderTarget != GraphicsContextGLRenderTarget::Offscreen) {
87+
ASSERT(s_windowContext);
88+
s_windowContextRefCount--;
89+
if (!s_windowContextRefCount) {
90+
s_windowContext = nullptr;
91+
}
92+
}
8893
}
8994

9095
bool GCGLLayer::makeContextCurrent()

Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,17 @@ void ThreadedCompositor::invalidate()
110110
m_compositingRunLoop->stopUpdates();
111111
m_displayRefreshMonitor->invalidate();
112112
m_compositingRunLoop->performTaskSync([this, protectedThis = Ref { *this }] {
113-
if (!m_context || !m_context->makeContextCurrent())
114-
return;
113+
if (m_context) {
114+
if (!m_context->makeContextCurrent())
115+
return;
115116

116-
// Update the scene at this point ensures the layers state are correctly propagated
117-
// in the ThreadedCompositor and in the CompositingCoordinator.
118-
updateSceneWithoutRendering();
117+
// Update the scene at this point ensures the layers state are correctly propagated
118+
// in the ThreadedCompositor and in the CompositingCoordinator.
119+
updateSceneWithoutRendering();
119120

120-
m_scene->purgeGLResources();
121-
m_context = nullptr;
121+
m_scene->purgeGLResources();
122+
m_context = nullptr;
123+
}
122124
m_client.didDestroyGLContext();
123125
m_scene = nullptr;
124126
});

0 commit comments

Comments
 (0)