diff --git a/content/canvas/src/CustomQS_Canvas2D.h b/content/canvas/src/CustomQS_Canvas2D.h index aec70a86af8e..62300524e5b7 100644 --- a/content/canvas/src/CustomQS_Canvas2D.h +++ b/content/canvas/src/CustomQS_Canvas2D.h @@ -187,13 +187,13 @@ CreateImageData(JSContext* cx, } if (self) { - JSObject *tdest = js::TypedArray::getTypedArray(darray); + js::TypedArray* tdest = js::TypedArray::fromJSObject(darray); // make the call nsresult rv = self->GetImageData_explicit(x, y, w, h, - static_cast(JS_GetTypedArrayData(tdest)), - JS_GetTypedArrayByteLength(tdest)); + static_cast(tdest->data), + tdest->byteLength); if (NS_FAILED(rv)) { return xpc_qsThrowMethodFailed(cx, rv, vp); } @@ -416,11 +416,11 @@ nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp js::AutoValueRooter tsrc_tvr(cx); - JSObject *tsrc = NULL; + js::TypedArray *tsrc = NULL; if (darray->getClass() == &js::TypedArray::fastClasses[js::TypedArray::TYPE_UINT8] || darray->getClass() == &js::TypedArray::fastClasses[js::TypedArray::TYPE_UINT8_CLAMPED]) { - tsrc = js::TypedArray::getTypedArray(darray); + tsrc = js::TypedArray::fromJSObject(darray); } else if (JS_IsArrayObject(cx, darray) || js_IsTypedArray(darray)) { // ugh, this isn't a uint8 typed array, someone made their own object; convert it to a typed array JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_UINT8, darray); @@ -428,14 +428,14 @@ nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp return JS_FALSE; *tsrc_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - tsrc = js::TypedArray::getTypedArray(nobj); + tsrc = js::TypedArray::fromJSObject(nobj); } else { // yeah, no. return xpc_qsThrow(cx, NS_ERROR_DOM_TYPE_MISMATCH_ERR); } // make the call - rv = self->PutImageData_explicit(x, y, w, h, (PRUint8*) JS_GetTypedArrayData(tsrc), JS_GetTypedArrayByteLength(tsrc), hasDirtyRect, dirtyX, dirtyY, dirtyWidth, dirtyHeight); + rv = self->PutImageData_explicit(x, y, w, h, (PRUint8*) tsrc->data, tsrc->byteLength, hasDirtyRect, dirtyX, dirtyY, dirtyWidth, dirtyHeight); if (NS_FAILED(rv)) return xpc_qsThrowMethodFailed(cx, rv, vp); diff --git a/content/canvas/src/CustomQS_WebGL.h b/content/canvas/src/CustomQS_WebGL.h index 94ddfe8e3a3b..e0398734fb83 100644 --- a/content/canvas/src/CustomQS_WebGL.h +++ b/content/canvas/src/CustomQS_WebGL.h @@ -101,7 +101,7 @@ nsIDOMWebGLRenderingContext_BufferData(JSContext *cx, uintN argc, jsval *vp) jsval *argv = JS_ARGV(cx, vp); int32 target; - JSObject *wa = 0; + js::TypedArray *wa = 0; JSObject *wb = 0; int32 size; int32 usage; @@ -120,7 +120,7 @@ nsIDOMWebGLRenderingContext_BufferData(JSContext *cx, uintN argc, jsval *vp) if (js_IsArrayBuffer(arg2)) { wb = js::ArrayBuffer::getArrayBuffer(arg2); } else if (js_IsTypedArray(arg2)) { - wa = js::TypedArray::getTypedArray(arg2); + wa = js::TypedArray::fromJSObject(arg2); } } @@ -175,7 +175,7 @@ nsIDOMWebGLRenderingContext_BufferSubData(JSContext *cx, uintN argc, jsval *vp) int32 target; int32 offset; - JSObject *wa = 0; + js::TypedArray *wa = 0; JSObject *wb = 0; if (!JS_ValueToECMAInt32(cx, argv[0], &target)) @@ -195,7 +195,7 @@ nsIDOMWebGLRenderingContext_BufferSubData(JSContext *cx, uintN argc, jsval *vp) if (js_IsArrayBuffer(arg3)) { wb = js::ArrayBuffer::getArrayBuffer(arg3); } else if (js_IsTypedArray(arg3)) { - wa = js::TypedArray::getTypedArray(arg3); + wa = js::TypedArray::fromJSObject(arg3); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 2); return JS_FALSE; @@ -265,7 +265,7 @@ nsIDOMWebGLRenderingContext_ReadPixels(JSContext *cx, uintN argc, jsval *vp) } else if (js_IsTypedArray(argv6)) { rv = self->ReadPixels_array(argv0, argv1, argv2, argv3, argv4, argv5, - js::TypedArray::getTypedArray(argv6)); + js::TypedArray::fromJSObject(argv6)); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6); return JS_FALSE; @@ -365,7 +365,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, uintN argc, jsval *vp) } rv = self->TexImage2D_imageData(argv0, argv1, argv2, int_width, int_height, 0, - argv3, argv4, js::TypedArray::getTypedArray(obj_data)); + argv3, argv4, js::TypedArray::fromJSObject(obj_data)); } } else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) // here, we allow null ! @@ -392,7 +392,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, uintN argc, jsval *vp) } else if (js_IsTypedArray(argv8)) { rv = self->TexImage2D_array(argv0, argv1, argv2, argv3, argv4, argv5, argv6, argv7, - js::TypedArray::getTypedArray(argv8)); + js::TypedArray::fromJSObject(argv8)); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 8); return JS_FALSE; @@ -491,7 +491,7 @@ nsIDOMWebGLRenderingContext_TexSubImage2D(JSContext *cx, uintN argc, jsval *vp) rv = self->TexSubImage2D_imageData(argv0, argv1, argv2, argv3, int_width, int_height, argv4, argv5, - js::TypedArray::getTypedArray(obj_data)); + js::TypedArray::fromJSObject(obj_data)); } } else if (argc > 8 && !JSVAL_IS_PRIMITIVE(argv[8])) @@ -511,7 +511,7 @@ nsIDOMWebGLRenderingContext_TexSubImage2D(JSContext *cx, uintN argc, jsval *vp) } else if (js_IsTypedArray(argv8)) { rv = self->TexSubImage2D_array(argv0, argv1, argv2, argv3, argv4, argv5, argv6, argv7, - js::TypedArray::getTypedArray(argv8)); + js::TypedArray::fromJSObject(argv8)); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 8); return JS_FALSE; @@ -567,10 +567,10 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_iv(JSContext *cx, uintN argc, jsval js::AutoValueRooter obj_tvr(cx); - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isInt32Array(arg1)) { - wa = js::TypedArray::getTypedArray(arg1); + wa = js::TypedArray::fromJSObject(arg1); } else if (JS_IsArrayObject(cx, arg1)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_INT32, arg1); if (!nobj) { @@ -579,7 +579,7 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_iv(JSContext *cx, uintN argc, jsval } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1); return JS_FALSE; @@ -641,10 +641,10 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_fv(JSContext *cx, uintN argc, jsval js::AutoValueRooter obj_tvr(cx); - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isFloat32Array(arg1)) { - wa = js::TypedArray::getTypedArray(arg1); + wa = js::TypedArray::fromJSObject(arg1); } else if (JS_IsArrayObject(cx, arg1)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg1); if (!nobj) { @@ -653,7 +653,7 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_fv(JSContext *cx, uintN argc, jsval } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1); return JS_FALSE; @@ -717,10 +717,10 @@ helper_nsIDOMWebGLRenderingContext_UniformMatrix_x_fv(JSContext *cx, uintN argc, js::AutoValueRooter obj_tvr(cx); - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isFloat32Array(arg2)) { - wa = js::TypedArray::getTypedArray(arg2); + wa = js::TypedArray::fromJSObject(arg2); } else if (JS_IsArrayObject(cx, arg2)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg2); if (!nobj) { @@ -729,7 +729,7 @@ helper_nsIDOMWebGLRenderingContext_UniformMatrix_x_fv(JSContext *cx, uintN argc, } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 2); return JS_FALSE; @@ -782,10 +782,10 @@ helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(JSContext *cx, uintN argc, js::AutoValueRooter obj_tvr(cx); - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isFloat32Array(arg1)) { - wa = js::TypedArray::getTypedArray(arg1); + wa = js::TypedArray::fromJSObject(arg1); } else if (JS_IsArrayObject(cx, arg1)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg1); if (!nobj) { @@ -794,7 +794,7 @@ helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(JSContext *cx, uintN argc, } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1); return JS_FALSE; @@ -944,10 +944,10 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_iv_tn(JSContext *cx, JSObject *obj, return; } - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isInt32Array(arg)) { - wa = js::TypedArray::getTypedArray(arg); + wa = js::TypedArray::fromJSObject(arg); } else if (JS_IsArrayObject(cx, arg)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_INT32, arg); if (!nobj) { @@ -957,7 +957,7 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_iv_tn(JSContext *cx, JSObject *obj, } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsIDOMWebGLRenderingContext", "uniformNiv"); js_SetTraceableNativeFailed(cx); @@ -1015,10 +1015,10 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_fv_tn(JSContext *cx, JSObject *obj, return; } - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isFloat32Array(arg)) { - wa = js::TypedArray::getTypedArray(arg); + wa = js::TypedArray::fromJSObject(arg); } else if (JS_IsArrayObject(cx, arg)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg); if (!nobj) { @@ -1028,7 +1028,7 @@ helper_nsIDOMWebGLRenderingContext_Uniform_x_fv_tn(JSContext *cx, JSObject *obj, } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsIDOMWebGLRenderingContext", "uniformNfv"); js_SetTraceableNativeFailed(cx); @@ -1088,10 +1088,10 @@ helper_nsIDOMWebGLRenderingContext_UniformMatrix_x_fv_tn(JSContext *cx, JSObject return; } - JSObject *wa = 0; + js::TypedArray *wa = 0; if (helper_isFloat32Array(arg)) { - wa = js::TypedArray::getTypedArray(arg); + wa = js::TypedArray::fromJSObject(arg); } else if (JS_IsArrayObject(cx, arg)) { JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg); if (!nobj) { @@ -1101,7 +1101,7 @@ helper_nsIDOMWebGLRenderingContext_UniformMatrix_x_fv_tn(JSContext *cx, JSObject } *obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - wa = js::TypedArray::getTypedArray(nobj); + wa = js::TypedArray::fromJSObject(nobj); } else { xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsIDOMWebGLRenderingContext", "uniformMatrixNfv"); js_SetTraceableNativeFailed(cx); diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 8f91aeb0d732..275269865406 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -487,7 +487,7 @@ WebGLContext::BufferData_buf(WebGLenum target, JSObject *wb, WebGLenum usage) } NS_IMETHODIMP -WebGLContext::BufferData_array(WebGLenum target, JSObject *wa, WebGLenum usage) +WebGLContext::BufferData_array(WebGLenum target, js::TypedArray *wa, WebGLenum usage) { WebGLBuffer *boundBuffer = NULL; @@ -508,17 +508,17 @@ WebGLContext::BufferData_array(WebGLenum target, JSObject *wa, WebGLenum usage) MakeContextCurrent(); GLenum error = CheckedBufferData(target, - JS_GetTypedArrayByteLength(wa), - JS_GetTypedArrayData(wa), + wa->byteLength, + wa->data, usage); if (error) { LogMessageIfVerbose("bufferData generated error %s", ErrorName(error)); return NS_OK; } - boundBuffer->SetByteLength(JS_GetTypedArrayByteLength(wa)); + boundBuffer->SetByteLength(wa->byteLength); boundBuffer->InvalidateCachedMaxElements(); - if (!boundBuffer->CopyDataIfElementArray(JS_GetTypedArrayData(wa))) + if (!boundBuffer->CopyDataIfElementArray(wa->data)) return ErrorOutOfMemory("bufferData: out of memory"); return NS_OK; @@ -574,7 +574,7 @@ WebGLContext::BufferSubData_buf(GLenum target, WebGLsizei byteOffset, JSObject * } NS_IMETHODIMP -WebGLContext::BufferSubData_array(WebGLenum target, WebGLsizei byteOffset, JSObject *wa) +WebGLContext::BufferSubData_array(WebGLenum target, WebGLsizei byteOffset, js::TypedArray *wa) { WebGLBuffer *boundBuffer = NULL; @@ -592,20 +592,20 @@ WebGLContext::BufferSubData_array(WebGLenum target, WebGLsizei byteOffset, JSObj if (!boundBuffer) return ErrorInvalidOperation("BufferData: no buffer bound!"); - CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + JS_GetTypedArrayByteLength(wa); + CheckedUint32 checked_neededByteLength = CheckedUint32(byteOffset) + wa->byteLength; if (!checked_neededByteLength.valid()) return ErrorInvalidOperation("bufferSubData: integer overflow computing the needed byte length"); if (checked_neededByteLength.value() > boundBuffer->ByteLength()) return ErrorInvalidOperation("BufferSubData: not enough data -- operation requires %d bytes, but buffer only has %d bytes", - byteOffset, JS_GetTypedArrayByteLength(wa), boundBuffer->ByteLength()); + byteOffset, wa->byteLength, boundBuffer->ByteLength()); MakeContextCurrent(); - boundBuffer->CopySubDataIfElementArray(byteOffset, JS_GetTypedArrayByteLength(wa), JS_GetTypedArrayData(wa)); + boundBuffer->CopySubDataIfElementArray(byteOffset, wa->byteLength, wa->data); boundBuffer->InvalidateCachedMaxElements(); - gl->fBufferSubData(target, byteOffset, JS_GetTypedArrayByteLength(wa), JS_GetTypedArrayData(wa)); + gl->fBufferSubData(target, byteOffset, wa->byteLength, wa->data); return NS_OK; } @@ -3140,11 +3140,11 @@ WebGLContext::ReadPixels_base(WebGLint x, WebGLint y, WebGLsizei width, WebGLsiz NS_IMETHODIMP WebGLContext::ReadPixels_array(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei height, - WebGLenum format, WebGLenum type, JSObject *pixels) + WebGLenum format, WebGLenum type, js::TypedArray *pixels) { return ReadPixels_base(x, y, width, height, format, type, - pixels ? JS_GetTypedArrayData(pixels) : 0, - pixels ? JS_GetTypedArrayByteLength(pixels) : 0); + pixels ? pixels->data : 0, + pixels ? pixels->byteLength : 0); } NS_IMETHODIMP @@ -3661,15 +3661,15 @@ WebGLContext::name(PRInt32) { \ return NS_ERROR_NOT_IMPLEMENTED; \ } \ NS_IMETHODIMP \ -WebGLContext::name##_array(nsIWebGLUniformLocation *ploc, JSObject *wa) \ +WebGLContext::name##_array(nsIWebGLUniformLocation *ploc, js::TypedArray *wa) \ { \ OBTAIN_UNIFORM_LOCATION(#name ": location") \ - if (!wa || JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) \ + if (!wa || wa->type != js::TypedArray::arrayType) \ return ErrorInvalidOperation(#name ": array must be " #arrayType); \ - if (JS_GetTypedArrayLength(wa) == 0 || JS_GetTypedArrayLength(wa) % cnt != 0)\ + if (wa->length == 0 || wa->length % cnt != 0) \ return ErrorInvalidValue(#name ": array must be > 0 elements and have a length multiple of %d", cnt); \ MakeContextCurrent(); \ - gl->f##name(location, JS_GetTypedArrayLength(wa) / cnt, (ptrType *)JS_GetTypedArrayData(wa)); \ + gl->f##name(location, wa->length / cnt, (ptrType *)wa->data); \ return NS_OK; \ } @@ -3679,17 +3679,17 @@ WebGLContext::name(PRInt32) { \ return NS_ERROR_NOT_IMPLEMENTED; \ } \ NS_IMETHODIMP \ -WebGLContext::name##_array(nsIWebGLUniformLocation *ploc, WebGLboolean transpose, JSObject *wa) \ +WebGLContext::name##_array(nsIWebGLUniformLocation *ploc, WebGLboolean transpose, js::TypedArray *wa) \ { \ OBTAIN_UNIFORM_LOCATION(#name ": location") \ - if (!wa || JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) \ + if (!wa || wa->type != js::TypedArray::arrayType) \ return ErrorInvalidValue(#name ": array must be " #arrayType); \ - if (JS_GetTypedArrayLength(wa) == 0 || JS_GetTypedArrayLength(wa) % (dim*dim) != 0) \ + if (wa->length == 0 || wa->length % (dim*dim) != 0) \ return ErrorInvalidValue(#name ": array length must be >0 and multiple of %d", dim*dim); \ if (transpose) \ return ErrorInvalidValue(#name ": transpose must be FALSE as per the OpenGL ES 2.0 spec"); \ MakeContextCurrent(); \ - gl->f##name(location, JS_GetTypedArrayLength(wa) / (dim*dim), transpose, (ptrType *)JS_GetTypedArrayData(wa)); \ + gl->f##name(location, wa->length / (dim*dim), transpose, (ptrType *)wa->data); \ return NS_OK; \ } @@ -3824,14 +3824,14 @@ WebGLContext::name(PRInt32) { \ return NS_ERROR_NOT_IMPLEMENTED; \ } \ NS_IMETHODIMP \ -WebGLContext::name##_array(WebGLuint idx, JSObject *wa) \ +WebGLContext::name##_array(WebGLuint idx, js::TypedArray *wa) \ { \ - if (!wa || JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) \ + if (!wa || wa->type != js::TypedArray::arrayType) \ return ErrorInvalidOperation(#name ": array must be " #arrayType); \ - if (JS_GetTypedArrayLength(wa) < cnt) \ + if (wa->length < cnt) \ return ErrorInvalidOperation(#name ": array must be >= %d elements", cnt); \ MakeContextCurrent(); \ - ptrType *ptr = (ptrType *)JS_GetTypedArrayData(wa); \ + ptrType *ptr = (ptrType *)wa->data; \ if (idx) { \ gl->f##name(idx, ptr); \ } else { \ @@ -4428,12 +4428,12 @@ NS_IMETHODIMP WebGLContext::TexImage2D_array(WebGLenum target, WebGLint level, WebGLenum internalformat, WebGLsizei width, WebGLsizei height, WebGLint border, WebGLenum format, WebGLenum type, - JSObject *pixels) + js::TypedArray *pixels) { 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 ? pixels->data : 0, + pixels ? pixels->byteLength : 0, + (int) pixels->type, WebGLTexelFormat::Auto, PR_FALSE); } @@ -4441,11 +4441,11 @@ NS_IMETHODIMP WebGLContext::TexImage2D_imageData(WebGLenum target, WebGLint level, WebGLenum internalformat, WebGLsizei width, WebGLsizei height, WebGLint border, WebGLenum format, WebGLenum type, - JSObject *pixels) + js::TypedArray *pixels) { return TexImage2D_base(target, level, internalformat, width, height, 4*width, border, format, type, - pixels ? JS_GetTypedArrayData(pixels) : 0, - pixels ? JS_GetTypedArrayByteLength(pixels) : 0, + pixels ? pixels->data : 0, + pixels ? pixels->byteLength : 0, -1, WebGLTexelFormat::RGBA8, PR_FALSE); } @@ -4612,15 +4612,15 @@ WebGLContext::TexSubImage2D_array(WebGLenum target, WebGLint level, WebGLint xoffset, WebGLint yoffset, WebGLsizei width, WebGLsizei height, WebGLenum format, WebGLenum type, - JSObject *pixels) + js::TypedArray *pixels) { if (!pixels) return ErrorInvalidValue("TexSubImage2D: pixels must not be null!"); return TexSubImage2D_base(target, level, xoffset, yoffset, width, height, 0, format, type, - JS_GetTypedArrayData(pixels), JS_GetTypedArrayByteLength(pixels), - JS_GetTypedArrayType(pixels), + pixels->data, pixels->byteLength, + pixels->type, WebGLTexelFormat::Auto, PR_FALSE); } @@ -4629,14 +4629,14 @@ WebGLContext::TexSubImage2D_imageData(WebGLenum target, WebGLint level, WebGLint xoffset, WebGLint yoffset, WebGLsizei width, WebGLsizei height, WebGLenum format, WebGLenum type, - JSObject *pixels) + js::TypedArray *pixels) { if (!pixels) return ErrorInvalidValue("TexSubImage2D: pixels must not be null!"); return TexSubImage2D_base(target, level, xoffset, yoffset, width, height, 4*width, format, type, - JS_GetTypedArrayData(pixels), JS_GetTypedArrayByteLength(pixels), + pixels->data, pixels->byteLength, -1, WebGLTexelFormat::RGBA8, PR_FALSE); } diff --git a/content/events/src/nsDOMNotifyAudioAvailableEvent.cpp b/content/events/src/nsDOMNotifyAudioAvailableEvent.cpp index 76ad94b81d0e..acdd8d1b1681 100644 --- a/content/events/src/nsDOMNotifyAudioAvailableEvent.cpp +++ b/content/events/src/nsDOMNotifyAudioAvailableEvent.cpp @@ -118,8 +118,8 @@ nsDOMNotifyAudioAvailableEvent::GetFrameBuffer(JSContext* aCx, jsval* aResult) return NS_ERROR_FAILURE; } - JSObject *tdest = js::TypedArray::getTypedArray(mCachedArray); - memcpy(JS_GetTypedArrayData(tdest), mFrameBuffer.get(), mFrameBufferLength * sizeof(float)); + js::TypedArray *tdest = js::TypedArray::fromJSObject(mCachedArray); + memcpy(tdest->data, mFrameBuffer.get(), mFrameBufferLength * sizeof(float)); *aResult = OBJECT_TO_JSVAL(mCachedArray); return NS_OK; diff --git a/content/html/content/src/nsHTMLAudioElement.cpp b/content/html/content/src/nsHTMLAudioElement.cpp index f504dbb9da71..78b0104da0fc 100644 --- a/content/html/content/src/nsHTMLAudioElement.cpp +++ b/content/html/content/src/nsHTMLAudioElement.cpp @@ -197,24 +197,24 @@ nsHTMLAudioElement::MozWriteAudio(const jsval &aData, JSContext *aCx, PRUint32 * JSObject *darray = JSVAL_TO_OBJECT(aData); js::AutoValueRooter tsrc_tvr(aCx); - JSObject *tsrc = NULL; + js::TypedArray *tsrc = NULL; // Allow either Float32Array or plain JS Array if (darray->getClass() == &js::TypedArray::fastClasses[js::TypedArray::TYPE_FLOAT32]) { - tsrc = js::TypedArray::getTypedArray(darray); + tsrc = js::TypedArray::fromJSObject(darray); } else if (JS_IsArrayObject(aCx, darray)) { JSObject *nobj = js_CreateTypedArrayWithArray(aCx, js::TypedArray::TYPE_FLOAT32, darray); if (!nobj) { return NS_ERROR_DOM_TYPE_MISMATCH_ERR; } *tsrc_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj); - tsrc = js::TypedArray::getTypedArray(nobj); + tsrc = js::TypedArray::fromJSObject(nobj); } else { return NS_ERROR_DOM_TYPE_MISMATCH_ERR; } - PRUint32 dataLength = JS_GetTypedArrayLength(tsrc); + PRUint32 dataLength = tsrc->length; // Make sure that we are going to write the correct amount of data based // on number of channels. @@ -225,7 +225,7 @@ nsHTMLAudioElement::MozWriteAudio(const jsval &aData, JSContext *aCx, PRUint32 * // Don't write more than can be written without blocking. PRUint32 writeLen = NS_MIN(mAudioStream->Available(), dataLength); - nsresult rv = mAudioStream->Write(JS_GetTypedArrayData(tsrc), writeLen, PR_TRUE); + nsresult rv = mAudioStream->Write(tsrc->data, writeLen, PR_TRUE); if (NS_FAILED(rv)) { return rv; } diff --git a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl index 87f52800d094..1ef32c20d738 100644 --- a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl +++ b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl @@ -68,13 +68,14 @@ struct TypedArray; #undef NO_ERROR %} +[ptr] native WebGLArrayPtr (js::TypedArray); [ptr] native WebGLJSObjectPtr (JSObject); // // OpenGL object wrappers // -[scriptable, uuid(0df9f4ed-f5ff-4e51-a6ff-2bd9785a7639)] +[scriptable, uuid(3b43762a-8305-11de-98ab-000c29206271)] interface nsIWebGLTexture : nsISupports { [noscript] attribute WebGLuint name; @@ -587,12 +588,12 @@ interface nsIDOMWebGLRenderingContext : nsISupports void bufferData([optional] in long dummy); [noscript] void bufferData_size(in WebGLenum target, in WebGLsizei size, in WebGLenum usage); [noscript] void bufferData_buf(in WebGLenum target, in WebGLJSObjectPtr data, in WebGLenum usage); - [noscript] void bufferData_array(in WebGLenum target, in WebGLJSObjectPtr data, in WebGLenum usage); + [noscript] void bufferData_array(in WebGLenum target, in WebGLArrayPtr data, in WebGLenum usage); [noscript] void bufferData_null(); 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_array(in WebGLenum target, in long offset, in WebGLArrayPtr data); [noscript] void bufferSubData_null(); WebGLenum checkFramebufferStatus(in WebGLenum target); @@ -713,7 +714,7 @@ 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); + in WebGLenum format, in WebGLenum type, in WebGLArrayPtr 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); @@ -739,10 +740,10 @@ interface nsIDOMWebGLRenderingContext : nsISupports 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); + in WebGLint border, in WebGLenum format, in WebGLenum type, in WebGLArrayPtr pixels); [noscript] void texImage2D_imageData(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); + in WebGLint border, in WebGLenum format, in WebGLenum type, in WebGLArrayPtr pixels); // HTMLImageElement, HTMLCanvasElement, HTMLVideoElement [noscript] void texImage2D_dom(in WebGLenum target, in WebGLint level, in WebGLenum internalformat, @@ -754,10 +755,10 @@ interface nsIDOMWebGLRenderingContext : nsISupports 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); + in WebGLenum format, in WebGLenum type, in WebGLArrayPtr pixels); [noscript] void texSubImage2D_imageData(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); + in WebGLenum format, in WebGLenum type, in WebGLArrayPtr pixels); // HTMLImageElement, HTMLCanvasElement, HTMLVideoElement [noscript] void texSubImage2D_dom(in WebGLenum target, in WebGLint level, in WebGLint xoffset, in WebGLint yoffset, in WebGLenum format, in WebGLenum type, @@ -787,23 +788,23 @@ interface nsIDOMWebGLRenderingContext : nsISupports void uniform4fv([optional] in long dummy); void uniform4iv([optional] in long dummy); - [noscript] void uniform1fv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform1iv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform2fv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform2iv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform3fv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform3iv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform4fv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); - [noscript] void uniform4iv_array (in nsIWebGLUniformLocation location, in WebGLJSObjectPtr v); + [noscript] void uniform1fv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform1iv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform2fv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform2iv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform3fv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform3iv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform4fv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); + [noscript] void uniform4iv_array (in nsIWebGLUniformLocation location, in WebGLArrayPtr v); - // Modified. These are modified by replacing 'count' and 'value' with a WebGLJSObjectPtr + // Modified. These are modified by replacing 'count' and 'value' with a WebGLArrayPtr void uniformMatrix2fv([optional] in long dummy); void uniformMatrix3fv([optional] in long dummy); void uniformMatrix4fv([optional] in long dummy); - [noscript] void uniformMatrix2fv_array (in nsIWebGLUniformLocation location, in WebGLboolean transpose, in WebGLJSObjectPtr value); - [noscript] void uniformMatrix3fv_array (in nsIWebGLUniformLocation location, in WebGLboolean transpose, in WebGLJSObjectPtr value); - [noscript] void uniformMatrix4fv_array (in nsIWebGLUniformLocation location, in WebGLboolean transpose, in WebGLJSObjectPtr value); + [noscript] void uniformMatrix2fv_array (in nsIWebGLUniformLocation location, in WebGLboolean transpose, in WebGLArrayPtr value); + [noscript] void uniformMatrix3fv_array (in nsIWebGLUniformLocation location, in WebGLboolean transpose, in WebGLArrayPtr value); + [noscript] void uniformMatrix4fv_array (in nsIWebGLUniformLocation location, in WebGLboolean transpose, in WebGLArrayPtr value); // Added API using top entry from the passed nsIWebGLMatrixStack //ZZ void glUniformMatrix(in WebGLint location, in WebGLboolean transpose, in nsIWebGLMatrixStack value); @@ -811,7 +812,7 @@ interface nsIDOMWebGLRenderingContext : nsISupports void useProgram(in nsIWebGLProgram program); void validateProgram(in nsIWebGLProgram program); - // Modified: All the glVertexAttrib*v forms below are modified by replacing 'values' with a WebGLJSObjectPtr + // Modified: All the glVertexAttrib*v forms below are modified by replacing 'values' with a WebGLArrayPtr void vertexAttrib1f(in WebGLuint indx, in WebGLfloat x); void vertexAttrib2f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y); void vertexAttrib3f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z); @@ -822,10 +823,10 @@ interface nsIDOMWebGLRenderingContext : nsISupports void vertexAttrib3fv([optional] in long dummy); void vertexAttrib4fv([optional] in long dummy); - [noscript] void vertexAttrib1fv_array(in WebGLuint indx, in WebGLJSObjectPtr values); - [noscript] void vertexAttrib2fv_array(in WebGLuint indx, in WebGLJSObjectPtr values); - [noscript] void vertexAttrib3fv_array(in WebGLuint indx, in WebGLJSObjectPtr values); - [noscript] void vertexAttrib4fv_array(in WebGLuint indx, in WebGLJSObjectPtr values); + [noscript] void vertexAttrib1fv_array(in WebGLuint indx, in WebGLArrayPtr values); + [noscript] void vertexAttrib2fv_array(in WebGLuint indx, in WebGLArrayPtr values); + [noscript] void vertexAttrib3fv_array(in WebGLuint indx, in WebGLArrayPtr values); + [noscript] void vertexAttrib4fv_array(in WebGLuint indx, in WebGLArrayPtr values); // size is number of elements per attrib; offset, stride are in bytes void vertexAttribPointer(in WebGLuint idx, in WebGLint size, in WebGLenum type, in WebGLboolean normalized, in WebGLsizei stride, in WebGLsizeiptr offset); diff --git a/js/src/jstypedarray.cpp b/js/src/jstypedarray.cpp index 2cf7cd145cea..01c8d45972f6 100644 --- a/js/src/jstypedarray.cpp +++ b/js/src/jstypedarray.cpp @@ -1956,40 +1956,3 @@ js_CreateTypedArrayWithBuffer(JSContext *cx, jsint atype, JSObject *bufArg, AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals); return TypedArrayConstruct(cx, atype, argc, &vals[0]); } - -JSUint32 -JS_GetTypedArrayLength(JSObject *obj) -{ - return obj->getSlot(TypedArray::FIELD_LENGTH).toInt32(); -} - -JSUint32 -JS_GetTypedArrayByteOffset(JSObject *obj) -{ - return obj->getSlot(TypedArray::FIELD_BYTEOFFSET).toInt32(); -} - -JSUint32 -JS_GetTypedArrayByteLength(JSObject *obj) -{ - return obj->getSlot(TypedArray::FIELD_BYTELENGTH).toInt32(); -} - -JSUint32 -JS_GetTypedArrayType(JSObject *obj) -{ - return obj->getSlot(TypedArray::FIELD_TYPE).toInt32(); -} - -JSObject * -JS_GetTypedArrayBuffer(JSObject *obj) -{ - return (JSObject *) obj->getSlot(TypedArray::FIELD_BUFFER).toPrivate(); -} - -void * -JS_GetTypedArrayData(JSObject *obj) -{ - uint8 *ptr = (uint8 *) obj->getSlot(TypedArray::FIELD_DATA).toPrivate(); - return (void *) ptr; -} diff --git a/js/src/jstypedarray.h b/js/src/jstypedarray.h index a78b25f18dd2..2619bbe6d065 100644 --- a/js/src/jstypedarray.h +++ b/js/src/jstypedarray.h @@ -260,22 +260,4 @@ JS_GetArrayBufferByteLength(JSObject *obj); JS_FRIEND_API(uint8 *) JS_GetArrayBufferData(JSObject *obj); -JS_FRIEND_API(JSUint32) -JS_GetTypedArrayLength(JSObject *obj); - -JS_FRIEND_API(JSUint32) -JS_GetTypedArrayByteOffset(JSObject *obj); - -JS_FRIEND_API(JSUint32) -JS_GetTypedArrayByteLength(JSObject *obj); - -JS_FRIEND_API(JSUint32) -JS_GetTypedArrayType(JSObject *obj); - -JS_FRIEND_API(JSObject *) -JS_GetTypedArrayBuffer(JSObject *obj); - -JS_FRIEND_API(void *) -JS_GetTypedArrayData(JSObject *obj); - #endif /* jstypedarray_h */