mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
b=573705; support ImageData signatures of tex[Sub]Image2D; r=vladimir
This commit is contained in:
parent
08e3bbc71f
commit
abcdcd5d28
@ -308,6 +308,7 @@ nsICanvasRenderingContextWebGL_ReadPixels(JSContext *cx, uintN argc, jsval *vp)
|
|||||||
* TexImage2D takes:
|
* TexImage2D takes:
|
||||||
* TexImage2D(uint, int, uint, int, int, int, uint, uint, ArrayBufferView)\
|
* TexImage2D(uint, int, uint, int, int, int, uint, uint, ArrayBufferView)\
|
||||||
* TexImage2D(uint, int, uint, uint, uint, nsIDOMElement)
|
* TexImage2D(uint, int, uint, uint, uint, nsIDOMElement)
|
||||||
|
* TexImage2D(uint, int, uint, uint, uint, ImageData)
|
||||||
*/
|
*/
|
||||||
static JSBool
|
static JSBool
|
||||||
nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
|
nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
|
||||||
@ -360,6 +361,34 @@ nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
|
|||||||
if (NS_FAILED(rv)) return JS_FALSE;
|
if (NS_FAILED(rv)) return JS_FALSE;
|
||||||
|
|
||||||
rv = self->TexImage2D_dom(argv0, argv1, argv2, argv3, argv4, elt);
|
rv = self->TexImage2D_dom(argv0, argv1, argv2, argv3, argv4, elt);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
// failed to interprete argv[5] as a DOMElement, now try to interprete it as ImageData
|
||||||
|
JSObject *argv5 = JSVAL_TO_OBJECT(argv[5]);
|
||||||
|
jsval js_width, js_height, js_data;
|
||||||
|
JS_GetProperty(cx, argv5, "width", &js_width);
|
||||||
|
JS_GetProperty(cx, argv5, "height", &js_height);
|
||||||
|
JS_GetProperty(cx, argv5, "data", &js_data);
|
||||||
|
if (js_width == JSVAL_VOID ||
|
||||||
|
js_height == JSVAL_VOID ||
|
||||||
|
js_data == JSVAL_VOID)
|
||||||
|
{
|
||||||
|
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5);
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
int32 int_width, int_height;
|
||||||
|
JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
|
||||||
|
if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
|
||||||
|
!JS_ValueToECMAInt32(cx, js_height, &int_height) ||
|
||||||
|
!js_IsTypedArray(obj_data))
|
||||||
|
{
|
||||||
|
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5);
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
rv = self->TexImage2D_array(argv0, argv1, argv2,
|
||||||
|
int_width, int_height, 0,
|
||||||
|
argv3, argv4, js::TypedArray::fromJSObject(obj_data));
|
||||||
|
}
|
||||||
} else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
|
} else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
|
||||||
// implement the variants taking a buffer/array as argv[8]
|
// implement the variants taking a buffer/array as argv[8]
|
||||||
GET_UINT32_ARG(argv2, 2);
|
GET_UINT32_ARG(argv2, 2);
|
||||||
@ -403,6 +432,7 @@ nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
|
|||||||
/* TexSubImage2D takes:
|
/* TexSubImage2D takes:
|
||||||
* TexSubImage2D(uint, int, int, int, int, int, uint, uint, ArrayBufferView)
|
* TexSubImage2D(uint, int, int, int, int, int, uint, uint, ArrayBufferView)
|
||||||
* TexSubImage2D(uint, int, int, int, uint, uint, nsIDOMElement)
|
* TexSubImage2D(uint, int, int, int, uint, uint, nsIDOMElement)
|
||||||
|
* TexSubImage2D(uint, int, int, int, uint, uint, ImageData)
|
||||||
*/
|
*/
|
||||||
static JSBool
|
static JSBool
|
||||||
nsICanvasRenderingContextWebGL_TexSubImage2D(JSContext *cx, uintN argc, jsval *vp)
|
nsICanvasRenderingContextWebGL_TexSubImage2D(JSContext *cx, uintN argc, jsval *vp)
|
||||||
@ -442,6 +472,35 @@ nsICanvasRenderingContextWebGL_TexSubImage2D(JSContext *cx, uintN argc, jsval *v
|
|||||||
if (NS_FAILED(rv)) return JS_FALSE;
|
if (NS_FAILED(rv)) return JS_FALSE;
|
||||||
|
|
||||||
rv = self->TexSubImage2D_dom(argv0, argv1, argv2, argv3, argv4, argv5, elt);
|
rv = self->TexSubImage2D_dom(argv0, argv1, argv2, argv3, argv4, argv5, elt);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
// failed to interprete argv[6] as a DOMElement, now try to interprete it as ImageData
|
||||||
|
JSObject *argv6 = JSVAL_TO_OBJECT(argv[6]);
|
||||||
|
jsval js_width, js_height, js_data;
|
||||||
|
JS_GetProperty(cx, argv6, "width", &js_width);
|
||||||
|
JS_GetProperty(cx, argv6, "height", &js_height);
|
||||||
|
JS_GetProperty(cx, argv6, "data", &js_data);
|
||||||
|
if (js_width == JSVAL_VOID ||
|
||||||
|
js_height == JSVAL_VOID ||
|
||||||
|
js_data == JSVAL_VOID)
|
||||||
|
{
|
||||||
|
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6);
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
int32 int_width, int_height;
|
||||||
|
JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
|
||||||
|
if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
|
||||||
|
!JS_ValueToECMAInt32(cx, js_height, &int_height) ||
|
||||||
|
!js_IsTypedArray(obj_data))
|
||||||
|
{
|
||||||
|
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6);
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
rv = self->TexSubImage2D_array(argv0, argv1, argv2, argv3,
|
||||||
|
int_width, int_height,
|
||||||
|
argv4, argv5,
|
||||||
|
js::TypedArray::fromJSObject(obj_data));
|
||||||
|
}
|
||||||
} else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
|
} else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
|
||||||
// implement the variants taking a buffer/array as argv[8]
|
// implement the variants taking a buffer/array as argv[8]
|
||||||
GET_INT32_ARG(argv4, 4);
|
GET_INT32_ARG(argv4, 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user