mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
b=584815; enable WebGL shader validation and remove obsolete texture API; r=bjacob
This commit is contained in:
parent
d0c8473b6b
commit
cd7ca8d0fe
@ -212,7 +212,7 @@ nsICanvasRenderingContextWebGL_BufferSubData(JSContext *cx, uintN argc, jsval *v
|
||||
|
||||
/*
|
||||
* ReadPixels takes:
|
||||
* TexImage2D(int, int, int, int, uint, uint, ArrayBufferView)
|
||||
* ReadPixels(int, int, int, int, uint, uint, ArrayBufferView)
|
||||
*/
|
||||
static JSBool
|
||||
nsICanvasRenderingContextWebGL_ReadPixels(JSContext *cx, uintN argc, jsval *vp)
|
||||
@ -230,8 +230,7 @@ nsICanvasRenderingContextWebGL_ReadPixels(JSContext *cx, uintN argc, jsval *vp)
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
|
||||
return JS_FALSE;
|
||||
|
||||
// XXX we currently allow passing only 6 args to support the API. Eventually drop that.
|
||||
if (argc < 6)
|
||||
if (argc < 7)
|
||||
return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
@ -244,40 +243,8 @@ nsICanvasRenderingContextWebGL_ReadPixels(JSContext *cx, uintN argc, jsval *vp)
|
||||
GET_UINT32_ARG(argv4, 4);
|
||||
GET_UINT32_ARG(argv5, 5);
|
||||
|
||||
if (argc == 6) {
|
||||
/*** BEGIN old API deprecated code. Eventually drop that. ***/
|
||||
// the code here is ugly, but temporary. It comes from the old ReadPixels implementation.
|
||||
// Remove it as soon as it's OK to drop the old API.
|
||||
|
||||
PRInt32 byteLength;
|
||||
rv = self->ReadPixels_byteLength_old_API_deprecated(argv2, argv3, argv4, argv5, &byteLength);
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrow(cx, NS_ERROR_FAILURE);
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSObject *abufObject = js_CreateArrayBuffer(cx, byteLength);
|
||||
if (!abufObject) {
|
||||
xpc_qsThrow(cx, NS_ERROR_FAILURE);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(abufObject);
|
||||
|
||||
rv = self->ReadPixels_buf(
|
||||
argv0, argv1, argv2, argv3, argv4, argv5, abuf);
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrow(cx, NS_ERROR_FAILURE);
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSObject *retval = js_CreateTypedArrayWithBuffer(cx, js::TypedArray::TYPE_UINT8,
|
||||
abufObject, 0, byteLength);
|
||||
|
||||
*vp = OBJECT_TO_JSVAL(retval);
|
||||
return JS_TRUE; // return here to be unaffected by the *vp = JSVAL_VOID; below
|
||||
|
||||
/*** END old API deprecated code ***/
|
||||
} else if (argc == 7 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[6]))
|
||||
if (argc == 7 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[6]))
|
||||
{
|
||||
JSObject *argv6 = JSVAL_TO_OBJECT(argv[6]);
|
||||
if (js_IsArrayBuffer(argv6)) {
|
||||
@ -306,7 +273,7 @@ nsICanvasRenderingContextWebGL_ReadPixels(JSContext *cx, uintN argc, jsval *vp)
|
||||
|
||||
/*
|
||||
* 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, ImageData)
|
||||
*/
|
||||
@ -326,9 +293,7 @@ nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
|
||||
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
|
||||
return JS_FALSE;
|
||||
|
||||
// XXX we currently allow passing only 3 args to support the API. Eventually drop that.
|
||||
// if (argc < 6 || argc == 7 || argc == 8)
|
||||
if (argc < 3)
|
||||
if (argc < 6 || argc == 7 || argc == 8)
|
||||
return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
@ -337,22 +302,9 @@ nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
|
||||
GET_UINT32_ARG(argv0, 0);
|
||||
GET_INT32_ARG(argv1, 1);
|
||||
|
||||
if (argc > 2 && JSVAL_IS_OBJECT(argv[2])) {
|
||||
// the old API. Eventually drop that.
|
||||
|
||||
nsIDOMElement *elt;
|
||||
xpc_qsSelfRef eltRef;
|
||||
rv = xpc_qsUnwrapArg<nsIDOMElement>(cx, argv[2], &elt, &eltRef.ptr, &argv[2]);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
GET_OPTIONAL_UINT32_ARG(argv3, 3);
|
||||
GET_OPTIONAL_UINT32_ARG(argv4, 4);
|
||||
|
||||
rv = self->TexImage2D_dom_old_API_deprecated(argv0, argv1, elt, argv3, argv4);
|
||||
} else if (argc > 5 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[5]))
|
||||
if (argc > 5 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[5]))
|
||||
{
|
||||
|
||||
// implement the variants taking a DOMElement as argv[5]
|
||||
GET_UINT32_ARG(argv2, 2);
|
||||
GET_UINT32_ARG(argv3, 3);
|
||||
|
@ -2409,58 +2409,6 @@ WebGLContext::ReadPixels_buf(WebGLint x, WebGLint y, WebGLsizei width, WebGLsize
|
||||
pixels ? pixels->byteLength : 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::ReadPixels_byteLength_old_API_deprecated(WebGLsizei width, WebGLsizei height,
|
||||
WebGLenum format, WebGLenum type, WebGLsizei *retval)
|
||||
{
|
||||
*retval = 0;
|
||||
if (width < 0 || height < 0)
|
||||
return ErrorInvalidValue("ReadPixels: negative size passed");
|
||||
|
||||
PRUint32 size = 0;
|
||||
switch (format) {
|
||||
case LOCAL_GL_ALPHA:
|
||||
size = 1;
|
||||
break;
|
||||
case LOCAL_GL_RGB:
|
||||
size = 3;
|
||||
break;
|
||||
case LOCAL_GL_RGBA:
|
||||
size = 4;
|
||||
break;
|
||||
default:
|
||||
return ErrorInvalidEnumInfo("ReadPixels: format", format);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
// case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
// case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
|
||||
// case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
|
||||
case LOCAL_GL_UNSIGNED_BYTE:
|
||||
break;
|
||||
default:
|
||||
return ErrorInvalidEnumInfo("ReadPixels: type", type);
|
||||
}
|
||||
PRUint32 packAlignment;
|
||||
gl->fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, (GLint*) &packAlignment);
|
||||
|
||||
CheckedUint32 checked_plainRowSize = CheckedUint32(width) * size;
|
||||
|
||||
// alignedRowSize = row size rounded up to next multiple of
|
||||
// packAlignment which is a power of 2
|
||||
CheckedUint32 checked_alignedRowSize
|
||||
= ((checked_plainRowSize + packAlignment-1) / packAlignment) * packAlignment;
|
||||
|
||||
CheckedUint32 checked_neededByteLength = (height-1)*checked_alignedRowSize + checked_plainRowSize;
|
||||
|
||||
if (!checked_neededByteLength.valid())
|
||||
return ErrorInvalidOperation("ReadPixels: integer overflow computing the needed buffer size");
|
||||
|
||||
*retval = checked_neededByteLength.value();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::RenderbufferStorage(WebGLenum target, WebGLenum internalformat, WebGLsizei width, WebGLsizei height)
|
||||
{
|
||||
@ -3229,27 +3177,6 @@ WebGLContext::TexImage2D_dom(WebGLenum target, WebGLint level, WebGLenum interna
|
||||
isurf->Data(), byteLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::TexImage2D_dom_old_API_deprecated(WebGLenum target, WebGLint level, nsIDOMElement *elt,
|
||||
PRBool flipY, PRBool premultiplyAlpha)
|
||||
{
|
||||
nsRefPtr<gfxImageSurface> isurf;
|
||||
|
||||
nsresult rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf),
|
||||
flipY, premultiplyAlpha);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ASSERTION(isurf->Stride() == isurf->Width() * 4, "Bad stride!");
|
||||
|
||||
PRUint32 byteLength = isurf->Stride() * isurf->Height();
|
||||
|
||||
return TexImage2D_base(target, level, LOCAL_GL_RGBA,
|
||||
isurf->Width(), isurf->Height(), 0,
|
||||
LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE,
|
||||
isurf->Data(), byteLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::TexSubImage2D(PRInt32 dummy)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ interface nsIWebGLUniformLocation : nsISupports
|
||||
};
|
||||
|
||||
|
||||
[scriptable, uuid(f02c85e0-8305-11de-abe2-000c29206271)]
|
||||
[scriptable, uuid(2f21ca21-9720-4eee-ad94-27eefe4f72dc)]
|
||||
interface nsICanvasRenderingContextWebGL : nsISupports
|
||||
{
|
||||
//
|
||||
@ -725,8 +725,6 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
||||
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 WebGLArrayBufferPtr pixels);
|
||||
[noscript] WebGLsizei readPixels_byteLength_old_API_deprecated(
|
||||
in WebGLsizei width, in WebGLsizei height, in WebGLenum format, in WebGLenum type);
|
||||
|
||||
//void glReleaseShaderCompiler();
|
||||
|
||||
@ -754,9 +752,6 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
||||
// HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
|
||||
[noscript] void texImage2D_dom(in WebGLenum target, in WebGLint level, in WebGLenum internalformat,
|
||||
in WebGLenum format, in WebGLenum type, in nsIDOMElement element);
|
||||
// XXX the old API. Eventually drop that.
|
||||
[noscript] void TexImage2D_dom_old_API_deprecated(in WebGLenum target, in WebGLint level,
|
||||
in nsIDOMElement element, in PRBool flipY, in PRBool premultiplyAlpha);
|
||||
|
||||
void texSubImage2D([optional] in long dummy);
|
||||
[noscript] void texSubImage2D_buf(in WebGLenum target, in WebGLint level,
|
||||
|
@ -3128,7 +3128,7 @@ pref("image.mem.min_discard_timeout_ms", 10000);
|
||||
|
||||
// WebGL prefs
|
||||
pref("webgl.enabled_for_all_sites", false);
|
||||
pref("webgl.shader_validator", false);
|
||||
pref("webgl.shader_validator", true);
|
||||
pref("webgl.software_render", false);
|
||||
pref("webgl.osmesalib", "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user