From 8e9569f9956740718d6b7c4f092171cc4615ed86 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Mon, 31 Oct 2011 16:55:00 -0700 Subject: [PATCH] Bug 697168 - Removes WebGL overloads for untyped ArrayBuffers where disallowed - r=bjacob --- content/canvas/src/CustomQS_WebGL.h | 25 +++------- content/canvas/src/WebGLContextGL.cpp | 50 +------------------ .../canvas/nsIDOMWebGLRenderingContext.idl | 8 --- 3 files changed, 8 insertions(+), 75 deletions(-) diff --git a/content/canvas/src/CustomQS_WebGL.h b/content/canvas/src/CustomQS_WebGL.h index 6066919222b..2447ae70ef9 100644 --- a/content/canvas/src/CustomQS_WebGL.h +++ b/content/canvas/src/CustomQS_WebGL.h @@ -259,10 +259,7 @@ nsIDOMWebGLRenderingContext_ReadPixels(JSContext *cx, uintN argc, jsval *vp) !JSVAL_IS_PRIMITIVE(argv[6])) { JSObject *argv6 = JSVAL_TO_OBJECT(argv[6]); - if (js_IsArrayBuffer(argv6)) { - rv = self->ReadPixels_buf(argv0, argv1, argv2, argv3, - argv4, argv5, js::ArrayBuffer::getArrayBuffer(argv6)); - } else if (js_IsTypedArray(argv6)) { + if (js_IsTypedArray(argv6)) { rv = self->ReadPixels_array(argv0, argv1, argv2, argv3, argv4, argv5, js::TypedArray::getTypedArray(argv6)); @@ -380,15 +377,11 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, uintN argc, jsval *vp) JSObject *argv8 = JSVAL_TO_OBJECT(argv[8]); - // then try to grab either a js::ArrayBuffer, js::TypedArray, or null + // then try to grab either a js::TypedArray, or null if (argv8 == nsnull) { - rv = self->TexImage2D_buf(argv0, argv1, argv2, argv3, - argv4, argv5, argv6, argv7, - nsnull); - } else if (js_IsArrayBuffer(argv8)) { - rv = self->TexImage2D_buf(argv0, argv1, argv2, argv3, - argv4, argv5, argv6, argv7, - js::ArrayBuffer::getArrayBuffer(argv8)); + rv = self->TexImage2D_array(argv0, argv1, argv2, argv3, + argv4, argv5, argv6, argv7, + nsnull); } else if (js_IsTypedArray(argv8)) { rv = self->TexImage2D_array(argv0, argv1, argv2, argv3, argv4, argv5, argv6, argv7, @@ -503,12 +496,8 @@ nsIDOMWebGLRenderingContext_TexSubImage2D(JSContext *cx, uintN argc, jsval *vp) GET_UINT32_ARG(argv7, 7); JSObject *argv8 = JSVAL_TO_OBJECT(argv[8]); - // try to grab either a js::ArrayBuffer or js::TypedArray - if (js_IsArrayBuffer(argv8)) { - rv = self->TexSubImage2D_buf(argv0, argv1, argv2, argv3, - argv4, argv5, argv6, argv7, - js::ArrayBuffer::getArrayBuffer(argv8)); - } else if (js_IsTypedArray(argv8)) { + // try to grab a js::TypedArray + if (js_IsTypedArray(argv8)) { rv = self->TexSubImage2D_array(argv0, argv1, argv2, argv3, argv4, argv5, argv6, argv7, js::TypedArray::getTypedArray(argv8)); diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index fda015fa205..b24ce744a31 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -3532,18 +3532,6 @@ WebGLContext::ReadPixels_array(WebGLint x, WebGLint y, WebGLsizei width, WebGLsi pixels ? JS_GetTypedArrayByteLength(pixels) : 0); } -NS_IMETHODIMP -WebGLContext::ReadPixels_buf(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei height, - WebGLenum format, WebGLenum type, JSObject *pixels) -{ - if (mContextLost) - return NS_OK; - - return ReadPixels_base(x, y, width, height, format, type, - pixels ? JS_GetArrayBufferData(pixels) : 0, - pixels ? JS_GetArrayBufferByteLength(pixels) : 0); -} - NS_IMETHODIMP WebGLContext::RenderbufferStorage(WebGLenum target, WebGLenum internalformat, WebGLsizei width, WebGLsizei height) { @@ -4910,22 +4898,6 @@ WebGLContext::TexImage2D_base(WebGLenum target, WebGLint level, WebGLenum intern return NS_OK; } -NS_IMETHODIMP -WebGLContext::TexImage2D_buf(WebGLenum target, WebGLint level, WebGLenum internalformat, - WebGLsizei width, WebGLsizei height, WebGLint border, - WebGLenum format, WebGLenum type, - JSObject *pixels) -{ - if (mContextLost) - return NS_OK; - - return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type, - pixels ? JS_GetArrayBufferData(pixels) : 0, - pixels ? JS_GetArrayBufferByteLength(pixels) : 0, - -1, - WebGLTexelFormat::Auto, false); -} - NS_IMETHODIMP WebGLContext::TexImage2D_array(WebGLenum target, WebGLint level, WebGLenum internalformat, WebGLsizei width, WebGLsizei height, WebGLint border, @@ -4938,7 +4910,7 @@ WebGLContext::TexImage2D_array(WebGLenum target, WebGLint level, WebGLenum inter return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type, pixels ? JS_GetTypedArrayData(pixels) : 0, pixels ? JS_GetTypedArrayByteLength(pixels) : 0, - (int) JS_GetTypedArrayType(pixels), + pixels ? (int)JS_GetTypedArrayType(pixels) : -1, WebGLTexelFormat::Auto, false); } @@ -5106,26 +5078,6 @@ WebGLContext::TexSubImage2D_base(WebGLenum target, WebGLint level, return NS_OK; } -NS_IMETHODIMP -WebGLContext::TexSubImage2D_buf(WebGLenum target, WebGLint level, - WebGLint xoffset, WebGLint yoffset, - WebGLsizei width, WebGLsizei height, - WebGLenum format, WebGLenum type, - JSObject *pixels) -{ - if (mContextLost) - return NS_OK; - - if (!pixels) - return ErrorInvalidValue("TexSubImage2D: pixels must not be null!"); - - return TexSubImage2D_base(target, level, xoffset, yoffset, - width, height, 0, format, type, - JS_GetArrayBufferData(pixels), JS_GetArrayBufferByteLength(pixels), - -1, - WebGLTexelFormat::Auto, false); -} - NS_IMETHODIMP WebGLContext::TexSubImage2D_array(WebGLenum target, WebGLint level, WebGLint xoffset, WebGLint yoffset, diff --git a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl index 7962227f269..dfaedd91c21 100644 --- a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl +++ b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl @@ -735,8 +735,6 @@ interface nsIDOMWebGLRenderingContext : nsISupports void readPixels([optional] in long dummy); [noscript] void readPixels_array(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height, in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels); - [noscript] void readPixels_buf(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height, - in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels); //void glReleaseShaderCompiler(); @@ -755,9 +753,6 @@ interface nsIDOMWebGLRenderingContext : nsISupports void stencilOpSeparate(in WebGLenum face, in WebGLenum fail, in WebGLenum zfail, in WebGLenum zpass); void texImage2D([optional] in long dummy); - [noscript] void texImage2D_buf(in WebGLenum target, in WebGLint level, in WebGLenum internalformat, - in WebGLsizei width, in WebGLsizei height, - in WebGLint border, in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels); [noscript] void texImage2D_array(in WebGLenum target, in WebGLint level, in WebGLenum internalformat, in WebGLsizei width, in WebGLsizei height, in WebGLint border, in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels); @@ -770,9 +765,6 @@ interface nsIDOMWebGLRenderingContext : nsISupports in WebGLenum format, in WebGLenum type, in nsIDOMElement element); void texSubImage2D([optional] in long dummy); - [noscript] void texSubImage2D_buf(in WebGLenum target, in WebGLint level, - in WebGLint xoffset, in WebGLint yoffset, in WebGLsizei width, in WebGLsizei height, - in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels); [noscript] void texSubImage2D_array(in WebGLenum target, in WebGLint level, in WebGLint xoffset, in WebGLint yoffset, in WebGLsizei width, in WebGLsizei height, in WebGLenum format, in WebGLenum type, in WebGLJSObjectPtr pixels);