Bug 722154 - Part f: Remove custom quickstubs for vertexAttrib[1-4]fv; r=bjacob

This commit is contained in:
Ms2ger 2012-03-16 10:53:41 +01:00
parent 3456d2d5e4
commit a494664e3f
4 changed files with 38 additions and 152 deletions

View File

@ -58,25 +58,6 @@
return JS_FALSE; \
} while (0)
#define GET_OPTIONAL_UINT32_ARG(var, index) \
uint32_t var = 0; \
do { \
if (argc > index) \
if (!JS_ValueToECMAUint32(cx, argv[index], &(var))) \
return JS_FALSE; \
} while (0)
static inline bool
helper_isInt32Array(JSObject *obj) {
return js::GetObjectClass(obj) == &js::TypedArray::fastClasses[js::TypedArray::TYPE_INT32];
}
static inline bool
helper_isFloat32Array(JSObject *obj) {
return js::GetObjectClass(obj) == &js::TypedArray::fastClasses[js::TypedArray::TYPE_FLOAT32];
}
class CallTexImage2D
{
private:
@ -335,95 +316,3 @@ nsIDOMWebGLRenderingContext_TexSubImage2D(JSContext *cx, unsigned argc, jsval *v
*vp = JSVAL_VOID;
return JS_TRUE;
}
static inline JSBool
helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(JSContext *cx, unsigned argc, jsval *vp, int nElements)
{
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 < 2)
return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
jsval *argv = JS_ARGV(cx, vp);
uint32_t location;
if (!JS_ValueToECMAUint32(cx, argv[0], &location))
return JS_FALSE;
if (JSVAL_IS_PRIMITIVE(argv[1])) {
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1);
return JS_FALSE;
}
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JS::AutoValueRooter obj_tvr(cx);
JSObject *wa = 0;
if (helper_isFloat32Array(arg1)) {
wa = js::TypedArray::getTypedArray(arg1);
} else if (JS_IsArrayObject(cx, arg1)) {
JSObject *nobj = js_CreateTypedArrayWithArray(cx, js::TypedArray::TYPE_FLOAT32, arg1);
if (!nobj) {
// XXX this will likely return a strange error message if it goes wrong
return JS_FALSE;
}
*obj_tvr.jsval_addr() = OBJECT_TO_JSVAL(nobj);
wa = js::TypedArray::getTypedArray(nobj);
} else {
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 1);
return JS_FALSE;
}
nsresult rv = NS_OK;
if (nElements == 1) {
rv = self->VertexAttrib1fv_array(location, wa);
} else if (nElements == 2) {
rv = self->VertexAttrib2fv_array(location, wa);
} else if (nElements == 3) {
rv = self->VertexAttrib3fv_array(location, wa);
} else if (nElements == 4) {
rv = self->VertexAttrib4fv_array(location, wa);
}
if (NS_FAILED(rv))
return xpc_qsThrowMethodFailed(cx, rv, vp);
*vp = JSVAL_VOID;
return JS_TRUE;
}
static JSBool
nsIDOMWebGLRenderingContext_VertexAttrib1fv(JSContext *cx, unsigned argc, jsval *vp)
{
return helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(cx, argc, vp, 1);
}
static JSBool
nsIDOMWebGLRenderingContext_VertexAttrib2fv(JSContext *cx, unsigned argc, jsval *vp)
{
return helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(cx, argc, vp, 2);
}
static JSBool
nsIDOMWebGLRenderingContext_VertexAttrib3fv(JSContext *cx, unsigned argc, jsval *vp)
{
return helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(cx, argc, vp, 3);
}
static JSBool
nsIDOMWebGLRenderingContext_VertexAttrib4fv(JSContext *cx, unsigned argc, jsval *vp)
{
return helper_nsIDOMWebGLRenderingContext_VertexAttrib_x_fv(cx, argc, vp, 4);
}

View File

