Bug 736481 - 3/7 - Add missing checks for lost WebGL contexts - r=jgilbert, a=blocking-fennec

This commit is contained in:
Benoit Jacob 2012-04-21 16:48:22 -04:00
parent 9cf9a2137b
commit 46b8e1d691

View File

@ -204,6 +204,9 @@ WebGLContext::BindAttribLocation(nsIWebGLProgram *pobj, WebGLuint location, cons
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj) WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
{ {
if (!IsContextStable())
return NS_OK;
WebGLuint bufname; WebGLuint bufname;
WebGLBuffer* buf; WebGLBuffer* buf;
bool isNull; // allow null objects bool isNull; // allow null objects
@ -246,6 +249,9 @@ WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj) WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj)
{ {
if (!IsContextStable())
return NS_OK;
WebGLuint framebuffername; WebGLuint framebuffername;
bool isNull; // allow null objects bool isNull; // allow null objects
bool isDeleted; // allow deleted objects bool isDeleted; // allow deleted objects
@ -278,6 +284,9 @@ WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj)
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj) WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj)
{ {
if (!IsContextStable())
return NS_OK;
WebGLuint renderbuffername; WebGLuint renderbuffername;
bool isNull; // allow null objects bool isNull; // allow null objects
bool isDeleted; // allow deleted objects bool isDeleted; // allow deleted objects
@ -308,6 +317,9 @@ WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj)
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::BindTexture(WebGLenum target, nsIWebGLTexture *tobj) WebGLContext::BindTexture(WebGLenum target, nsIWebGLTexture *tobj)
{ {
if (!IsContextStable())
return NS_OK;
WebGLuint texturename; WebGLuint texturename;
WebGLTexture *tex; WebGLTexture *tex;
bool isNull; // allow null objects bool isNull; // allow null objects
@ -588,6 +600,9 @@ WebGLContext::BufferData_array(WebGLenum target, JSObject *wa, WebGLenum usage)
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::BufferSubData(PRInt32 target, PRInt32 offset, const JS::Value& data) WebGLContext::BufferSubData(PRInt32 target, PRInt32 offset, const JS::Value& data)
{ {
if (!IsContextStable())
return NS_OK;
if (data.isNull()) { if (data.isNull()) {
// see http://www.khronos.org/bugzilla/show_bug.cgi?id=386 // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386
return NS_OK; return NS_OK;
@ -2075,11 +2090,11 @@ WebGLContext::GetAttribLocation(nsIWebGLProgram *pobj,
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::GetParameter(PRUint32 pname, nsIVariant **retval) WebGLContext::GetParameter(PRUint32 pname, nsIVariant **retval)
{ {
*retval = nsnull;
if (!IsContextStable()) if (!IsContextStable())
return NS_OK; return NS_OK;
*retval = nsnull;
nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1"); nsCOMPtr<nsIWritableVariant> wrval = do_CreateInstance("@mozilla.org/variant;1");
NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE); NS_ENSURE_TRUE(wrval, NS_ERROR_FAILURE);
@ -2843,11 +2858,11 @@ WebGLContext::TexParameteri(WebGLenum target, WebGLenum pname, WebGLint param)
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname, nsIVariant **retval) WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname, nsIVariant **retval)
{ {
*retval = nsnull;
if (!IsContextStable()) if (!IsContextStable())
return NS_OK; return NS_OK;
*retval = nsnull;
MakeContextCurrent(); MakeContextCurrent();
if (!ValidateTextureTargetEnum(target, "getTexParameter: target")) if (!ValidateTextureTargetEnum(target, "getTexParameter: target"))
@ -2893,11 +2908,11 @@ WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname, nsIVariant **re
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::GetUniform(nsIWebGLProgram *pobj, nsIWebGLUniformLocation *ploc, nsIVariant **retval) WebGLContext::GetUniform(nsIWebGLProgram *pobj, nsIWebGLUniformLocation *ploc, nsIVariant **retval)
{ {
*retval = nsnull;
if (!IsContextStable()) if (!IsContextStable())
return NS_OK; return NS_OK;
*retval = nsnull;
WebGLuint progname; WebGLuint progname;
WebGLProgram *prog; WebGLProgram *prog;
if (!GetConcreteObjectAndGLName("getUniform: program", pobj, &prog, &progname)) if (!GetConcreteObjectAndGLName("getUniform: program", pobj, &prog, &progname))
@ -3051,11 +3066,11 @@ WebGLContext::GetUniformLocation(nsIWebGLProgram *pobj, const nsAString& name, n
NS_IMETHODIMP NS_IMETHODIMP
WebGLContext::GetVertexAttrib(WebGLuint index, WebGLenum pname, nsIVariant **retval) WebGLContext::GetVertexAttrib(WebGLuint index, WebGLenum pname, nsIVariant **retval)
{ {
*retval = nsnull;
if (!IsContextStable()) if (!IsContextStable())
return NS_OK; return NS_OK;
*retval = nsnull;
if (!ValidateAttribIndex(index, "getVertexAttrib")) if (!ValidateAttribIndex(index, "getVertexAttrib"))
return NS_OK; return NS_OK;