Bug 779535 - defaultNoAlpha preference is not used in case if nsIPropertyBag argument is 0. r=vlad
authorOleg Romashin <oleg.romashin@nokia.com>
Wed, 01 Aug 2012 11:58:44 -0700
changeset 101143 f0b216d9f512ad5af8fec073e22bd5c652342ffd
parent 101142 412282a35c2d1d743fed748d754db8dc43baad50
child 101144 8b0faad0630d74b7686e0dfa26d5c5863db46594
push id23217
push userryanvm@gmail.com
push dateThu, 02 Aug 2012 02:18:43 +0000
treeherdermozilla-central@61d7f15ea6a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs779535
milestone17.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 779535 - defaultNoAlpha preference is not used in case if nsIPropertyBag argument is 0. r=vlad
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContext.h
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -68,16 +68,25 @@ NS_NewCanvasRenderingContextWebGL(nsIDOM
     nsIDOMWebGLRenderingContext* ctx = new WebGLContext();
     if (!ctx)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(*aResult = ctx);
     return NS_OK;
 }
 
+WebGLContextOptions::WebGLContextOptions()
+    : depth(true), stencil(false),
+      premultipliedAlpha(true), antialias(true),
+      preserveDrawingBuffer(false)
+{
+    // Set default alpha state based on preference.
+    alpha = Preferences::GetBool("webgl.default-no-alpha", false) ? 0 : 1;
+}
+
 WebGLContext::WebGLContext()
     : gl(nullptr)
 {
     SetIsDOMBinding();
     mExtensions.SetLength(WebGLExtensionID_number_of_extensions);
 
     mGeneration = 0;
     mInvalidated = false;
@@ -284,32 +293,24 @@ GetBoolFromPropertyBag(nsIPropertyBag *b
 }
 
 NS_IMETHODIMP
 WebGLContext::SetContextOptions(nsIPropertyBag *aOptions)
 {
     if (!aOptions)
         return NS_OK;
 
-    bool defaultNoAlpha =
-        Preferences::GetBool("webgl.default-no-alpha", false);
-
     WebGLContextOptions newOpts;
 
     GetBoolFromPropertyBag(aOptions, "stencil", &newOpts.stencil);
     GetBoolFromPropertyBag(aOptions, "depth", &newOpts.depth);
     GetBoolFromPropertyBag(aOptions, "premultipliedAlpha", &newOpts.premultipliedAlpha);
     GetBoolFromPropertyBag(aOptions, "antialias", &newOpts.antialias);
     GetBoolFromPropertyBag(aOptions, "preserveDrawingBuffer", &newOpts.preserveDrawingBuffer);
-
-    // alpha defaults to true as per the spec, but we want to evaluate
-    // what will happen if it were to default to false based on a pref
-    if (!GetBoolFromPropertyBag(aOptions, "alpha", &newOpts.alpha) && defaultNoAlpha) {
-        newOpts.alpha = false;
-    }
+    GetBoolFromPropertyBag(aOptions, "alpha", &newOpts.alpha);
 
     // enforce that if stencil is specified, we also give back depth
     newOpts.depth |= newOpts.stencil;
 
 #if 0
     GenerateWarning("aaHint: %d stencil: %d depth: %d alpha: %d premult: %d preserve: %d\n",
                newOpts.antialias ? 1 : 0,
                newOpts.stencil ? 1 : 0,
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -419,21 +419,17 @@ public:
 
 protected:
     WebGLsizei mWidth;
     WebGLsizei mHeight;
 };
 
 struct WebGLContextOptions {
     // these are defaults
-    WebGLContextOptions()
-        : alpha(true), depth(true), stencil(false),
-          premultipliedAlpha(true), antialias(true),
-          preserveDrawingBuffer(false)
-    { }
+    WebGLContextOptions();
 
     bool operator==(const WebGLContextOptions& other) const {
         return
             alpha == other.alpha &&
             depth == other.depth &&
             stencil == other.stencil &&
             premultipliedAlpha == other.premultipliedAlpha &&
             antialias == other.antialias &&