From e9cf37db6a6377d2f7d6d36292a00eb25da82676 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Fri, 28 Jan 2011 21:12:24 -0500 Subject: [PATCH] Bug 628403 - introduce webgl.force-enabled and webgl.disabled prefs - r=vlad, a=joe --- content/canvas/src/WebGLContext.cpp | 5 +++-- content/canvas/src/WebGLContextUtils.cpp | 6 +++--- .../webgl/test_webgl_conformance_test_suite.html | 14 +++++++------- modules/libpref/src/init/all.js | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index 8121f0adc45..4bd15a62f7c 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -402,10 +402,11 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height) 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; } @@ -415,7 +416,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height) PRBool useANGLE = PR_TRUE; nsCOMPtr 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) { diff --git a/content/canvas/src/WebGLContextUtils.cpp b/content/canvas/src/WebGLContextUtils.cpp index 1cb990cd7b3..246ff9c5b40 100644 --- a/content/canvas/src/WebGLContextUtils.cpp +++ b/content/canvas/src/WebGLContextUtils.cpp @@ -89,9 +89,9 @@ WebGLContext::SafeToCreateCanvas3DContext(nsHTMLCanvasElement *canvasElement) nsCOMPtr 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; } diff --git a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html index e62ad82b3ea..36b5faf54a9 100644 --- a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html +++ b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html @@ -45,14 +45,14 @@ function start() { 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) { @@ -70,7 +70,7 @@ function start() { } function restoreOldPrefs() { - setEnabledForAllSites(saved_enabled_for_all_sites); + setForceEnabled(saved_force_enabled); setPreferGL(saved_prefer_gl); } @@ -296,7 +296,7 @@ function start() { 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 @@ -383,7 +383,7 @@ function start() { } } - var saved_enabled_for_all_sites = getEnabledForAllSites(); + var saved_force_enabled = getForceEnabled(); var saved_prefer_gl = getPreferGL(); var statusElem = document.getElementById("status"); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 36e5bddeece..1dccc539b31 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3208,10 +3208,10 @@ pref("image.mem.max_ms_before_yield", 400); 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);