Skip to content

Commit 9f13ddc

Browse files
committed
Ensure there's a current context when checking the GLES version
1 parent 45b4620 commit 9f13ddc

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,18 @@ bool TextureMapperPlatformLayerBuffer::isHolePunchBuffer()
187187

188188
void TextureMapperPlatformLayerBuffer::addFenceSyncIfAvailable()
189189
{
190-
unsigned version = GLContext::current()->version();
190+
static unsigned version = 0;
191+
static std::once_flag onceFlag;
192+
193+
std::call_once(onceFlag, []() {
194+
GLContext* context = GLContext::current();
195+
if (!context) {
196+
context = PlatformDisplay::sharedDisplayForCompositing().sharingGLContext();
197+
context->makeContextCurrent();
198+
}
199+
version = context->version();
200+
});
201+
191202
if (version >= 300 && glFenceSync) {
192203
// GLES 3, so fences are available and we can use them.
193204
m_sync = static_cast<void*>(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));

0 commit comments

Comments
 (0)