Bug 686083 - Adds method to disable GL implementations - r=bjacob
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 19 Oct 2011 15:09:57 -0400
changeset 79607 f5f1228fc7abe7da15dc8b16e525a2a78dd99516
parent 79606 b3d39e8a44b8360740ff0f3d8dc65a4a40af5d18
child 79608 716915ed489cdfecbb2e5455718b29504bedcbe4
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs686083
milestone10.0a1
Bug 686083 - Adds method to disable GL implementations - r=bjacob
gfx/thebes/GLContextProviderCGL.mm
gfx/thebes/GLContextProviderWGL.cpp
--- a/gfx/thebes/GLContextProviderCGL.mm
+++ b/gfx/thebes/GLContextProviderCGL.mm
@@ -41,16 +41,17 @@
 #include <OpenGL/gl.h>
 #include <AppKit/NSOpenGL.h>
 #include "gfxASurface.h"
 #include "gfxImageSurface.h"
 #include "gfxQuartzSurface.h"
 #include "gfxPlatform.h"
 #include "gfxFailure.h"
 #include "prenv.h"
+#include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace gl {
 
 static bool gUseDoubleBufferedWindows = true;
 
 class CGLLibrary
 {
@@ -553,26 +554,31 @@ CreateOffscreenFBOContext(const gfxIntSi
     return glContext.forget();
 }
 
 already_AddRefed<GLContext>
 GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
                                       const ContextFormat& aFormat)
 {
     nsRefPtr<GLContextCGL> glContext;
-
-    glContext = CreateOffscreenPBufferContext(aSize, aFormat);
-    if (glContext &&
-        glContext->Init())
+    
+    NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
+    const bool preferFBOs = Preferences::GetBool("cgl.prefer-fbo", false);
+    if (!preferFBOs)
     {
-        glContext->mOffscreenSize = aSize;
-        glContext->mOffscreenActualSize = aSize;
+	    glContext = CreateOffscreenPBufferContext(aSize, aFormat);
+	    if (glContext &&
+	        glContext->Init())
+	    {
+	        glContext->mOffscreenSize = aSize;
+	        glContext->mOffscreenActualSize = aSize;
 
-        return glContext.forget();
-    }
+	        return glContext.forget();
+	    }
+	}
 
     // try a FBO as second choice
     glContext = CreateOffscreenFBOContext(aSize, aFormat);
     if (glContext &&
         glContext->Init() &&
         glContext->ResizeOffscreenFBO(aSize))
     {
         return glContext.forget();
--- a/gfx/thebes/GLContextProviderWGL.cpp
+++ b/gfx/thebes/GLContextProviderWGL.cpp
@@ -43,16 +43,18 @@
 #include "gfxImageSurface.h"
 #include "gfxPlatform.h"
 #include "gfxWindowsSurface.h"
 
 #include "gfxCrashReporterUtils.h"
 
 #include "prenv.h"
 
+#include "mozilla/Preferences.h"
+
 namespace mozilla {
 namespace gl {
 
 WGLLibrary sWGLLibrary;
 
 static HWND gSharedWindow = 0;
 static HDC gSharedWindowDC = 0;
 static HGLRC gSharedWindowGLContext = 0;
@@ -611,17 +613,20 @@ GLContextProviderWGL::CreateOffscreen(co
     if (!sWGLLibrary.EnsureInitialized()) {
         return nsnull;
     }
 
     nsRefPtr<GLContextWGL> glContext;
 
     // Always try to create a pbuffer context first, because we
     // want the context isolation.
-    if (sWGLLibrary.fCreatePbuffer &&
+    NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
+    const bool preferFBOs = Preferences::GetBool("wgl.prefer-fbo", false);
+    if (!preferFBOs &&
+        sWGLLibrary.fCreatePbuffer &&
         sWGLLibrary.fChoosePixelFormat)
     {
         glContext = CreatePBufferOffscreenContext(aSize, aFormat);
     }
 
     // If it failed, then create a window context and use a FBO.
     if (!glContext) {
         glContext = CreateWindowOffscreenContext(aSize, aFormat);