mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1318507 - Update implementation. - r=ethlin
This commit is contained in:
parent
3c8047e06c
commit
1a57a7121a
@ -202,9 +202,16 @@ public:
|
||||
void TexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
|
||||
GLint zOffset, GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum unpackFormat, GLenum unpackType,
|
||||
const dom::ArrayBufferView& srcView, GLuint srcElemOffset,
|
||||
ErrorResult&)
|
||||
const dom::Nullable<dom::ArrayBufferView>& maybeSrcView,
|
||||
GLuint srcElemOffset, ErrorResult&)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateNonNull("texSubImage3D", maybeSrcView))
|
||||
return;
|
||||
const auto& srcView = maybeSrcView.Value();
|
||||
|
||||
const TexImageSourceAdapter src(srcView, srcElemOffset);
|
||||
TexSubImage3D(target, level, xOffset, yOffset, zOffset, width, height, depth,
|
||||
unpackFormat, unpackType, src);
|
||||
@ -224,7 +231,7 @@ protected:
|
||||
public:
|
||||
// -------------------------------------------------------------------------
|
||||
// Programs and shaders - WebGL2ContextPrograms.cpp
|
||||
GLint GetFragDataLocation(WebGLProgram* program, const nsAString& name);
|
||||
GLint GetFragDataLocation(const WebGLProgram& program, const nsAString& name);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -309,13 +316,10 @@ public:
|
||||
void DeleteSampler(WebGLSampler* sampler);
|
||||
bool IsSampler(WebGLSampler* sampler);
|
||||
void BindSampler(GLuint unit, WebGLSampler* sampler);
|
||||
void SamplerParameteri(WebGLSampler* sampler, GLenum pname, GLint param);
|
||||
void SamplerParameteriv(WebGLSampler* sampler, GLenum pname, const dom::Int32Array& param);
|
||||
void SamplerParameteriv(WebGLSampler* sampler, GLenum pname, const dom::Sequence<GLint>& param);
|
||||
void SamplerParameterf(WebGLSampler* sampler, GLenum pname, GLfloat param);
|
||||
void SamplerParameterfv(WebGLSampler* sampler, GLenum pname, const dom::Float32Array& param);
|
||||
void SamplerParameterfv(WebGLSampler* sampler, GLenum pname, const dom::Sequence<GLfloat>& param);
|
||||
void GetSamplerParameter(JSContext*, WebGLSampler* sampler, GLenum pname, JS::MutableHandleValue retval);
|
||||
void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
|
||||
void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
|
||||
void GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLenum pname,
|
||||
JS::MutableHandleValue retval);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -324,9 +328,10 @@ public:
|
||||
already_AddRefed<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
|
||||
bool IsSync(WebGLSync* sync);
|
||||
void DeleteSync(WebGLSync* sync);
|
||||
GLenum ClientWaitSync(WebGLSync* sync, GLbitfield flags, GLuint64 timeout);
|
||||
void WaitSync(WebGLSync* sync, GLbitfield flags, GLuint64 timeout);
|
||||
void GetSyncParameter(JSContext*, WebGLSync* sync, GLenum pname, JS::MutableHandleValue retval);
|
||||
GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout);
|
||||
void WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout);
|
||||
void GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
|
||||
JS::MutableHandleValue retval);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -340,8 +345,11 @@ public:
|
||||
void EndTransformFeedback();
|
||||
void PauseTransformFeedback();
|
||||
void ResumeTransformFeedback();
|
||||
void TransformFeedbackVaryings(WebGLProgram* program, const dom::Sequence<nsString>& varyings, GLenum bufferMode);
|
||||
already_AddRefed<WebGLActiveInfo> GetTransformFeedbackVarying(WebGLProgram* program, GLuint index);
|
||||
void TransformFeedbackVaryings(WebGLProgram& program,
|
||||
const dom::Sequence<nsString>& varyings,
|
||||
GLenum bufferMode);
|
||||
already_AddRefed<WebGLActiveInfo>
|
||||
GetTransformFeedbackVarying(const WebGLProgram& program, GLuint index);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -354,23 +362,21 @@ public:
|
||||
virtual JS::Value GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv) override;
|
||||
void GetIndexedParameter(JSContext* cx, GLenum target, GLuint index,
|
||||
JS::MutableHandleValue retval, ErrorResult& rv);
|
||||
void GetUniformIndices(WebGLProgram* program,
|
||||
void GetUniformIndices(const WebGLProgram& program,
|
||||
const dom::Sequence<nsString>& uniformNames,
|
||||
dom::Nullable< nsTArray<GLuint> >& retval);
|
||||
void GetActiveUniforms(JSContext* cx,
|
||||
WebGLProgram* program,
|
||||
const dom::Sequence<GLuint>& uniformIndices,
|
||||
GLenum pname,
|
||||
void GetActiveUniforms(JSContext* cx, const 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 GetUniformBlockIndex(const WebGLProgram& program,
|
||||
const nsAString& uniformBlockName);
|
||||
void GetActiveUniformBlockParameter(JSContext*, const WebGLProgram& program,
|
||||
GLuint uniformBlockIndex, GLenum pname,
|
||||
JS::MutableHandleValue retval,
|
||||
ErrorResult& rv);
|
||||
void GetActiveUniformBlockName(WebGLProgram* program, GLuint uniformBlockIndex,
|
||||
JS::MutableHandleValue retval, ErrorResult& rv);
|
||||
void GetActiveUniformBlockName(const WebGLProgram& program, GLuint uniformBlockIndex,
|
||||
nsAString& retval);
|
||||
void UniformBlockBinding(WebGLProgram* program, GLuint uniformBlockIndex,
|
||||
void UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
|
||||
GLuint uniformBlockBinding);
|
||||
|
||||
|
||||
|
@ -14,15 +14,15 @@ namespace mozilla {
|
||||
// Programs and shaders
|
||||
|
||||
GLint
|
||||
WebGL2Context::GetFragDataLocation(WebGLProgram* prog, const nsAString& name)
|
||||
WebGL2Context::GetFragDataLocation(const WebGLProgram& prog, const nsAString& name)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return -1;
|
||||
|
||||
if (!ValidateObject("getFragDataLocation: program", prog))
|
||||
if (!ValidateObjectRef("getFragDataLocation: program", prog))
|
||||
return -1;
|
||||
|
||||
return prog->GetFragDataLocation(name);
|
||||
return prog.GetFragDataLocation(name);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -110,7 +110,7 @@ WebGLContext::IsQuery(const WebGLQuery* query, const char* funcName)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BeginQuery(GLenum target, WebGLQuery* query, const char* funcName)
|
||||
WebGLContext::BeginQuery(GLenum target, WebGLQuery& query, const char* funcName)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "beginQuery";
|
||||
@ -119,10 +119,10 @@ WebGLContext::BeginQuery(GLenum target, WebGLQuery* query, const char* funcName)
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeleted(funcName, query))
|
||||
if (!ValidateObjectAllowDeleted(funcName, &query))
|
||||
return;
|
||||
|
||||
if (query->IsDeleted())
|
||||
if (query.IsDeleted())
|
||||
return ErrorInvalidOperation("%s: Cannot begin a deleted query.", funcName);
|
||||
|
||||
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
|
||||
@ -134,7 +134,7 @@ WebGLContext::BeginQuery(GLenum target, WebGLQuery* query, const char* funcName)
|
||||
|
||||
////
|
||||
|
||||
query->BeginQuery(target, *slot);
|
||||
query.BeginQuery(target, *slot);
|
||||
}
|
||||
|
||||
void
|
||||
@ -227,7 +227,7 @@ WebGLContext::GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery* query, GLenum pname,
|
||||
WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery& query, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName)
|
||||
{
|
||||
if (!funcName) {
|
||||
@ -238,13 +238,13 @@ WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery* query, GLenum pnam
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObjectAllowDeleted(funcName, query))
|
||||
if (!ValidateObjectAllowDeleted(funcName, &query))
|
||||
return;
|
||||
|
||||
if (query->IsDeleted())
|
||||
if (query.IsDeleted())
|
||||
return ErrorInvalidOperation("%s: Query must not be deleted.", funcName);
|
||||
|
||||
query->GetQueryParameter(pname, retval);
|
||||
query.GetQueryParameter(pname, retval);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -59,62 +59,63 @@ WebGL2Context::DeleteSync(WebGLSync* sync)
|
||||
}
|
||||
|
||||
GLenum
|
||||
WebGL2Context::ClientWaitSync(WebGLSync* sync, GLbitfield flags, GLuint64 timeout)
|
||||
WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout)
|
||||
{
|
||||
const char funcName[] = "clientWaitSync";
|
||||
if (IsContextLost())
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
|
||||
if (!sync || sync->IsDeleted()) {
|
||||
ErrorInvalidValue("clientWaitSync: sync is not a sync object.");
|
||||
if (!ValidateObjectRef(funcName, sync))
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
}
|
||||
|
||||
if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
|
||||
ErrorInvalidValue("clientWaitSync: flag must be SYNC_FLUSH_COMMANDS_BIT or 0");
|
||||
ErrorInvalidValue("%s: `flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.", funcName);
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
return gl->fClientWaitSync(sync->mGLName, flags, timeout);
|
||||
return gl->fClientWaitSync(sync.mGLName, flags, timeout);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::WaitSync(WebGLSync* sync, GLbitfield flags, GLuint64 timeout)
|
||||
WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout)
|
||||
{
|
||||
const char funcName[] = "waitSync";
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!sync || sync->IsDeleted()) {
|
||||
ErrorInvalidValue("waitSync: sync is not a sync object.");
|
||||
if (!ValidateObjectRef(funcName, sync))
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags != 0) {
|
||||
ErrorInvalidValue("waitSync: flags must be 0");
|
||||
ErrorInvalidValue("%s: `flags` must be 0.", funcName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeout != LOCAL_GL_TIMEOUT_IGNORED) {
|
||||
ErrorInvalidValue("waitSync: timeout must be TIMEOUT_IGNORED");
|
||||
if (timeout != -1) {
|
||||
ErrorInvalidValue("%s: `timeout` must be TIMEOUT_IGNORED.", funcName);
|
||||
return;
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
gl->fWaitSync(sync->mGLName, flags, timeout);
|
||||
gl->fWaitSync(sync.mGLName, flags, LOCAL_GL_TIMEOUT_IGNORED);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetSyncParameter(JSContext*, WebGLSync* sync, GLenum pname, JS::MutableHandleValue retval)
|
||||
WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
const char funcName[] = "getSyncParameter";
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!sync || sync->IsDeleted()) {
|
||||
ErrorInvalidValue("getSyncParameter: sync is not a sync object.");
|
||||
if (!ValidateObjectRef(funcName, sync))
|
||||
return;
|
||||
}
|
||||
|
||||
retval.set(JS::NullValue());
|
||||
////
|
||||
|
||||
gl->MakeCurrent();
|
||||
|
||||
GLint result = 0;
|
||||
switch (pname) {
|
||||
@ -122,13 +123,14 @@ WebGL2Context::GetSyncParameter(JSContext*, WebGLSync* sync, GLenum pname, JS::M
|
||||
case LOCAL_GL_SYNC_STATUS:
|
||||
case LOCAL_GL_SYNC_CONDITION:
|
||||
case LOCAL_GL_SYNC_FLAGS:
|
||||
MakeContextCurrent();
|
||||
gl->fGetSynciv(sync->mGLName, pname, 1, nullptr, &result);
|
||||
gl->fGetSynciv(sync.mGLName, pname, 1, nullptr, &result);
|
||||
retval.set(JS::Int32Value(result));
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorInvalidEnum("getSyncParameter: Invalid pname 0x%04x", pname);
|
||||
default:
|
||||
ErrorInvalidEnum("%s: Invalid pname 0x%04x", funcName, pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -136,29 +136,29 @@ WebGL2Context::ResumeTransformFeedback()
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::TransformFeedbackVaryings(WebGLProgram* program,
|
||||
WebGL2Context::TransformFeedbackVaryings(WebGLProgram& program,
|
||||
const dom::Sequence<nsString>& varyings,
|
||||
GLenum bufferMode)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("transformFeedbackVaryings: program", program))
|
||||
if (!ValidateObjectRef("transformFeedbackVaryings: program", program))
|
||||
return;
|
||||
|
||||
program->TransformFeedbackVaryings(varyings, bufferMode);
|
||||
program.TransformFeedbackVaryings(varyings, bufferMode);
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLActiveInfo>
|
||||
WebGL2Context::GetTransformFeedbackVarying(WebGLProgram* program, GLuint index)
|
||||
WebGL2Context::GetTransformFeedbackVarying(const WebGLProgram& program, GLuint index)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!ValidateObject("getTransformFeedbackVarying: program", program))
|
||||
if (!ValidateObjectRef("getTransformFeedbackVarying: program", program))
|
||||
return nullptr;
|
||||
|
||||
return program->GetTransformFeedbackVarying(index);
|
||||
return program.GetTransformFeedbackVarying(index);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -130,7 +130,7 @@ WebGL2Context::GetIndexedParameter(JSContext* cx, GLenum target, GLuint index,
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetUniformIndices(WebGLProgram* program,
|
||||
WebGL2Context::GetUniformIndices(const WebGLProgram& program,
|
||||
const dom::Sequence<nsString>& uniformNames,
|
||||
dom::Nullable< nsTArray<GLuint> >& retval)
|
||||
{
|
||||
@ -138,13 +138,13 @@ WebGL2Context::GetUniformIndices(WebGLProgram* program,
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getUniformIndices: program", program))
|
||||
if (!ValidateObjectRef("getUniformIndices: program", program))
|
||||
return;
|
||||
|
||||
if (!uniformNames.Length())
|
||||
return;
|
||||
|
||||
program->GetUniformIndices(uniformNames, retval);
|
||||
program.GetUniformIndices(uniformNames, retval);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -167,40 +167,34 @@ ValidateUniformEnum(WebGLContext* webgl, GLenum pname, const char* info)
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetActiveUniforms(JSContext* cx,
|
||||
WebGLProgram* program,
|
||||
WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
|
||||
const dom::Sequence<GLuint>& uniformIndices,
|
||||
GLenum pname,
|
||||
JS::MutableHandleValue retval)
|
||||
GLenum pname, JS::MutableHandleValue retval)
|
||||
{
|
||||
retval.set(JS::NullValue());
|
||||
const char funcName[] = "getActiveUniforms";
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateUniformEnum(this, pname, "getActiveUniforms"))
|
||||
if (!ValidateUniformEnum(this, pname, funcName))
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getActiveUniforms: program", program))
|
||||
if (!ValidateObjectRef("getActiveUniforms: program", program))
|
||||
return;
|
||||
|
||||
size_t count = uniformIndices.Length();
|
||||
if (!count)
|
||||
return;
|
||||
|
||||
GLuint progname = program->mGLName;
|
||||
Vector<GLint> samples;
|
||||
if (!samples.resize(count)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
gl->fGetActiveUniformsiv(progname, count, uniformIndices.Elements(), pname,
|
||||
samples.begin());
|
||||
const auto& count = uniformIndices.Length();
|
||||
|
||||
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, count));
|
||||
if (!array) {
|
||||
UniquePtr<GLint[]> samples(new GLint[count]);
|
||||
if (!array || !samples) {
|
||||
ErrorOutOfMemory("%s: Failed to allocate buffers.", funcName);
|
||||
return;
|
||||
}
|
||||
retval.setObject(*array);
|
||||
|
||||
MakeContextCurrent();
|
||||
gl->fGetActiveUniformsiv(program.mGLName, count, uniformIndices.Elements(), pname,
|
||||
samples.get());
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_UNIFORM_TYPE:
|
||||
@ -209,55 +203,51 @@ WebGL2Context::GetActiveUniforms(JSContext* cx,
|
||||
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) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
JS::RootedValue value(cx);
|
||||
value = JS::Int32Value(samples[i]);
|
||||
if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE)) {
|
||||
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) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
JS::RootedValue value(cx);
|
||||
value = JS::BooleanValue(samples[i]);
|
||||
if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE)) {
|
||||
if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE))
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
MOZ_CRASH("Invalid pname");
|
||||
}
|
||||
|
||||
retval.setObjectOrNull(array);
|
||||
}
|
||||
|
||||
GLuint
|
||||
WebGL2Context::GetUniformBlockIndex(WebGLProgram* program,
|
||||
WebGL2Context::GetUniformBlockIndex(const WebGLProgram& program,
|
||||
const nsAString& uniformBlockName)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return 0;
|
||||
|
||||
if (!ValidateObject("getUniformBlockIndex: program", program))
|
||||
if (!ValidateObjectRef("getUniformBlockIndex: program", program))
|
||||
return 0;
|
||||
|
||||
return program->GetUniformBlockIndex(uniformBlockName);
|
||||
return program.GetUniformBlockIndex(uniformBlockName);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, WebGLProgram* program,
|
||||
WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, const WebGLProgram& program,
|
||||
GLuint uniformBlockIndex, GLenum pname,
|
||||
JS::MutableHandleValue out_retval,
|
||||
ErrorResult& out_error)
|
||||
{
|
||||
out_retval.set(JS::NullValue());
|
||||
out_retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getActiveUniformBlockParameter: program", program))
|
||||
if (!ValidateObjectRef("getActiveUniformBlockParameter: program", program))
|
||||
return;
|
||||
|
||||
MakeContextCurrent();
|
||||
@ -268,12 +258,12 @@ WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, WebGLProgram* progr
|
||||
case LOCAL_GL_UNIFORM_BLOCK_BINDING:
|
||||
case LOCAL_GL_UNIFORM_BLOCK_DATA_SIZE:
|
||||
case LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
|
||||
out_retval.set(program->GetActiveUniformBlockParam(uniformBlockIndex, pname));
|
||||
out_retval.set(program.GetActiveUniformBlockParam(uniformBlockIndex, pname));
|
||||
return;
|
||||
|
||||
case LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
|
||||
out_retval.set(program->GetActiveUniformBlockActiveUniforms(cx, uniformBlockIndex,
|
||||
&out_error));
|
||||
out_retval.set(program.GetActiveUniformBlockActiveUniforms(cx, uniformBlockIndex,
|
||||
&out_error));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,30 +271,30 @@ WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, WebGLProgram* progr
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetActiveUniformBlockName(WebGLProgram* program, GLuint uniformBlockIndex,
|
||||
nsAString& retval)
|
||||
WebGL2Context::GetActiveUniformBlockName(const WebGLProgram& program,
|
||||
GLuint uniformBlockIndex, nsAString& retval)
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getActiveUniformBlockName: program", program))
|
||||
if (!ValidateObjectRef("getActiveUniformBlockName: program", program))
|
||||
return;
|
||||
|
||||
program->GetActiveUniformBlockName(uniformBlockIndex, retval);
|
||||
program.GetActiveUniformBlockName(uniformBlockIndex, retval);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::UniformBlockBinding(WebGLProgram* program, GLuint uniformBlockIndex,
|
||||
WebGL2Context::UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
|
||||
GLuint uniformBlockBinding)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("uniformBlockBinding: program", program))
|
||||
if (!ValidateObjectRef("uniformBlockBinding: program", program))
|
||||
return;
|
||||
|
||||
program->UniformBlockBinding(uniformBlockIndex, uniformBlockBinding);
|
||||
program.UniformBlockBinding(uniformBlockIndex, uniformBlockBinding);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -164,19 +164,19 @@ struct WebGLContextOptions
|
||||
// From WebGLContextUtils
|
||||
TexTarget TexImageTargetToTexTarget(TexImageTarget texImageTarget);
|
||||
|
||||
class WebGLIntOrFloat {
|
||||
enum {
|
||||
struct WebGLIntOrFloat {
|
||||
const enum {
|
||||
Int,
|
||||
Float,
|
||||
Uint
|
||||
} mType;
|
||||
|
||||
union {
|
||||
GLint i;
|
||||
GLfloat f;
|
||||
GLuint u;
|
||||
} mValue;
|
||||
|
||||
public:
|
||||
explicit WebGLIntOrFloat(GLint i) : mType(Int) { mValue.i = i; }
|
||||
explicit WebGLIntOrFloat(GLfloat f) : mType(Float) { mValue.f = f; }
|
||||
|
||||
@ -490,8 +490,8 @@ public:
|
||||
void GetExtension(JSContext* cx, const nsAString& name,
|
||||
JS::MutableHandle<JSObject*> retval,
|
||||
dom::CallerType callerType, ErrorResult& rv);
|
||||
void AttachShader(WebGLProgram* prog, WebGLShader* shader);
|
||||
void BindAttribLocation(WebGLProgram* prog, GLuint location,
|
||||
void AttachShader(WebGLProgram& prog, WebGLShader& shader);
|
||||
void BindAttribLocation(WebGLProgram& prog, GLuint location,
|
||||
const nsAString& name);
|
||||
void BindFramebuffer(GLenum target, WebGLFramebuffer* fb);
|
||||
void BindRenderbuffer(GLenum target, WebGLRenderbuffer* fb);
|
||||
@ -508,7 +508,7 @@ public:
|
||||
void ClearDepth(GLclampf v);
|
||||
void ClearStencil(GLint v);
|
||||
void ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a);
|
||||
void CompileShader(WebGLShader* shader);
|
||||
void CompileShader(WebGLShader& shader);
|
||||
void CompileShaderANGLE(WebGLShader* shader);
|
||||
void CompileShaderBypass(WebGLShader* shader, const nsCString& shaderSource);
|
||||
already_AddRefed<WebGLFramebuffer> CreateFramebuffer();
|
||||
@ -525,7 +525,7 @@ public:
|
||||
void DepthFunc(GLenum func);
|
||||
void DepthMask(WebGLboolean b);
|
||||
void DepthRange(GLclampf zNear, GLclampf zFar);
|
||||
void DetachShader(WebGLProgram* prog, WebGLShader* shader);
|
||||
void DetachShader(WebGLProgram& prog, const WebGLShader& shader);
|
||||
void DrawBuffers(const dom::Sequence<GLenum>& buffers);
|
||||
void Flush();
|
||||
void Finish();
|
||||
@ -541,16 +541,16 @@ public:
|
||||
bool badColorAttachmentIsInvalidOp = false);
|
||||
|
||||
void FrontFace(GLenum mode);
|
||||
already_AddRefed<WebGLActiveInfo> GetActiveAttrib(WebGLProgram* prog,
|
||||
already_AddRefed<WebGLActiveInfo> GetActiveAttrib(const WebGLProgram& prog,
|
||||
GLuint index);
|
||||
already_AddRefed<WebGLActiveInfo> GetActiveUniform(WebGLProgram* prog,
|
||||
already_AddRefed<WebGLActiveInfo> GetActiveUniform(const WebGLProgram& prog,
|
||||
GLuint index);
|
||||
|
||||
void
|
||||
GetAttachedShaders(WebGLProgram* prog,
|
||||
GetAttachedShaders(const WebGLProgram& prog,
|
||||
dom::Nullable<nsTArray<RefPtr<WebGLShader>>>& retval);
|
||||
|
||||
GLint GetAttribLocation(WebGLProgram* prog, const nsAString& name);
|
||||
GLint GetAttribLocation(const WebGLProgram& prog, const nsAString& name);
|
||||
JS::Value GetBufferParameter(GLenum target, GLenum pname);
|
||||
|
||||
void GetBufferParameter(JSContext*, GLenum target, GLenum pname,
|
||||
@ -573,16 +573,16 @@ public:
|
||||
pname, rv));
|
||||
}
|
||||
|
||||
JS::Value GetProgramParameter(WebGLProgram* prog, GLenum pname);
|
||||
JS::Value GetProgramParameter(const WebGLProgram& prog, GLenum pname);
|
||||
|
||||
void GetProgramParameter(JSContext*, WebGLProgram* prog, GLenum pname,
|
||||
void GetProgramParameter(JSContext*, const WebGLProgram& prog, GLenum pname,
|
||||
JS::MutableHandle<JS::Value> retval)
|
||||
{
|
||||
retval.set(GetProgramParameter(prog, pname));
|
||||
}
|
||||
|
||||
void GetProgramInfoLog(WebGLProgram* prog, nsACString& retval);
|
||||
void GetProgramInfoLog(WebGLProgram* prog, nsAString& retval);
|
||||
void GetProgramInfoLog(const WebGLProgram& prog, nsACString& retval);
|
||||
void GetProgramInfoLog(const WebGLProgram& prog, nsAString& retval);
|
||||
JS::Value GetRenderbufferParameter(GLenum target, GLenum pname);
|
||||
|
||||
void GetRenderbufferParameter(JSContext*, GLenum target, GLenum pname,
|
||||
@ -591,9 +591,9 @@ public:
|
||||
retval.set(GetRenderbufferParameter(target, pname));
|
||||
}
|
||||
|
||||
JS::Value GetShaderParameter(WebGLShader* shader, GLenum pname);
|
||||
JS::Value GetShaderParameter(const WebGLShader& shader, GLenum pname);
|
||||
|
||||
void GetShaderParameter(JSContext*, WebGLShader* shader, GLenum pname,
|
||||
void GetShaderParameter(JSContext*, const WebGLShader& shader, GLenum pname,
|
||||
JS::MutableHandle<JS::Value> retval)
|
||||
{
|
||||
retval.set(GetShaderParameter(shader, pname));
|
||||
@ -602,23 +602,22 @@ public:
|
||||
already_AddRefed<WebGLShaderPrecisionFormat>
|
||||
GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
|
||||
|
||||
void GetShaderInfoLog(WebGLShader* shader, nsACString& retval);
|
||||
void GetShaderInfoLog(WebGLShader* shader, nsAString& retval);
|
||||
void GetShaderSource(WebGLShader* shader, nsAString& retval);
|
||||
void GetShaderTranslatedSource(WebGLShader* shader, nsAString& retval);
|
||||
void GetShaderInfoLog(const WebGLShader& shader, nsACString& retval);
|
||||
void GetShaderInfoLog(const WebGLShader& shader, nsAString& retval);
|
||||
void GetShaderSource(const WebGLShader& shader, nsAString& retval);
|
||||
|
||||
JS::Value GetUniform(JSContext* cx, WebGLProgram* prog,
|
||||
WebGLUniformLocation* loc);
|
||||
JS::Value GetUniform(JSContext* cx, const WebGLProgram& prog,
|
||||
const WebGLUniformLocation& loc);
|
||||
|
||||
void GetUniform(JSContext* cx, WebGLProgram* prog,
|
||||
WebGLUniformLocation* loc,
|
||||
void GetUniform(JSContext* cx, const WebGLProgram& prog,
|
||||
const WebGLUniformLocation& loc,
|
||||
JS::MutableHandle<JS::Value> retval)
|
||||
{
|
||||
retval.set(GetUniform(cx, prog, loc));
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLUniformLocation>
|
||||
GetUniformLocation(WebGLProgram* prog, const nsAString& name);
|
||||
GetUniformLocation(const WebGLProgram& prog, const nsAString& name);
|
||||
|
||||
void Hint(GLenum target, GLenum mode);
|
||||
bool IsFramebuffer(WebGLFramebuffer* fb);
|
||||
@ -627,7 +626,7 @@ public:
|
||||
bool IsShader(WebGLShader* shader);
|
||||
bool IsVertexArray(WebGLVertexArray* vao);
|
||||
void LineWidth(GLfloat width);
|
||||
void LinkProgram(WebGLProgram* prog);
|
||||
void LinkProgram(WebGLProgram& prog);
|
||||
void PixelStorei(GLenum pname, GLint param);
|
||||
void PolygonOffset(GLfloat factor, GLfloat units);
|
||||
|
||||
@ -670,7 +669,7 @@ protected:
|
||||
public:
|
||||
void SampleCoverage(GLclampf value, WebGLboolean invert);
|
||||
void Scissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void ShaderSource(WebGLShader* shader, const nsAString& source);
|
||||
void ShaderSource(WebGLShader& shader, const nsAString& source);
|
||||
void StencilFunc(GLenum func, GLint ref, GLuint mask);
|
||||
void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
|
||||
void StencilMask(GLuint mask);
|
||||
@ -871,7 +870,7 @@ public:
|
||||
bool setterTranspose,
|
||||
const char* funcName,
|
||||
uint32_t* out_numElementsToUpload);
|
||||
void ValidateProgram(WebGLProgram* prog);
|
||||
void ValidateProgram(const WebGLProgram& prog);
|
||||
bool ValidateUniformLocation(const char* info, WebGLUniformLocation* loc);
|
||||
bool ValidateSamplerUniformSetter(const char* info,
|
||||
WebGLUniformLocation* loc, GLint value);
|
||||
@ -894,11 +893,10 @@ private:
|
||||
|
||||
public:
|
||||
void BufferData(GLenum target, WebGLsizeiptr size, GLenum usage);
|
||||
void BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeSrc,
|
||||
GLenum usage);
|
||||
void BufferData(GLenum target, const dom::ArrayBufferView& srcData, GLenum usage,
|
||||
GLuint srcElemOffset = 0, GLuint srcElemCountOverride = 0);
|
||||
void BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeData,
|
||||
GLenum usage);
|
||||
void BufferData(GLenum target, const dom::SharedArrayBuffer& data, GLenum usage);
|
||||
|
||||
private:
|
||||
void BufferSubDataImpl(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
@ -909,7 +907,7 @@ public:
|
||||
const dom::ArrayBufferView& src, GLuint srcElemOffset = 0,
|
||||
GLuint srcElemCountOverride = 0);
|
||||
void BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
const dom::Nullable<dom::ArrayBuffer>& maybeSrc);
|
||||
const dom::ArrayBuffer& src);
|
||||
void BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
const dom::SharedArrayBuffer& src);
|
||||
|
||||
@ -946,11 +944,11 @@ public:
|
||||
already_AddRefed<WebGLQuery> CreateQuery(const char* funcName = nullptr);
|
||||
void DeleteQuery(WebGLQuery* query, const char* funcName = nullptr);
|
||||
bool IsQuery(const WebGLQuery* query, const char* funcName = nullptr);
|
||||
void BeginQuery(GLenum target, WebGLQuery* query, const char* funcName = nullptr);
|
||||
void BeginQuery(GLenum target, WebGLQuery& query, const char* funcName = nullptr);
|
||||
void EndQuery(GLenum target, const char* funcName = nullptr);
|
||||
void GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName = nullptr);
|
||||
void GetQueryParameter(JSContext* cx, const WebGLQuery* query, GLenum pname,
|
||||
void GetQueryParameter(JSContext* cx, const WebGLQuery& query, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName = nullptr);
|
||||
|
||||
|
||||
@ -1530,9 +1528,6 @@ protected:
|
||||
bool ValidateCopyTexImage(TexInternalFormat srcFormat, TexInternalFormat dstformat,
|
||||
WebGLTexImageFunc func, WebGLTexDimensions dims);
|
||||
|
||||
bool ValidateSamplerParameterName(GLenum pname, const char* info);
|
||||
bool ValidateSamplerParameterParams(GLenum pname, const WebGLIntOrFloat& param, const char* info);
|
||||
|
||||
bool ValidateTexImage(TexImageTarget texImageTarget,
|
||||
GLint level, GLenum internalFormat,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
@ -1602,6 +1597,15 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename T>
|
||||
bool ValidateNonNull(const char* funcName, const dom::Nullable<T>& maybe) {
|
||||
if (maybe.IsNull()) {
|
||||
ErrorInvalidValue("%s: `null` is invalid.", funcName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateArrayBufferView(const char* funcName, const dom::ArrayBufferView& view,
|
||||
GLuint elemOffset, GLuint elemCountOverride,
|
||||
uint8_t** const out_bytes, size_t* const out_byteLen);
|
||||
@ -1623,11 +1627,15 @@ protected:
|
||||
size_t dstTexelSize);
|
||||
|
||||
//////
|
||||
|
||||
public:
|
||||
// Returns false if `object` is null or not valid.
|
||||
template<class ObjectType>
|
||||
bool ValidateObject(const char* info, const ObjectType* object);
|
||||
|
||||
// Returns false if `object` is not valid.
|
||||
template<class ObjectType>
|
||||
bool ValidateObjectRef(const char* info, const ObjectType& object);
|
||||
|
||||
// Returns false if `object` is not valid. Considers null to be valid.
|
||||
template<class ObjectType>
|
||||
bool ValidateObjectAllowNull(const char* info, const ObjectType* object);
|
||||
@ -1932,8 +1940,7 @@ ToSupports(WebGLContext* webgl)
|
||||
|
||||
template<class ObjectType>
|
||||
inline bool
|
||||
WebGLContext::ValidateObjectAllowDeletedOrNull(const char* info,
|
||||
const ObjectType* object)
|
||||
WebGLContext::ValidateObjectAllowDeletedOrNull(const char* info, const ObjectType* object)
|
||||
{
|
||||
if (object && !object->IsCompatibleWithContext(this)) {
|
||||
ErrorInvalidOperation("%s: object from different WebGL context "
|
||||
@ -1996,6 +2003,14 @@ WebGLContext::ValidateObject(const char* info, const ObjectType* object)
|
||||
return ValidateObjectAssumeNonNull(info, object);
|
||||
}
|
||||
|
||||
template<class ObjectType>
|
||||
inline bool
|
||||
WebGLContext::ValidateObjectRef(const char* info, const ObjectType& object)
|
||||
{
|
||||
MOZ_ASSERT(bool(&object));
|
||||
return ValidateObjectAssumeNonNull(info, &object);
|
||||
}
|
||||
|
||||
// Returns `value` rounded to the next highest multiple of `multiple`.
|
||||
// AKA PadToAlignment, StrideForAlignment.
|
||||
template<typename V, typename M>
|
||||
|
@ -334,16 +334,6 @@ WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage)
|
||||
BufferDataImpl(target, size_t(size), (const uint8_t*)zeroBuffer.get(), usage);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferData(GLenum target, const dom::SharedArrayBuffer& src, GLenum usage)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
src.ComputeLengthAndData();
|
||||
BufferDataImpl(target, src.LengthAllowShared(), src.DataAllowShared(), usage);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeSrc,
|
||||
GLenum usage)
|
||||
@ -351,9 +341,9 @@ WebGLContext::BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& m
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (maybeSrc.IsNull())
|
||||
return ErrorInvalidValue("bufferData: null object passed");
|
||||
auto& src = maybeSrc.Value();
|
||||
if (!ValidateNonNull("bufferData", maybeSrc))
|
||||
return;
|
||||
const auto& src = maybeSrc.Value();
|
||||
|
||||
src.ComputeLengthAndData();
|
||||
BufferDataImpl(target, src.LengthAllowShared(), src.DataAllowShared(), usage);
|
||||
@ -423,23 +413,7 @@ WebGLContext::BufferSubDataImpl(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
|
||||
void
|
||||
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
const dom::Nullable<dom::ArrayBuffer>& maybeSrc)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (maybeSrc.IsNull())
|
||||
return ErrorInvalidValue("BufferSubData: returnedData is null.");
|
||||
auto& src = maybeSrc.Value();
|
||||
|
||||
src.ComputeLengthAndData();
|
||||
BufferSubDataImpl(target, dstByteOffset, src.LengthAllowShared(),
|
||||
src.DataAllowShared());
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
const dom::SharedArrayBuffer& src)
|
||||
const dom::ArrayBuffer& src)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
@ -87,31 +87,31 @@ WebGLContext::ActiveTexture(GLenum texture)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::AttachShader(WebGLProgram* program, WebGLShader* shader)
|
||||
WebGLContext::AttachShader(WebGLProgram& program, WebGLShader& shader)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("attachShader: program", program) ||
|
||||
!ValidateObject("attachShader: shader", shader))
|
||||
if (!ValidateObjectRef("attachShader: program", program) ||
|
||||
!ValidateObjectRef("attachShader: shader", shader))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
program->AttachShader(shader);
|
||||
program.AttachShader(&shader);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BindAttribLocation(WebGLProgram* prog, GLuint location,
|
||||
WebGLContext::BindAttribLocation(WebGLProgram& prog, GLuint location,
|
||||
const nsAString& name)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("bindAttribLocation: program", prog))
|
||||
if (!ValidateObjectRef("bindAttribLocation: program", prog))
|
||||
return;
|
||||
|
||||
prog->BindAttribLocation(location, name);
|
||||
prog.BindAttribLocation(location, name);
|
||||
}
|
||||
|
||||
void
|
||||
@ -436,20 +436,20 @@ WebGLContext::DeleteShader(WebGLShader* shader)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DetachShader(WebGLProgram* program, WebGLShader* shader)
|
||||
WebGLContext::DetachShader(WebGLProgram& program, const WebGLShader& shader)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
// It's valid to attempt to detach a deleted shader, since it's still a
|
||||
// shader.
|
||||
if (!ValidateObject("detachShader: program", program) ||
|
||||
!ValidateObjectAllowDeleted("detashShader: shader", shader))
|
||||
if (!ValidateObjectRef("detachShader: program", program) ||
|
||||
!ValidateObjectAllowDeleted("detachShader: shader", &shader))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
program->DetachShader(shader);
|
||||
program.DetachShader(&shader);
|
||||
}
|
||||
|
||||
void
|
||||
@ -564,58 +564,53 @@ WebGLContext::FrontFace(GLenum mode)
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLActiveInfo>
|
||||
WebGLContext::GetActiveAttrib(WebGLProgram* prog, GLuint index)
|
||||
WebGLContext::GetActiveAttrib(const WebGLProgram& prog, GLuint index)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!ValidateObject("getActiveAttrib: program", prog))
|
||||
if (!ValidateObjectRef("getActiveAttrib: program", prog))
|
||||
return nullptr;
|
||||
|
||||
return prog->GetActiveAttrib(index);
|
||||
return prog.GetActiveAttrib(index);
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLActiveInfo>
|
||||
WebGLContext::GetActiveUniform(WebGLProgram* prog, GLuint index)
|
||||
WebGLContext::GetActiveUniform(const WebGLProgram& prog, GLuint index)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!ValidateObject("getActiveUniform: program", prog))
|
||||
if (!ValidateObjectRef("getActiveUniform: program", prog))
|
||||
return nullptr;
|
||||
|
||||
return prog->GetActiveUniform(index);
|
||||
return prog.GetActiveUniform(index);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetAttachedShaders(WebGLProgram* prog,
|
||||
WebGLContext::GetAttachedShaders(const WebGLProgram& prog,
|
||||
dom::Nullable<nsTArray<RefPtr<WebGLShader>>>& retval)
|
||||
{
|
||||
retval.SetNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!prog) {
|
||||
ErrorInvalidValue("getAttachedShaders: Invalid program.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateObject("getAttachedShaders", prog))
|
||||
if (!ValidateObjectRef("getAttachedShaders", prog))
|
||||
return;
|
||||
|
||||
prog->GetAttachedShaders(&retval.SetValue());
|
||||
prog.GetAttachedShaders(&retval.SetValue());
|
||||
}
|
||||
|
||||
GLint
|
||||
WebGLContext::GetAttribLocation(WebGLProgram* prog, const nsAString& name)
|
||||
WebGLContext::GetAttribLocation(const WebGLProgram& prog, const nsAString& name)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return -1;
|
||||
|
||||
if (!ValidateObject("getAttribLocation: program", prog))
|
||||
if (!ValidateObjectRef("getAttribLocation: program", prog))
|
||||
return -1;
|
||||
|
||||
return prog->GetAttribLocation(name);
|
||||
return prog.GetAttribLocation(name);
|
||||
}
|
||||
|
||||
JS::Value
|
||||
@ -910,62 +905,60 @@ WebGLContext::GetError()
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetProgramParameter(WebGLProgram* prog, GLenum pname)
|
||||
WebGLContext::GetProgramParameter(const WebGLProgram& prog, GLenum pname)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
if (!ValidateObjectAllowDeleted("getProgramParameter: program", prog))
|
||||
if (!ValidateObjectAllowDeleted("getProgramParameter: program", &prog))
|
||||
return JS::NullValue();
|
||||
|
||||
return prog->GetProgramParameter(pname);
|
||||
return prog.GetProgramParameter(pname);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetProgramInfoLog(WebGLProgram* prog, nsAString& retval)
|
||||
WebGLContext::GetProgramInfoLog(const WebGLProgram& prog, nsAString& retval)
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getProgramInfoLog: program", prog))
|
||||
if (!ValidateObjectRef("getProgramInfoLog: program", prog))
|
||||
return;
|
||||
|
||||
prog->GetProgramInfoLog(&retval);
|
||||
|
||||
retval.SetIsVoid(false);
|
||||
prog.GetProgramInfoLog(&retval);
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetUniform(JSContext* js, WebGLProgram* prog,
|
||||
WebGLUniformLocation* loc)
|
||||
WebGLContext::GetUniform(JSContext* js, const WebGLProgram& prog,
|
||||
const WebGLUniformLocation& loc)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
if (!ValidateObject("getUniform: `program`", prog))
|
||||
if (!ValidateObjectRef("getUniform: `program`", prog))
|
||||
return JS::NullValue();
|
||||
|
||||
if (!ValidateObject("getUniform: `location`", loc))
|
||||
if (!ValidateObjectRef("getUniform: `location`", loc))
|
||||
return JS::NullValue();
|
||||
|
||||
if (!loc->ValidateForProgram(prog, "getUniform"))
|
||||
if (!loc.ValidateForProgram(&prog, "getUniform"))
|
||||
return JS::NullValue();
|
||||
|
||||
return loc->GetUniform(js);
|
||||
return loc.GetUniform(js);
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLUniformLocation>
|
||||
WebGLContext::GetUniformLocation(WebGLProgram* prog, const nsAString& name)
|
||||
WebGLContext::GetUniformLocation(const WebGLProgram& prog, const nsAString& name)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!ValidateObject("getUniformLocation: program", prog))
|
||||
if (!ValidateObjectRef("getUniformLocation: program", prog))
|
||||
return nullptr;
|
||||
|
||||
return prog->GetUniformLocation(name);
|
||||
return prog.GetUniformLocation(name);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1060,29 +1053,29 @@ WebGLContext::IsShader(WebGLShader* shader)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::LinkProgram(WebGLProgram* prog)
|
||||
WebGLContext::LinkProgram(WebGLProgram& prog)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("linkProgram", prog))
|
||||
if (!ValidateObjectRef("linkProgram", prog))
|
||||
return;
|
||||
|
||||
prog->LinkProgram();
|
||||
prog.LinkProgram();
|
||||
|
||||
if (!prog->IsLinked()) {
|
||||
if (!prog.IsLinked()) {
|
||||
// If we failed to link, but `prog == mCurrentProgram`, we are *not* supposed to
|
||||
// null out mActiveProgramLinkInfo.
|
||||
return;
|
||||
}
|
||||
|
||||
if (prog == mCurrentProgram) {
|
||||
mActiveProgramLinkInfo = prog->LinkInfo();
|
||||
if (&prog == mCurrentProgram) {
|
||||
mActiveProgramLinkInfo = prog.LinkInfo();
|
||||
|
||||
if (gl->WorkAroundDriverBugs() &&
|
||||
gl->Vendor() == gl::GLVendor::NVIDIA)
|
||||
{
|
||||
gl->fUseProgram(prog->mGLName);
|
||||
gl->fUseProgram(prog.mGLName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2212,15 +2205,15 @@ WebGLContext::UseProgram(WebGLProgram* prog)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ValidateProgram(WebGLProgram* prog)
|
||||
WebGLContext::ValidateProgram(const WebGLProgram& prog)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("validateProgram", prog))
|
||||
if (!ValidateObjectRef("validateProgram", prog))
|
||||
return;
|
||||
|
||||
prog->ValidateProgram();
|
||||
prog.ValidateProgram();
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLFramebuffer>
|
||||
@ -2267,43 +2260,41 @@ WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::CompileShader(WebGLShader* shader)
|
||||
WebGLContext::CompileShader(WebGLShader& shader)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("compileShader", shader))
|
||||
if (!ValidateObjectRef("compileShader", shader))
|
||||
return;
|
||||
|
||||
shader->CompileShader();
|
||||
shader.CompileShader();
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLContext::GetShaderParameter(WebGLShader* shader, GLenum pname)
|
||||
WebGLContext::GetShaderParameter(const WebGLShader& shader, GLenum pname)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
if (!ValidateObject("getShaderParameter: shader", shader))
|
||||
if (!ValidateObjectRef("getShaderParameter: shader", shader))
|
||||
return JS::NullValue();
|
||||
|
||||
return shader->GetShaderParameter(pname);
|
||||
return shader.GetShaderParameter(pname);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetShaderInfoLog(WebGLShader* shader, nsAString& retval)
|
||||
WebGLContext::GetShaderInfoLog(const WebGLShader& shader, nsAString& retval)
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getShaderInfoLog: shader", shader))
|
||||
if (!ValidateObjectRef("getShaderInfoLog: shader", shader))
|
||||
return;
|
||||
|
||||
shader->GetShaderInfoLog(&retval);
|
||||
|
||||
retval.SetIsVoid(false);
|
||||
shader.GetShaderInfoLog(&retval);
|
||||
}
|
||||
|
||||
already_AddRefed<WebGLShaderPrecisionFormat>
|
||||
@ -2355,43 +2346,29 @@ WebGLContext::GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetShaderSource(WebGLShader* shader, nsAString& retval)
|
||||
WebGLContext::GetShaderSource(const WebGLShader& shader, nsAString& retval)
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getShaderSource: shader", shader))
|
||||
if (!ValidateObjectRef("getShaderSource: shader", shader))
|
||||
return;
|
||||
|
||||
shader->GetShaderSource(&retval);
|
||||
shader.GetShaderSource(&retval);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ShaderSource(WebGLShader* shader, const nsAString& source)
|
||||
WebGLContext::ShaderSource(WebGLShader& shader, const nsAString& source)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("shaderSource: shader", shader))
|
||||
if (!ValidateObjectRef("shaderSource: shader", shader))
|
||||
return;
|
||||
|
||||
shader->ShaderSource(source);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetShaderTranslatedSource(WebGLShader* shader, nsAString& retval)
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getShaderTranslatedSource: shader", shader))
|
||||
return;
|
||||
|
||||
shader->GetShaderTranslatedSource(&retval);
|
||||
shader.ShaderSource(source);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -240,117 +240,6 @@ WebGLContext::ValidateFramebufferAttachment(const WebGLFramebuffer* fb, GLenum a
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if pname is valid for GetSamplerParameter calls.
|
||||
*/
|
||||
bool
|
||||
WebGLContext::ValidateSamplerParameterName(GLenum pname, const char* info)
|
||||
{
|
||||
switch (pname) {
|
||||
case LOCAL_GL_TEXTURE_MIN_FILTER:
|
||||
case LOCAL_GL_TEXTURE_MAG_FILTER:
|
||||
case LOCAL_GL_TEXTURE_WRAP_S:
|
||||
case LOCAL_GL_TEXTURE_WRAP_T:
|
||||
case LOCAL_GL_TEXTURE_WRAP_R:
|
||||
case LOCAL_GL_TEXTURE_MIN_LOD:
|
||||
case LOCAL_GL_TEXTURE_MAX_LOD:
|
||||
case LOCAL_GL_TEXTURE_COMPARE_MODE:
|
||||
case LOCAL_GL_TEXTURE_COMPARE_FUNC:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid pname: %s", info, EnumName(pname));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if pname and param are valid combination for SamplerParameter calls.
|
||||
*/
|
||||
bool
|
||||
WebGLContext::ValidateSamplerParameterParams(GLenum pname, const WebGLIntOrFloat& param, const char* info)
|
||||
{
|
||||
const GLenum p = param.AsInt();
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_TEXTURE_MIN_FILTER:
|
||||
switch (p) {
|
||||
case LOCAL_GL_NEAREST:
|
||||
case LOCAL_GL_LINEAR:
|
||||
case LOCAL_GL_NEAREST_MIPMAP_NEAREST:
|
||||
case LOCAL_GL_NEAREST_MIPMAP_LINEAR:
|
||||
case LOCAL_GL_LINEAR_MIPMAP_NEAREST:
|
||||
case LOCAL_GL_LINEAR_MIPMAP_LINEAR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid param: %s", info, EnumName(p));
|
||||
return false;
|
||||
}
|
||||
|
||||
case LOCAL_GL_TEXTURE_MAG_FILTER:
|
||||
switch (p) {
|
||||
case LOCAL_GL_NEAREST:
|
||||
case LOCAL_GL_LINEAR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid param: %s", info, EnumName(p));
|
||||
return false;
|
||||
}
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_S:
|
||||
case LOCAL_GL_TEXTURE_WRAP_T:
|
||||
case LOCAL_GL_TEXTURE_WRAP_R:
|
||||
switch (p) {
|
||||
case LOCAL_GL_CLAMP_TO_EDGE:
|
||||
case LOCAL_GL_REPEAT:
|
||||
case LOCAL_GL_MIRRORED_REPEAT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid param: %s", info, EnumName(p));
|
||||
return false;
|
||||
}
|
||||
|
||||
case LOCAL_GL_TEXTURE_MIN_LOD:
|
||||
case LOCAL_GL_TEXTURE_MAX_LOD:
|
||||
return true;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_MODE:
|
||||
switch (param.AsInt()) {
|
||||
case LOCAL_GL_NONE:
|
||||
case LOCAL_GL_COMPARE_REF_TO_TEXTURE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid param: %s", info, EnumName(p));
|
||||
return false;
|
||||
}
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_FUNC:
|
||||
switch (p) {
|
||||
case LOCAL_GL_LEQUAL:
|
||||
case LOCAL_GL_GEQUAL:
|
||||
case LOCAL_GL_LESS:
|
||||
case LOCAL_GL_GREATER:
|
||||
case LOCAL_GL_EQUAL:
|
||||
case LOCAL_GL_NOTEQUAL:
|
||||
case LOCAL_GL_ALWAYS:
|
||||
case LOCAL_GL_NEVER:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid param: %s", info, EnumName(p));
|
||||
return false;
|
||||
}
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid pname: %s", info, EnumName(pname));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateUniformLocation(WebGLUniformLocation* loc, const char* funcName)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "WebGLContext.h"
|
||||
#include "WebGLShader.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -23,8 +24,8 @@ WebGLExtensionDebugShaders::~WebGLExtensionDebugShaders()
|
||||
// translation has failed for shader, an empty string is returned; otherwise,
|
||||
// return the translated source.
|
||||
void
|
||||
WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
|
||||
nsAString& retval)
|
||||
WebGLExtensionDebugShaders::GetTranslatedShaderSource(const WebGLShader& shader,
|
||||
nsAString& retval) const
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
|
||||
@ -34,8 +35,13 @@ WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
|
||||
return;
|
||||
}
|
||||
|
||||
retval.SetIsVoid(false);
|
||||
mContext->GetShaderTranslatedSource(shader, retval);
|
||||
if (mContext->IsContextLost())
|
||||
return;
|
||||
|
||||
if (!mContext->ValidateObjectRef("getShaderTranslatedSource: shader", shader))
|
||||
return;
|
||||
|
||||
shader.GetShaderTranslatedSource(&retval);
|
||||
}
|
||||
|
||||
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDebugShaders, WEBGL_debug_shaders)
|
||||
|
@ -57,7 +57,7 @@ WebGLExtensionDisjointTimerQuery::IsQueryEXT(const WebGLQuery* query) const
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target, WebGLQuery* query) const
|
||||
WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target, WebGLQuery& query) const
|
||||
{
|
||||
const char funcName[] = "beginQueryEXT";
|
||||
if (mIsLost)
|
||||
@ -77,16 +77,16 @@ WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target) const
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery* query, GLenum target) const
|
||||
WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum target) const
|
||||
{
|
||||
const char funcName[] = "queryCounterEXT";
|
||||
if (mIsLost)
|
||||
return;
|
||||
|
||||
if (!mContext->ValidateObject(funcName, query))
|
||||
if (!mContext->ValidateObjectRef(funcName, query))
|
||||
return;
|
||||
|
||||
query->QueryCounter(funcName, target);
|
||||
query.QueryCounter(funcName, target);
|
||||
}
|
||||
|
||||
void
|
||||
@ -103,7 +103,7 @@ WebGLExtensionDisjointTimerQuery::GetQueryEXT(JSContext* cx, GLenum target, GLen
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::GetQueryObjectEXT(JSContext* cx,
|
||||
const WebGLQuery* query, GLenum pname,
|
||||
const WebGLQuery& query, GLenum pname,
|
||||
JS::MutableHandleValue retval) const
|
||||
{
|
||||
const char funcName[] = "getQueryObjectEXT";
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
explicit WebGLExtensionDebugShaders(WebGLContext*);
|
||||
virtual ~WebGLExtensionDebugShaders();
|
||||
|
||||
void GetTranslatedShaderSource(WebGLShader* shader, nsAString& retval);
|
||||
void GetTranslatedShaderSource(const WebGLShader& shader, nsAString& retval) const;
|
||||
|
||||
DECL_WEBGL_EXTENSION_GOOP
|
||||
};
|
||||
@ -372,12 +372,12 @@ public:
|
||||
already_AddRefed<WebGLQuery> CreateQueryEXT() const;
|
||||
void DeleteQueryEXT(WebGLQuery* query) const;
|
||||
bool IsQueryEXT(const WebGLQuery* query) const;
|
||||
void BeginQueryEXT(GLenum target, WebGLQuery* query) const;
|
||||
void BeginQueryEXT(GLenum target, WebGLQuery& query) const;
|
||||
void EndQueryEXT(GLenum target) const;
|
||||
void QueryCounterEXT(WebGLQuery* query, GLenum target) const;
|
||||
void QueryCounterEXT(WebGLQuery& query, GLenum target) const;
|
||||
void GetQueryEXT(JSContext* cx, GLenum target, GLenum pname,
|
||||
JS::MutableHandleValue retval) const;
|
||||
void GetQueryObjectEXT(JSContext* cx, const WebGLQuery* query,
|
||||
void GetQueryObjectEXT(JSContext* cx, const WebGLQuery& query,
|
||||
GLenum pname, JS::MutableHandleValue retval) const;
|
||||
|
||||
static bool IsSupported(const WebGLContext*);
|
||||
|
@ -537,7 +537,7 @@ WebGLProgram::BindAttribLocation(GLuint loc, const nsAString& name)
|
||||
}
|
||||
|
||||
void
|
||||
WebGLProgram::DetachShader(WebGLShader* shader)
|
||||
WebGLProgram::DetachShader(const WebGLShader* shader)
|
||||
{
|
||||
MOZ_ASSERT(shader);
|
||||
|
||||
|
@ -145,7 +145,7 @@ public:
|
||||
// GL funcs
|
||||
void AttachShader(WebGLShader* shader);
|
||||
void BindAttribLocation(GLuint index, const nsAString& name);
|
||||
void DetachShader(WebGLShader* shader);
|
||||
void DetachShader(const WebGLShader* shader);
|
||||
already_AddRefed<WebGLActiveInfo> GetActiveAttrib(GLuint index) const;
|
||||
already_AddRefed<WebGLActiveInfo> GetActiveUniform(GLuint index) const;
|
||||
void GetAttachedShaders(nsTArray<RefPtr<WebGLShader>>* const out) const;
|
||||
|
@ -53,95 +53,134 @@ WebGLSampler::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
|
||||
return dom::WebGLSamplerBinding::Wrap(cx, this, givenProto);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLSampler::SamplerParameter1i(GLenum pname, GLint param)
|
||||
static bool
|
||||
ValidateSamplerParameterParams(WebGLContext* webgl, const char* funcName, GLenum pname,
|
||||
GLint paramInt)
|
||||
{
|
||||
switch (pname) {
|
||||
case LOCAL_GL_TEXTURE_MIN_FILTER:
|
||||
mMinFilter = param;
|
||||
switch (paramInt) {
|
||||
case LOCAL_GL_NEAREST:
|
||||
case LOCAL_GL_LINEAR:
|
||||
case LOCAL_GL_NEAREST_MIPMAP_NEAREST:
|
||||
case LOCAL_GL_NEAREST_MIPMAP_LINEAR:
|
||||
case LOCAL_GL_LINEAR_MIPMAP_NEAREST:
|
||||
case LOCAL_GL_LINEAR_MIPMAP_LINEAR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MAG_FILTER:
|
||||
mMagFilter = param;
|
||||
switch (paramInt) {
|
||||
case LOCAL_GL_NEAREST:
|
||||
case LOCAL_GL_LINEAR:
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_S:
|
||||
mWrapS = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_T:
|
||||
mWrapT = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_R:
|
||||
mWrapR = param;
|
||||
break;
|
||||
switch (paramInt) {
|
||||
case LOCAL_GL_CLAMP_TO_EDGE:
|
||||
case LOCAL_GL_REPEAT:
|
||||
case LOCAL_GL_MIRRORED_REPEAT:
|
||||
return true;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_MODE:
|
||||
mCompareMode = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_FUNC:
|
||||
mCompareFunc = param;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MIN_LOD:
|
||||
mMinLod = param;
|
||||
case LOCAL_GL_TEXTURE_MAX_LOD:
|
||||
return true;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_MODE:
|
||||
switch (paramInt) {
|
||||
case LOCAL_GL_NONE:
|
||||
case LOCAL_GL_COMPARE_REF_TO_TEXTURE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_FUNC:
|
||||
switch (paramInt) {
|
||||
case LOCAL_GL_LEQUAL:
|
||||
case LOCAL_GL_GEQUAL:
|
||||
case LOCAL_GL_LESS:
|
||||
case LOCAL_GL_GREATER:
|
||||
case LOCAL_GL_EQUAL:
|
||||
case LOCAL_GL_NOTEQUAL:
|
||||
case LOCAL_GL_ALWAYS:
|
||||
case LOCAL_GL_NEVER:
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
webgl->ErrorInvalidEnum("%s: invalid pname: %s", funcName,
|
||||
webgl->EnumName(pname));
|
||||
return false;
|
||||
}
|
||||
|
||||
webgl->ErrorInvalidEnum("%s: invalid param: %s", funcName, webgl->EnumName(paramInt));
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLSampler::SamplerParameter(const char* funcName, GLenum pname, GLint paramInt)
|
||||
{
|
||||
if (!ValidateSamplerParameterParams(mContext, funcName, pname, paramInt))
|
||||
return;
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_TEXTURE_MIN_FILTER:
|
||||
mMinFilter = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MAG_FILTER:
|
||||
mMagFilter = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_S:
|
||||
mWrapS = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_T:
|
||||
mWrapT = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_R:
|
||||
mWrapR = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_MODE:
|
||||
mCompareMode = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_FUNC:
|
||||
mCompareFunc = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MIN_LOD:
|
||||
mMinLod = paramInt;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MAX_LOD:
|
||||
mMaxLod = param;
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("GFX: Unhandled pname");
|
||||
break;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mContext->mBoundSamplers.Length(); ++i) {
|
||||
if (this == mContext->mBoundSamplers[i])
|
||||
mContext->InvalidateResolveCacheForTextureWithTexUnit(i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGLSampler::SamplerParameter1f(GLenum pname, GLfloat param)
|
||||
{
|
||||
switch (pname) {
|
||||
case LOCAL_GL_TEXTURE_MIN_LOD:
|
||||
mMinLod = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MAX_LOD:
|
||||
mMaxLod = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_S:
|
||||
mWrapS = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_T:
|
||||
mWrapT = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_WRAP_R:
|
||||
mWrapR = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MAG_FILTER:
|
||||
mMagFilter = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_MIN_FILTER:
|
||||
mMinFilter = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_MODE:
|
||||
mCompareMode = param;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_TEXTURE_COMPARE_FUNC:
|
||||
mCompareFunc = param;
|
||||
mMaxLod = paramInt;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -153,8 +192,14 @@ WebGLSampler::SamplerParameter1f(GLenum pname, GLfloat param)
|
||||
if (this == mContext->mBoundSamplers[i])
|
||||
mContext->InvalidateResolveCacheForTextureWithTexUnit(i);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
mContext->gl->MakeCurrent();
|
||||
mContext->gl->fSamplerParameteri(mGLName, pname, paramInt);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLSampler)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLSampler, AddRef)
|
||||
|
@ -32,11 +32,9 @@ public:
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
||||
|
||||
void SamplerParameter1i(GLenum pname, GLint param);
|
||||
void SamplerParameter1f(GLenum pname, GLfloat param);
|
||||
void SamplerParameter(const char* funcName, GLenum pname, GLint paramInt);
|
||||
|
||||
private:
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLSampler)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLSampler)
|
||||
|
||||
|
@ -29,7 +29,8 @@ WebGLUniformLocation::~WebGLUniformLocation()
|
||||
{ }
|
||||
|
||||
bool
|
||||
WebGLUniformLocation::ValidateForProgram(WebGLProgram* prog, const char* funcName) const
|
||||
WebGLUniformLocation::ValidateForProgram(const WebGLProgram* prog,
|
||||
const char* funcName) const
|
||||
{
|
||||
// Check the weak-pointer.
|
||||
if (!mLinkInfo) {
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo,
|
||||
webgl::UniformInfo* info, GLuint loc, size_t arrayIndex);
|
||||
|
||||
bool ValidateForProgram(WebGLProgram* prog, const char* funcName) const;
|
||||
bool ValidateForProgram(const WebGLProgram* prog, const char* funcName) const;
|
||||
bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
|
||||
const char* funcName) const;
|
||||
bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize,
|
||||
|
Loading…
Reference in New Issue
Block a user