Bug 628403 - introduce webgl.force-enabled and webgl.disabled prefs - r=vlad, a=joe
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 28 Jan 2011 21:12:24 -0500
changeset 61566 2a7ac44076692b40386defdc1b2f7cf70019f33c
parent 61565 f704da8cce12481a5436cafbb692df22691e1b7d
child 61567 828decbcc564718527dc890da335564cbd627701
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersvlad, joe
bugs628403
milestone2.0b11pre
Bug 628403 - introduce webgl.force-enabled and webgl.disabled prefs - r=vlad, a=joe
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContextUtils.cpp
content/canvas/test/webgl/test_webgl_conformance_test_suite.html
modules/libpref/src/init/all.js
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -397,30 +397,31 @@ WebGLContext::SetDimensions(PRInt32 widt
     PRBool verbose = PR_FALSE;
     prefService->GetBoolPref("webgl.verbose", &verbose);
     mVerbose = verbose;
 
     // Get some prefs for some preferred/overriden things
     PRBool forceOSMesa = PR_FALSE;
     PRBool preferEGL = PR_FALSE;
     PRBool preferOpenGL = PR_FALSE;
+    PRBool forceEnabled = PR_FALSE;
     prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa);
     prefService->GetBoolPref("webgl.prefer_egl", &preferEGL);
     prefService->GetBoolPref("webgl.prefer_gl", &preferOpenGL);
-
+    prefService->GetBoolPref("webgl.force-enabled", &forceEnabled);
     if (PR_GetEnv("MOZ_WEBGL_PREFER_EGL")) {
         preferEGL = PR_TRUE;
     }
 
     // Ask GfxInfo about what we should use
     PRBool useOpenGL = PR_TRUE;
     PRBool useANGLE = PR_TRUE;
 
     nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
-    if (gfxInfo) {
+    if (gfxInfo && !forceEnabled) {
         PRInt32 status;
         if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_OPENGL, &status))) {
             if (status != nsIGfxInfo::FEATURE_NO_INFO) {
                 useOpenGL = PR_FALSE;
             }
         }
         if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBGL_ANGLE, &status))) {
             if (status != nsIGfxInfo::FEATURE_NO_INFO) {
--- a/content/canvas/src/WebGLContextUtils.cpp
+++ b/content/canvas/src/WebGLContextUtils.cpp
@@ -84,19 +84,19 @@ WebGLContext::SafeToCreateCanvas3DContex
         return PR_TRUE;
 
     // not chrome? check pref.
 
     // first check our global pref
     nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, PR_FALSE);
 
-    PRBool allSites = PR_FALSE;
-    rv = prefService->GetBoolPref("webgl.enabled_for_all_sites", &allSites);
-    if (NS_SUCCEEDED(rv) && allSites) {
+    PRBool disabled = PR_FALSE;
+    rv = prefService->GetBoolPref("webgl.disabled", &disabled);
+    if (NS_SUCCEEDED(rv) && !disabled) {
         // the all-sites pref was set, we're good to go
         return PR_TRUE;
     }
 
 #if 0
     // otherwise we'll check content prefs
     nsCOMPtr<nsIContentPrefService> cpsvc = do_GetService("@mozilla.org/content-pref/service;1", &rv);
     if (NS_FAILED(rv)) {
--- a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html
+++ b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html
@@ -40,24 +40,24 @@ Mochitest version of the WebGL Conforman
 function start() {
 
   function prefSvc() {
     var svc = Components.classes["@mozilla.org/preferences-service;1"]
                         .getService(Components.interfaces.nsIPrefService).getBranch("");
     return svc;
   }
 
-  function setEnabledForAllSites(value) {
+  function setForceEnabled(value) {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    prefSvc().setBoolPref("webgl.enabled_for_all_sites", value);
+    prefSvc().setBoolPref("webgl.force-enabled", value);
   }
 
-  function getEnabledForAllSites() {
+  function getForceEnabled() {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    return prefSvc().getBoolPref("webgl.enabled_for_all_sites");
+    return prefSvc().getBoolPref("webgl.force-enabled");
   }
 
   function setPreferGL(value) {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
     prefSvc().setBoolPref("webgl.prefer_gl", value);
   }
 
   function getPreferGL() {
@@ -65,17 +65,17 @@ function start() {
     var retval = false;
     try {
       retval = prefSvc().getBoolPref("webgl.prefer_gl");
     } catch (ex) { }
     return retval;
   }
 
   function restoreOldPrefs() {
-    setEnabledForAllSites(saved_enabled_for_all_sites);
+    setForceEnabled(saved_force_enabled);
     setPreferGL(saved_prefer_gl);
   }
 
   function getEnv(env) {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
     var envsvc = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
     var val = envsvc.get(env);
     if (val == "")
@@ -291,17 +291,17 @@ function start() {
         break;
     };
   };
 
   function runTestSuite() {
     var reporter = new Reporter();
 
     // set WebGL-related preferences needed to run WebGL tests
-    setEnabledForAllSites(true);
+    setForceEnabled(true);
 
     // XXX temporary hack. Until the DirectX runtime is deployed on test slaves, we just use OpenGL,
     // so that rel-eng can safely deploy DirectX runtime without getting sudden mochitest failures
     // (e.g. if there's a ANGLE bug).
     setPreferGL(true);
 
     // try to create a dummy WebGL context, just to catch context creation failures once here,
     // rather than having them result in 100's of failures (one in each test page)
@@ -378,17 +378,17 @@ function start() {
     } catch (ex) { }
     if (!is106orHigher) {
       dump("WebGL mochitest disabled on Mac OSX versions older than 10.6");
       SimpleTest.finish();
       return;
     }
   }
 
-  var saved_enabled_for_all_sites = getEnabledForAllSites();
+  var saved_force_enabled = getForceEnabled();
   var saved_prefer_gl = getPreferGL();
 
   var statusElem = document.getElementById("status");
   var statusTextNode = document.createTextNode('');
   statusElem.appendChild(statusTextNode);
 
   var expectedtofailElem = document.getElementById("expectedtofail");
   var expectedtofailTextNode = document.createTextNode('');
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3203,20 +3203,20 @@ pref("image.mem.decode_bytes_at_a_time",
 
 // The longest time we can spend in an iteration of an async decode
 pref("image.mem.max_ms_before_yield", 400);
 
 // The maximum source data size for which we auto sync decode
 pref("image.mem.max_bytes_for_sync_decode", 150000);
 
 // WebGL prefs
-pref("webgl.enabled_for_all_sites", true);
+pref("webgl.force-enabled", false);
+pref("webgl.disabled", false);
 pref("webgl.shader_validator", true);
 pref("webgl.force_osmesa", false);
-pref("webgl.mochitest_native_gl", false);
 pref("webgl.osmesalib", "");
 pref("webgl.verbose", false);
 
 #ifdef XP_WIN
 #ifndef WINCE
 // The default TCP send window on Windows is too small, and autotuning only occurs on receive
 pref("network.tcp.sendbuffer", 131072);
 #endif