@ -4312,33 +4312,39 @@ WebGLContext::VertexAttrib4f(PRUint32 index, WebGLfloat x0, WebGLfloat x1,
return NS_OK;
}
#define SIMPLE_ARRAY_METHOD_NO_COUNT(name, cnt, arrayType, ptrType) \
NS_IMETHODIMP \
WebGLContext::name(PRInt32) { \
return NS_ERROR_NOT_IMPLEMENTED; \
} \
NS_IMETHODIMP \
WebGLContext::name##_array(WebGLuint idx, JSObject *wa) \
{ \
if (!IsContextStable()) \
return NS_OK; \
if (!wa || JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) \
return ErrorInvalidOperation(#name ": array must be " #arrayType); \
if (JS_GetTypedArrayLength(wa) < cnt) \
return ErrorInvalidOperation(#name ": array must be >= %d elements", cnt); \
MakeContextCurrent(); \
ptrType *ptr = (ptrType *)JS_GetTypedArrayData(wa); \
if (idx) { \
gl->f##name(idx, ptr); \
} else { \
mVertexAttrib0Vector[0] = ptr[0]; \
mVertexAttrib0Vector[1] = cnt > 1 ? ptr[1] : ptrType(0); \
mVertexAttrib0Vector[2] = cnt > 2 ? ptr[2] : ptrType(0); \
mVertexAttrib0Vector[3] = cnt > 3 ? ptr[3] : ptrType(1); \
if (gl->IsGLES2()) \
gl->f##name(idx, ptr); \
} \
return NS_OK; \
#define SIMPLE_ARRAY_METHOD_NO_COUNT(name, cnt, arrayType, ptrType) \
NS_IMETHODIMP \
WebGLContext::name(WebGLuint idx, const JS::Value& aValue, JSContext* aCx) \
{ \
JSObject* wa = GetFloat32Array(aCx, aValue); \
if (!wa) { \
return NS_ERROR_FAILURE; \
} \
\
if (!IsContextStable()) { \
return NS_OK; \
} \
if (JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) { \
return ErrorInvalidOperation(#name ": array must be " #arrayType); \
} \
if (JS_GetTypedArrayLength(wa) < cnt) { \
return ErrorInvalidOperation(#name ": array must be >= %d elements", \
cnt); \
} \
\
MakeContextCurrent(); \
ptrType *ptr = static_cast<ptrType*>(JS_GetTypedArrayData(wa)); \
if (idx) { \
gl->f##name(idx, ptr); \
} else { \
mVertexAttrib0Vector[0] = ptr[0]; \
mVertexAttrib0Vector[1] = cnt > 1 ? ptr[1] : ptrType(0); \
mVertexAttrib0Vector[2] = cnt > 2 ? ptr[2] : ptrType(0); \
mVertexAttrib0Vector[3] = cnt > 3 ? ptr[3] : ptrType(1); \
if (gl->IsGLES2()) \
gl->f##name(idx, ptr); \
} \
return NS_OK; \
}
SIMPLE_ARRAY_METHOD_NO_COUNT(VertexAttrib1fv, 1, TYPE_FLOAT32, WebGLfloat)

View File

@ -177,7 +177,7 @@ interface nsIWebGLExtensionTextureFilterAnisotropic : nsIWebGLExtension
const WebGLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
};
[scriptable, builtinclass, uuid(77c303b8-9d86-48d4-a118-0c32358520ee)]
[scriptable, builtinclass, uuid(dcba5412-42b4-4897-b2f4-56a5cae7ef2d)]
interface nsIDOMWebGLRenderingContext : nsISupports
{
//
@ -832,15 +832,10 @@ interface nsIDOMWebGLRenderingContext : nsISupports
void vertexAttrib3f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z);
void vertexAttrib4f(in WebGLuint indx, in WebGLfloat x, in WebGLfloat y, in WebGLfloat z, in WebGLfloat w);
void vertexAttrib1fv([optional] in long dummy);
void vertexAttrib2fv([optional] in long dummy);
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);
[implicit_jscontext] void vertexAttrib1fv(in WebGLuint indx, in jsval values);
[implicit_jscontext] void vertexAttrib2fv(in WebGLuint indx, in jsval values);
[implicit_jscontext] void vertexAttrib3fv(in WebGLuint indx, in jsval values);
[implicit_jscontext] void vertexAttrib4fv(in WebGLuint indx, in jsval 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);

View File

@ -980,10 +980,6 @@ customMethodCalls = {
# WebGL
'nsIDOMWebGLRenderingContext_TexImage2D': CUSTOM_QS,
'nsIDOMWebGLRenderingContext_TexSubImage2D': CUSTOM_QS,
'nsIDOMWebGLRenderingContext_VertexAttrib1fv': CUSTOM_QS,
'nsIDOMWebGLRenderingContext_VertexAttrib2fv': CUSTOM_QS,
'nsIDOMWebGLRenderingContext_VertexAttrib3fv': CUSTOM_QS,
'nsIDOMWebGLRenderingContext_VertexAttrib4fv': CUSTOM_QS,
# Canvas 2D
'nsIDOMCanvasRenderingContext2D_CreateImageData': CUSTOM_QS,
'nsIDOMCanvasRenderingContext2D_PutImageData': CUSTOM_QS,