Bug 929506 - Check that the GLContext is not destroyed in MakeCurrent. r=bjacob
authorNicolas Silva <nical@mozilla.com>
Tue, 03 Dec 2013 11:44:37 +0100
changeset 158547 cd2a2e6b360b1ac21d53e8bd81c0236a291b9f43
parent 158546 24161557228b65b567975a2ce36ee58a50b1a535
child 158548 e249103c2049999aa9aba68faa7c8a04bdaa7027
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 - Check that the GLContext is not destroyed in MakeCurrent. r=bjacob
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLContextProviderWGL.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -451,17 +451,17 @@ GLContext::InitWithPrefix(const char *pr
         { (PRFuncPtr*) &mSymbols.fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", nullptr } },
         { (PRFuncPtr*) &mSymbols.fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", nullptr } },
 
         { nullptr, { nullptr } },
 
     };
 
     mInitialized = LoadSymbols(&symbols[0], trygl, prefix);
-
+    MakeCurrent();
     if (mInitialized) {
         unsigned int version = 0;
 
         bool parseSuccess = ParseGLVersion(this, &version);
 
         if (version >= mVersion) {
             mVersion = version;
         } else if (parseSuccess) {
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2386,16 +2386,19 @@ public:
 
 #ifdef MOZ_ENABLE_GL_TRACKING
     static void StaticInit() {
         PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, nullptr);
     }
 #endif
 
     bool MakeCurrent(bool aForce = false) {
+        if (IsDestroyed()) {
+            return false;
+        }
 #ifdef MOZ_ENABLE_GL_TRACKING
     PR_SetThreadPrivate(sCurrentGLContextTLS, this);
 
     // XXX this assertion is disabled because it's triggering on Mac;
     // we need to figure out why and reenable it.
 #if 0
         // IsOwningThreadCurrent is a bit of a misnomer;
         // the "owning thread" is the creation thread,
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -116,17 +116,16 @@ public:
     }
 
     GLContextType GetContextType() {
         return ContextTypeCGL;
     }
 
     bool Init()
     {
-        MakeCurrent();
         if (!InitWithPrefix("gl", true))
             return false;
 
         return true;
     }
 
     void *GetNativeData(NativeDataType aType)
     { 
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -326,27 +326,27 @@ public:
 #if defined(XP_UNIX)
                 if (!OpenLibrary(GLES2_LIB2)) {
                     NS_WARNING("Couldn't load GLES2 LIB.");
                     return false;
                 }
 #endif
             }
 
+        SetupLookupFunction();
+        if (!InitWithPrefix("gl", true))
+            return false;
+
         bool current = MakeCurrent();
         if (!current) {
             gfx::LogFailure(NS_LITERAL_CSTRING(
                 "Couldn't get device attachments for device."));
             return false;
         }
 
-        SetupLookupFunction();
-        if (!InitWithPrefix("gl", true))
-            return false;
-
         PR_STATIC_ASSERT(sizeof(GLint) >= sizeof(int32_t));
         mMaxTextureImageSize = INT32_MAX;
 
         mShareWithEGLImage = sEGLLibrary.HasKHRImageBase() &&
                              sEGLLibrary.HasKHRImageTexture2D() &&
                              IsExtensionSupported(OES_EGL_image);
 
         return true;
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -856,17 +856,16 @@ TRY_AGAIN_NO_SHARING:
     }
 
     GLContextType GetContextType() {
         return ContextTypeGLX;
     }
 
     bool Init()
     {
-        MakeCurrent();
         SetupLookupFunction();
         if (!InitWithPrefix("gl", true)) {
             return false;
         }
 
         if (!IsExtensionSupported(EXT_framebuffer_object))
             return false;
 
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -310,17 +310,16 @@ public:
         return ContextTypeWGL;
     }
 
     bool Init()
     {
         if (!mDC || !mContext)
             return false;
 
-        MakeCurrent();
         SetupLookupFunction();
         if (!InitWithPrefix("gl", true))
             return false;
 
         return true;
     }
 
     bool MakeCurrentImpl(bool aForce = false)