From 79d282af260d91f966c728a2504a27eb351eec9c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 16 Mar 2012 10:50:18 +0100 Subject: [PATCH] Bug 722154 - Part b: Remove custom quickstub for bufferSubData; r=bjacob --- content/canvas/src/CustomQS_WebGL.h | 73 ------------------- content/canvas/src/WebGLContext.h | 3 + content/canvas/src/WebGLContextGL.cpp | 32 ++++---- .../canvas/nsIDOMWebGLRenderingContext.idl | 7 +- js/xpconnect/src/dom_quickstubs.qsconf | 1 - 5 files changed, 24 insertions(+), 92 deletions(-) diff --git a/content/canvas/src/CustomQS_WebGL.h b/content/canvas/src/CustomQS_WebGL.h index cb4065342456..8a4bb51892e8 100644 --- a/content/canvas/src/CustomQS_WebGL.h +++ b/content/canvas/src/CustomQS_WebGL.h @@ -77,79 +77,6 @@ helper_isFloat32Array(JSObject *obj) { return js::GetObjectClass(obj) == &js::TypedArray::fastClasses[js::TypedArray::TYPE_FLOAT32]; } -/* - * BufferSubData takes: - * BufferSubData (int, int, js::ArrayBuffer *) - * BufferSubData_array (int, int, js::TypedArray *) - */ -static JSBool -nsIDOMWebGLRenderingContext_BufferSubData(JSContext *cx, unsigned argc, jsval *vp) -{ - XPC_QS_ASSERT_CONTEXT_OK(cx); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - if (!obj) - return JS_FALSE; - - nsIDOMWebGLRenderingContext *self; - xpc_qsSelfRef selfref; - JS::AutoValueRooter tvr(cx); - if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nsnull)) - return JS_FALSE; - - if (argc < 3) - return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS); - - jsval *argv = JS_ARGV(cx, vp); - - int32_t target; - int32_t offset; - JSObject *wa = 0; - JSObject *wb = 0; - - if (!JS_ValueToECMAInt32(cx, argv[0], &target)) - return JS_FALSE; - if (!JS_ValueToECMAInt32(cx, argv[1], &offset)) - return JS_FALSE; - - if (!JSVAL_IS_OBJECT(argv[2])) { - xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 2); - return JS_FALSE; - } - - JSBool nullobject = JSVAL_IS_NULL(argv[2]); - - if (!nullobject) { - JSObject *arg3 = JSVAL_TO_OBJECT(argv[2]); - if (js_IsArrayBuffer(arg3)) { - wb = js::ArrayBuffer::getArrayBuffer(arg3); - } else if (js_IsTypedArray(arg3)) { - wa = js::TypedArray::getTypedArray(arg3); - } else { - xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 2); - return JS_FALSE; - } - } - - nsresult rv; - - if (wa) { - rv = self->BufferSubData_array(target, offset, wa); - } else if (wb) { - rv = self->BufferSubData_buf(target, offset, wb); - } else if (nullobject) { - rv = self->BufferSubData_null(); - } else { - xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 2); - return JS_FALSE; - } - - if (NS_FAILED(rv)) - return xpc_qsThrowMethodFailed(cx, rv, vp); - - *vp = JSVAL_VOID; - return JS_TRUE; -} - /* * CompressedTexImage2D takes: * CompressedTexImage2D(uint, int, uint, int, int, int, ArrayBufferView) diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 187684015b15..7acb3b9eb564 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -692,6 +692,9 @@ protected: nsresult BufferData_buf(WebGLenum target, JSObject* data, WebGLenum usage); nsresult BufferData_array(WebGLenum target, JSObject* data, WebGLenum usage); + nsresult BufferSubData_buf(WebGLenum target, PRInt32 offset, JSObject* data); + nsresult BufferSubData_array(WebGLenum target, PRInt32 offset, JSObject* data); + nsCOMPtr mCanvasElement; nsHTMLCanvasElement *HTMLCanvasElement() { return static_cast(mCanvasElement.get()); diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index ece07bf0fe52..03eeca720f7e 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -585,24 +585,30 @@ WebGLContext::BufferData_array(WebGLenum target, JSObject *wa, WebGLenum usage) } NS_IMETHODIMP -WebGLContext::BufferSubData(PRInt32) +WebGLContext::BufferSubData(PRInt32 target, PRInt32 offset, const JS::Value& data) { - if (!IsContextStable()) + if (data.isNull()) { + // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386 return NS_OK; + } + + if (!data.isObject()) { + return NS_ERROR_FAILURE; + } + + JSObject& dataObj = data.toObject(); + if (js_IsArrayBuffer(&dataObj)) { + return BufferSubData_buf(target, offset, &dataObj); + } + + if (js_IsTypedArray(&dataObj)) { + return BufferSubData_array(target, offset, &dataObj); + } return NS_ERROR_FAILURE; } -NS_IMETHODIMP -WebGLContext::BufferSubData_null() -{ - if (!IsContextStable()) - return NS_OK; - - return NS_OK; // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386 -} - -NS_IMETHODIMP +nsresult WebGLContext::BufferSubData_buf(GLenum target, WebGLsizei byteOffset, JSObject *wb) { if (!IsContextStable()) @@ -642,7 +648,7 @@ WebGLContext::BufferSubData_buf(GLenum target, WebGLsizei byteOffset, JSObject * return NS_OK; } -NS_IMETHODIMP +nsresult WebGLContext::BufferSubData_array(WebGLenum target, WebGLsizei byteOffset, JSObject *wa) { if (!IsContextStable()) diff --git a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl index 70848aba76d5..ae7288b22e45 100644 --- a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl +++ b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl @@ -177,7 +177,7 @@ interface nsIWebGLExtensionTextureFilterAnisotropic : nsIWebGLExtension const WebGLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; }; -[scriptable, builtinclass, uuid(c0d5f7cb-91ad-433c-a426-a701e06d4413)] +[scriptable, builtinclass, uuid(cabad79d-222c-40d1-a746-4942278c0bba)] interface nsIDOMWebGLRenderingContext : nsISupports { // @@ -624,10 +624,7 @@ interface nsIDOMWebGLRenderingContext : nsISupports // Modified: void glBufferData(WebGLenum target, long size, const void* data, WebGLenum usage); [implicit_jscontext] void bufferData(in long target, in jsval data, in long usage); - void bufferSubData([optional] in long dummy); - [noscript] void bufferSubData_buf(in WebGLenum target, in long offset, in WebGLJSObjectPtr data); - [noscript] void bufferSubData_array(in WebGLenum target, in long offset, in WebGLJSObjectPtr data); - [noscript] void bufferSubData_null(); + void bufferSubData(in long target, in long offset, in jsval data); WebGLenum checkFramebufferStatus(in WebGLenum target); void clear(in WebGLbitfield mask); diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 6f89ca05a26a..7ff11f06dba2 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -978,7 +978,6 @@ customMethodCalls = { 'unwrapThisFailureFatal' : False }, # WebGL - 'nsIDOMWebGLRenderingContext_BufferSubData': CUSTOM_QS, 'nsIDOMWebGLRenderingContext_ReadPixels': CUSTOM_QS, 'nsIDOMWebGLRenderingContext_TexImage2D': CUSTOM_QS, 'nsIDOMWebGLRenderingContext_TexSubImage2D': CUSTOM_QS,