зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1237193 - Fix WebGL getActiveUniforms return type. r=jgilbert, r=smaug
--HG-- extra : rebase_source : 141f00dc036118d7ec0b92a079de84b7b81c29f6 extra : amend_source : 158f20f09262bbbdc41b3b7ba734cfadd3706198
This commit is contained in:
Родитель
a5aa950851
Коммит
d650b65ee9
|
@ -360,9 +360,12 @@ public:
|
|||
void GetUniformIndices(WebGLProgram* program,
|
||||
const dom::Sequence<nsString>& uniformNames,
|
||||
dom::Nullable< nsTArray<GLuint> >& retval);
|
||||
void GetActiveUniforms(WebGLProgram* program,
|
||||
const dom::Sequence<GLuint>& uniformIndices, GLenum pname,
|
||||
dom::Nullable< nsTArray<GLint> >& retval);
|
||||
void GetActiveUniforms(JSContext* cx,
|
||||
WebGLProgram* program,
|
||||
const dom::Sequence<GLuint>& uniformIndices,
|
||||
GLenum pname,
|
||||
JS::MutableHandleValue retval);
|
||||
|
||||
GLuint GetUniformBlockIndex(WebGLProgram* program, const nsAString& uniformBlockName);
|
||||
void GetActiveUniformBlockParameter(JSContext*, WebGLProgram* program,
|
||||
GLuint uniformBlockIndex, GLenum pname,
|
||||
|
|
|
@ -318,20 +318,38 @@ WebGL2Context::GetUniformIndices(WebGLProgram* program,
|
|||
program->GetUniformIndices(uniformNames, retval);
|
||||
}
|
||||
|
||||
static bool
|
||||
ValidateUniformEnum(WebGLContext* webgl, GLenum pname, const char* info)
|
||||
{
|
||||
switch (pname) {
|
||||
case LOCAL_GL_UNIFORM_TYPE:
|
||||
case LOCAL_GL_UNIFORM_SIZE:
|
||||
case LOCAL_GL_UNIFORM_BLOCK_INDEX:
|
||||
case LOCAL_GL_UNIFORM_OFFSET:
|
||||
case LOCAL_GL_UNIFORM_ARRAY_STRIDE:
|
||||
case LOCAL_GL_UNIFORM_MATRIX_STRIDE:
|
||||
case LOCAL_GL_UNIFORM_IS_ROW_MAJOR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
webgl->ErrorInvalidEnum("%s: invalid pname: %s", info, webgl->EnumName(pname));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetActiveUniforms(WebGLProgram* program,
|
||||
WebGL2Context::GetActiveUniforms(JSContext* cx,
|
||||
WebGLProgram* program,
|
||||
const dom::Sequence<GLuint>& uniformIndices,
|
||||
GLenum pname,
|
||||
dom::Nullable< nsTArray<GLint> >& retval)
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
retval.SetNull();
|
||||
retval.set(JS::NullValue());
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (pname == LOCAL_GL_UNIFORM_NAME_LENGTH) {
|
||||
ErrorInvalidEnumInfo("getActiveUniforms: pname", pname);
|
||||
if (!ValidateUniformEnum(this, pname, "getActiveUniforms"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateObject("getActiveUniforms: program", program))
|
||||
return;
|
||||
|
@ -341,12 +359,48 @@ WebGL2Context::GetActiveUniforms(WebGLProgram* program,
|
|||
return;
|
||||
|
||||
GLuint progname = program->mGLName;
|
||||
nsTArray<GLint>& arr = retval.SetValue();
|
||||
arr.SetLength(count);
|
||||
Vector<GLint> samples;
|
||||
samples.resize(count);
|
||||
|
||||
MakeContextCurrent();
|
||||
gl->fGetActiveUniformsiv(progname, count, uniformIndices.Elements(), pname,
|
||||
arr.Elements());
|
||||
samples.begin());
|
||||
|
||||
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, count));
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_UNIFORM_TYPE:
|
||||
case LOCAL_GL_UNIFORM_SIZE:
|
||||
case LOCAL_GL_UNIFORM_BLOCK_INDEX:
|
||||
case LOCAL_GL_UNIFORM_OFFSET:
|
||||
case LOCAL_GL_UNIFORM_ARRAY_STRIDE:
|
||||
case LOCAL_GL_UNIFORM_MATRIX_STRIDE:
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
JS::RootedValue value(cx);
|
||||
value = JS::Int32Value(samples[i]);
|
||||
if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOCAL_GL_UNIFORM_IS_ROW_MAJOR:
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
JS::RootedValue value(cx);
|
||||
value = JS::BooleanValue(samples[i]);
|
||||
if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
retval.setObjectOrNull(array);
|
||||
}
|
||||
|
||||
GLuint
|
||||
|
|
|
@ -475,7 +475,7 @@ interface WebGL2RenderingContext : WebGLRenderingContext
|
|||
// GLintptr here, otherwise interface generator returns error.
|
||||
(WebGLBuffer or GLintptr)? getIndexedParameter(GLenum target, GLuint index);
|
||||
sequence<GLuint>? getUniformIndices(WebGLProgram? program, sequence<DOMString> uniformNames);
|
||||
sequence<GLint>? getActiveUniforms(WebGLProgram? program, sequence<GLuint> uniformIndices, GLenum pname);
|
||||
any getActiveUniforms(WebGLProgram? program, sequence<GLuint> uniformIndices, GLenum pname);
|
||||
GLuint getUniformBlockIndex(WebGLProgram? program, DOMString uniformBlockName);
|
||||
[Throws]
|
||||
(GLuint or Uint32Array or GLboolean)? getActiveUniformBlockParameter(WebGLProgram? program, GLuint uniformBlockIndex, GLenum pname);
|
||||
|
|
Загрузка…
Ссылка в новой задаче