Skip to content

Commit 9bd631e

Browse files
committed
Bug 1484624 - Don't create texture sources if the compositor doesn't have a GL context. r=sotaro
1 parent 8081638 commit 9bd631e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

gfx/layers/opengl/CompositorOGL.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,12 +1904,20 @@ CompositorOGL::Resume()
19041904
already_AddRefed<DataTextureSource>
19051905
CompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
19061906
{
1907+
if (!gl()) {
1908+
return nullptr;
1909+
}
1910+
19071911
return MakeAndAddRef<TextureImageTextureSourceOGL>(this, aFlags);
19081912
}
19091913

19101914
already_AddRefed<DataTextureSource>
19111915
CompositorOGL::CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture)
19121916
{
1917+
if (!gl()) {
1918+
return nullptr;
1919+
}
1920+
19131921
BufferTextureHost* bufferTexture = aTexture->AsBufferTextureHost();
19141922
MOZ_ASSERT(bufferTexture);
19151923

@@ -1991,6 +1999,10 @@ CompositorOGL::TryUnlockTextures()
19911999
already_AddRefed<DataTextureSource>
19922000
CompositorOGL::CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface)
19932001
{
2002+
if (!gl()) {
2003+
return nullptr;
2004+
}
2005+
19942006
return MakeAndAddRef<DirectMapTextureSource>(this, aSurface);
19952007
}
19962008

gfx/layers/opengl/TextureHostOGL.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,14 @@ DirectMapTextureSource::Update(gfx::DataSourceSurface* aSurface,
340340
bool
341341
DirectMapTextureSource::Sync(bool aBlocking)
342342
{
343-
gl()->MakeCurrent();
343+
if (!gl() || !gl()->MakeCurrent()) {
344+
// We use this function to decide whether we can unlock the texture
345+
// and clean it up. If we return false here and for whatever reason
346+
// the context is absent or invalid, the compositor will keep a
347+
// reference to this texture forever.
348+
return true;
349+
}
350+
344351
if (!gl()->IsDestroyed()) {
345352
if (aBlocking) {
346353
gl()->fFinishObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
@@ -357,7 +364,9 @@ DirectMapTextureSource::UpdateInternal(gfx::DataSourceSurface* aSurface,
357364
gfx::IntPoint* aSrcOffset,
358365
bool aInit)
359366
{
360-
gl()->MakeCurrent();
367+
if (!gl() || !gl()->MakeCurrent()) {
368+
return false;
369+
}
361370

362371
if (aInit) {
363372
gl()->fGenTextures(1, &mTextureHandle);

0 commit comments

Comments
 (0)