Bug 924600 - WebGL.getUniform should not throw - r=jgilbert

This commit is contained in:
Benoit Jacob 2013-11-23 21:20:48 -05:00
parent 0187cd7e3d
commit 3c410edd4b
3 changed files with 8 additions and 9 deletions

View File

@ -371,7 +371,7 @@ public:
return GetTexParameter(target, pname);
}
JS::Value GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location, ErrorResult& rv);
WebGLUniformLocation *location);
already_AddRefed<WebGLUniformLocation>
GetUniformLocation(WebGLProgram *prog, const nsAString& name);
void Hint(GLenum target, GLenum mode);

View File

@ -1807,7 +1807,7 @@ WebGLContext::GetTexParameter(GLenum target, GLenum pname)
JS::Value
WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location, ErrorResult& rv)
WebGLUniformLocation *location)
{
if (IsContextLost())
return JS::NullValue();
@ -1876,20 +1876,20 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
}
if (index == uniforms) {
rv.Throw(NS_ERROR_FAILURE); // XXX GL error? shouldn't happen.
GenerateWarning("getUniform: internal error: hit an OpenGL driver bug");
return JS::NullValue();
}
GLenum baseType;
GLint unitSize;
if (!BaseTypeAndSizeFromUniformType(uniformType, &baseType, &unitSize)) {
rv.Throw(NS_ERROR_FAILURE);
GenerateWarning("getUniform: internal error: unknown uniform type 0x%x", uniformType);
return JS::NullValue();
}
// this should never happen
if (unitSize > 16) {
rv.Throw(NS_ERROR_FAILURE);
GenerateWarning("getUniform: internal error: unexpected uniform unit size %d", unitSize);
return JS::NullValue();
}
@ -1901,7 +1901,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
} else {
JSObject* obj = Float32Array::Create(cx, this, unitSize, fv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
ErrorOutOfMemory("getUniform: out of memory");
}
return JS::ObjectOrNullValue(obj);
}
@ -1913,7 +1913,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
} else {
JSObject* obj = Int32Array::Create(cx, this, unitSize, iv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
ErrorOutOfMemory("getUniform: out of memory");
}
return JS::ObjectOrNullValue(obj);
}
@ -1928,7 +1928,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
uv[k] = JS::BooleanValue(iv[k] ? true : false);
JSObject* obj = JS_NewArrayObject(cx, unitSize, uv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
ErrorOutOfMemory("getUniform: out of memory");
}
return JS::ObjectOrNullValue(obj);
}

View File

@ -621,7 +621,6 @@ interface WebGLRenderingContext {
any getTexParameter(GLenum target, GLenum pname);
[Throws]
any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
[NewObject]