Bug 929506 - fix context bug in BasicTextureImage. r=bjacob
authorNicolas Silva <nical@mozilla.com>
Tue, 03 Dec 2013 11:44:49 +0100
changeset 158549 3ac6ea6491a85377e2c044d28a01f85d12a55076
parent 158548 e249103c2049999aa9aba68faa7c8a04bdaa7027
child 158550 bb06cc9a70886e3725f6e960ef0ba6d709056325
push id25749
push userryanvm@gmail.com
push dateTue, 03 Dec 2013 21:45:20 +0000
treeherdermozilla-central@85694fd9b17c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs929506
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 929506 - fix context bug in BasicTextureImage. r=bjacob
gfx/gl/GLTextureImage.cpp
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -68,19 +68,18 @@ BasicTextureImage::~BasicTextureImage()
     if (ctx->IsDestroyed() || !ctx->IsOwningThreadCurrent()) {
         ctx = ctx->GetSharedContext();
     }
 
     // If we have a context, then we need to delete the texture;
     // if we don't have a context (either real or shared),
     // then they went away when the contex was deleted, because it
     // was the only one that had access to it.
-    if (ctx && !ctx->IsDestroyed()) {
-        mGLContext->MakeCurrent();
-        mGLContext->fDeleteTextures(1, &mTexture);
+    if (ctx && ctx->MakeCurrent()) {
+        ctx->fDeleteTextures(1, &mTexture);
     }
 }
 
 gfxASurface*
 BasicTextureImage::BeginUpdate(nsIntRegion& aRegion)
 {
     NS_ASSERTION(!mUpdateSurface, "BeginUpdate() without EndUpdate()?");
 
@@ -694,17 +693,19 @@ already_AddRefed<TextureImage>
 CreateBasicTextureImage(GLContext* aGL,
                         const nsIntSize& aSize,
                         TextureImage::ContentType aContentType,
                         GLenum aWrapMode,
                         TextureImage::Flags aFlags,
                         TextureImage::ImageFormat aImageFormat)
 {
     bool useNearestFilter = aFlags & TextureImage::UseNearestFilter;
-    aGL->MakeCurrent();
+    if (!aGL->MakeCurrent()) {
+      return nullptr;
+    }
 
     GLuint texture = 0;
     aGL->fGenTextures(1, &texture);
 
     ScopedBindTexture bind(aGL, texture);
 
     GLint texfilter = useNearestFilter ? LOCAL_GL_NEAREST : LOCAL_GL_LINEAR;
     aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, texfilter);