Bug 736481 - 3/7 - Add missing checks for lost WebGL contexts - r=jgilbert, a=blocking-fennec
authorBenoit Jacob <bjacob@mozilla.com>
Sat, 21 Apr 2012 16:48:22 -0400
changeset 95393 ac74798eb3d3741b7b0e0b05ef0c63d68596647c
parent 95392 9528f37307f3788463f8f59bce0a6e0b63b72088
child 95394 1f0b1c587cd6ef839bc24f5329ed9b0d606d9cfe
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, blocking-fennec
bugs736481
milestone14.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 736481 - 3/7 - Add missing checks for lost WebGL contexts - r=jgilbert, a=blocking-fennec
content/canvas/src/WebGLContextGL.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -199,16 +199,19 @@ WebGLContext::BindAttribLocation(nsIWebG
     MakeContextCurrent();
     gl->fBindAttribLocation(progname, location, mappedName.get());
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
 {
+    if (!IsContextStable())
+        return NS_OK;
+
     WebGLuint bufname;
     WebGLBuffer* buf;
     bool isNull; // allow null objects
     bool isDeleted; // allow deleted objects
     if (!GetConcreteObjectAndGLName("bindBuffer", bobj, &buf, &bufname, &isNull, &isDeleted))
         return NS_OK;
 
     // silently ignore a deleted buffer
@@ -241,16 +244,19 @@ WebGLContext::BindBuffer(WebGLenum targe
     gl->fBindBuffer(target, bufname);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj)
 {
+    if (!IsContextStable())
+        return NS_OK;
+
     WebGLuint framebuffername;
     bool isNull; // allow null objects
     bool isDeleted; // allow deleted objects
     WebGLFramebuffer *wfb;
 
     if (target != LOCAL_GL_FRAMEBUFFER)
         return ErrorInvalidEnum("BindFramebuffer: target must be GL_FRAMEBUFFER");
 
@@ -273,16 +279,19 @@ WebGLContext::BindFramebuffer(WebGLenum 
     mBoundFramebuffer = wfb;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj)
 {
+    if (!IsContextStable())
+        return NS_OK;
+
     WebGLuint renderbuffername;
     bool isNull; // allow null objects
     bool isDeleted; // allow deleted objects
     WebGLRenderbuffer *wrb;
 
     if (target != LOCAL_GL_RENDERBUFFER)
         return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
 
@@ -303,16 +312,19 @@ WebGLContext::BindRenderbuffer(WebGLenum
     mBoundRenderbuffer = wrb;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindTexture(WebGLenum target, nsIWebGLTexture *tobj)
 {
+    if (!IsContextStable())
+        return NS_OK;
+
     WebGLuint texturename;
     WebGLTexture *tex;
     bool isNull; // allow null objects
     bool isDeleted; // allow deleted objects
     if (!GetConcreteObjectAndGLName("bindTexture", tobj, &tex, &texturename, &isNull, &isDeleted))
         return NS_OK;
 
     // silently ignore a deleted texture
@@ -583,16 +595,19 @@ WebGLContext::BufferData_array(WebGLenum
         return ErrorOutOfMemory("bufferData: out of memory");
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BufferSubData(PRInt32 target, PRInt32 offset, const JS::Value& data)
 {
+    if (!IsContextStable())
+        return NS_OK;
+
     if (data.isNull()) {
         // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386
         return NS_OK;
     }
 
     if (!data.isObject()) {
         return NS_ERROR_FAILURE;
     }
@@ -2070,21 +2085,21 @@ WebGLContext::GetAttribLocation(nsIWebGL
     MakeContextCurrent();
     *retval = gl->fGetAttribLocation(progname, mappedName.get());
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::GetParameter(PRUint32 pname, nsIVariant **retval)
 {
+    *retval = nsnull;
+
     if (!IsContextStable())
         return NS_OK;
 
-    *retval = nsnull;
-
     nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
     NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
 
     MakeContextCurrent();
     
     if (MinCapabilityMode()) {
         bool override = true;
         switch(pname) {
@@ -2838,21 +2853,21 @@ WebGLContext::TexParameteri(WebGLenum ta
         return NS_OK;
 
     return TexParameter_base(target, pname, &param, nsnull);
 }
 
 NS_IMETHODIMP
 WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname, nsIVariant **retval)
 {
+    *retval = nsnull;
+
     if (!IsContextStable())
         return NS_OK;
 
-    *retval = nsnull;
-
     MakeContextCurrent();
 
     if (!ValidateTextureTargetEnum(target, "getTexParameter: target"))
         return NS_OK;
 
     if (!activeBoundTextureForTarget(target))
         return ErrorInvalidOperation("getTexParameter: no texture bound");
 
@@ -2888,21 +2903,21 @@ WebGLContext::GetTexParameter(WebGLenum 
 
     return NS_OK;
 }
 
 /* any getUniform(in WebGLProgram program, in WebGLUniformLocation location) raises(DOMException); */
 NS_IMETHODIMP
 WebGLContext::GetUniform(nsIWebGLProgram *pobj, nsIWebGLUniformLocation *ploc, nsIVariant **retval)
 {
+    *retval = nsnull;
+
     if (!IsContextStable())
         return NS_OK;
 
-    *retval = nsnull;
-
     WebGLuint progname;
     WebGLProgram *prog;
     if (!GetConcreteObjectAndGLName("getUniform: program", pobj, &prog, &progname))
         return NS_OK;
 
     WebGLUniformLocation *location;
     if (!GetConcreteObject("getUniform: location", ploc, &location))
         return NS_OK;
@@ -3046,21 +3061,21 @@ WebGLContext::GetUniformLocation(nsIWebG
     }
     *retval = loc;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::GetVertexAttrib(WebGLuint index, WebGLenum pname, nsIVariant **retval)
 {
+    *retval = nsnull;
+
     if (!IsContextStable())
         return NS_OK;
 
-    *retval = nsnull;
-
     if (!ValidateAttribIndex(index, "getVertexAttrib"))
         return NS_OK;
 
     nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
     NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
 
     MakeContextCurrent();