Bug 989349 - part 2 - eliminate static constructor in GLContextProviderGLX.cpp; r=bjacob
authorNathan Froyd <froydnj@mozilla.com>
Wed, 26 Mar 2014 09:26:11 -0400
changeset 177551 5723793a54e02131e3da8edf4754c250bb68bf6a
parent 177550 0eb9fb345a5b3230b15ccff4af74cacd71d2b801
child 177552 8eef124486621bf0d089dddcc9c1882dcabf773d
push id26556
push userryanvm@gmail.com
push dateTue, 08 Apr 2014 22:16:57 +0000
treeherdermozilla-central@5811efc11011 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs989349
milestone31.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 989349 - part 2 - eliminate static constructor in GLContextProviderGLX.cpp; r=bjacob
gfx/gl/GLContextProviderGLX.cpp
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -1185,24 +1185,30 @@ GLContextProviderGLX::CreateOffscreen(co
 
     if (!glContext->InitOffscreen(ToIntSize(size), caps))
         return nullptr;
 
     return glContext.forget();
 }
 
 static StaticRefPtr<GLContext> gGlobalContext;
-// TODO move that out of static initializaion
-static bool gUseContextSharing = getenv("MOZ_DISABLE_CONTEXT_SHARING_GLX") == 0;
 
 GLContext*
 GLContextProviderGLX::GetGlobalContext()
 {
+    static bool checkedContextSharing = false;
+    static bool useContextSharing = false;
+
+    if (!checkedContextSharing) {
+        useContextSharing = getenv("MOZ_DISABLE_CONTEXT_SHARING_GLX") == 0;
+        checkedContextSharing = true;
+    }
+
     // TODO: get GLX context sharing to work well with multiple threads
-    if (!gUseContextSharing) {
+    if (!useContextSharing) {
         return nullptr;
     }
 
     static bool triedToCreateContext = false;
     if (!triedToCreateContext && !gGlobalContext) {
         triedToCreateContext = true;
 
         gfxIntSize dummySize = gfxIntSize(16, 16);