Bug 1320030 - Simplify marking and deletion checks. - r=ethlin

This commit is contained in:
Jeff Gilbert 2016-11-29 18:30:28 -08:00
parent feeb6bb7b5
commit 51d744aa93
45 changed files with 262 additions and 443 deletions

View File

@ -314,7 +314,7 @@ public:
already_AddRefed<WebGLSampler> CreateSampler();
void DeleteSampler(WebGLSampler* sampler);
bool IsSampler(WebGLSampler* sampler);
bool IsSampler(const WebGLSampler* sampler);
void BindSampler(GLuint unit, WebGLSampler* sampler);
void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
@ -326,7 +326,7 @@ public:
// Sync objects - WebGL2ContextSync.cpp
already_AddRefed<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
bool IsSync(WebGLSync* sync);
bool IsSync(const WebGLSync* sync);
void DeleteSync(WebGLSync* sync);
GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout);
void WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout);
@ -339,7 +339,7 @@ public:
already_AddRefed<WebGLTransformFeedback> CreateTransformFeedback();
void DeleteTransformFeedback(WebGLTransformFeedback* tf);
bool IsTransformFeedback(WebGLTransformFeedback* tf);
bool IsTransformFeedback(const WebGLTransformFeedback* tf);
void BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf);
void BeginTransformFeedback(GLenum primitiveMode);
void EndTransformFeedback();

View File

@ -19,7 +19,7 @@ WebGL2Context::GetFragDataLocation(const WebGLProgram& prog, const nsAString& na
if (IsContextLost())
return -1;
if (!ValidateObjectRef("getFragDataLocation: program", prog))
if (!ValidateObject("getFragDataLocation: program", prog))
return -1;
return prog.GetFragDataLocation(name);

View File

@ -78,13 +78,7 @@ WebGLContext::DeleteQuery(WebGLQuery* query, const char* funcName)
funcName = "deleteQuery";
}
if (IsContextLost())
return;
if (!query)
return;
if (!ValidateObjectAllowDeleted(funcName, query))
if (!ValidateDeleteObject(funcName, query))
return;
query->DeleteQuery();
@ -97,13 +91,7 @@ WebGLContext::IsQuery(const WebGLQuery* query, const char* funcName)
funcName = "isQuery";
}
if (IsContextLost())
return false;
if (!query)
return false;
if (!ValidateObjectAllowDeleted("isQuery", query))
if (!ValidateIsObject(funcName, query))
return false;
return query->IsQuery();
@ -119,12 +107,9 @@ WebGLContext::BeginQuery(GLenum target, WebGLQuery& query, const char* funcName)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeleted(funcName, &query))
if (!ValidateObject(funcName, query))
return;
if (query.IsDeleted())
return ErrorInvalidOperation("%s: Cannot begin a deleted query.", funcName);
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
if (!slot)
return;
@ -238,12 +223,9 @@ WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery& query, GLenum pnam
if (IsContextLost())
return;
if (!ValidateObjectAllowDeleted(funcName, &query))
if (!ValidateObject(funcName, query))
return;
if (query.IsDeleted())
return ErrorInvalidOperation("%s: Query must not be deleted.", funcName);
query.GetQueryParameter(pname, retval);
}

View File

@ -26,13 +26,7 @@ WebGL2Context::CreateSampler()
void
WebGL2Context::DeleteSampler(WebGLSampler* sampler)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteSampler", sampler))
return;
if (!sampler || sampler->IsDeleted())
if (!ValidateDeleteObject("deleteSampler", sampler))
return;
for (int n = 0; n < mGLMaxTextureUnits; n++) {
@ -47,18 +41,9 @@ WebGL2Context::DeleteSampler(WebGLSampler* sampler)
}
bool
WebGL2Context::IsSampler(WebGLSampler* sampler)
WebGL2Context::IsSampler(const WebGLSampler* sampler)
{
if (IsContextLost())
return false;
if (!sampler)
return false;
if (!ValidateObjectAllowDeleted("isSampler", sampler))
return false;
if (sampler->IsDeleted())
if (!ValidateIsObject("isSampler", sampler))
return false;
MakeContextCurrent();
@ -71,15 +56,12 @@ WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindSampler", sampler))
if (sampler && !ValidateObject("bindSampler", *sampler))
return;
if (GLint(unit) >= mGLMaxTextureUnits)
return ErrorInvalidValue("bindSampler: unit must be < %d", mGLMaxTextureUnits);
if (sampler && sampler->IsDeleted())
return ErrorInvalidOperation("bindSampler: binding deleted sampler");
////
gl->MakeCurrent();
@ -96,7 +78,7 @@ WebGL2Context::SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint para
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sampler))
if (!ValidateObject(funcName, sampler))
return;
sampler.SamplerParameter(funcName, pname, paramInt);
@ -109,7 +91,7 @@ WebGL2Context::SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat pa
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sampler))
if (!ValidateObject(funcName, sampler))
return;
sampler.SamplerParameter(funcName, pname, WebGLIntOrFloat(paramFloat).AsInt());
@ -125,7 +107,7 @@ WebGL2Context::GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLen
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sampler))
if (!ValidateObject(funcName, sampler))
return;
////

View File

@ -16,43 +16,37 @@ namespace mozilla {
already_AddRefed<WebGLSync>
WebGL2Context::FenceSync(GLenum condition, GLbitfield flags)
{
if (IsContextLost())
return nullptr;
if (IsContextLost())
return nullptr;
if (condition != LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE) {
ErrorInvalidEnum("fenceSync: condition must be SYNC_GPU_COMMANDS_COMPLETE");
return nullptr;
}
if (condition != LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE) {
ErrorInvalidEnum("fenceSync: condition must be SYNC_GPU_COMMANDS_COMPLETE");
return nullptr;
}
if (flags != 0) {
ErrorInvalidValue("fenceSync: flags must be 0");
return nullptr;
}
if (flags != 0) {
ErrorInvalidValue("fenceSync: flags must be 0");
return nullptr;
}
MakeContextCurrent();
RefPtr<WebGLSync> globj = new WebGLSync(this, condition, flags);
return globj.forget();
MakeContextCurrent();
RefPtr<WebGLSync> globj = new WebGLSync(this, condition, flags);
return globj.forget();
}
bool
WebGL2Context::IsSync(WebGLSync* sync)
WebGL2Context::IsSync(const WebGLSync* sync)
{
if (IsContextLost())
return false;
if (!ValidateIsObject("isSync", sync))
return false;
return ValidateObjectAllowDeleted("isSync", sync) && !sync->IsDeleted();
return true;
}
void
WebGL2Context::DeleteSync(WebGLSync* sync)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteSync", sync))
return;
if (!sync || sync->IsDeleted())
if (!ValidateDeleteObject("deleteSync", sync))
return;
sync->RequestDelete();
@ -65,7 +59,7 @@ WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64
if (IsContextLost())
return LOCAL_GL_WAIT_FAILED;
if (!ValidateObjectRef(funcName, sync))
if (!ValidateObject(funcName, sync))
return LOCAL_GL_WAIT_FAILED;
if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
@ -84,7 +78,7 @@ WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sync))
if (!ValidateObject(funcName, sync))
return;
if (flags != 0) {
@ -110,7 +104,7 @@ WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sync))
if (!ValidateObject(funcName, sync))
return;
////

View File

@ -32,10 +32,7 @@ void
WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
{
const char funcName[] = "deleteTransformFeedback";
if (IsContextLost())
return;
if (!ValidateObject(funcName, tf))
if (!ValidateDeleteObject(funcName, tf))
return;
if (tf->mIsActive) {
@ -51,15 +48,9 @@ WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
}
bool
WebGL2Context::IsTransformFeedback(WebGLTransformFeedback* tf)
WebGL2Context::IsTransformFeedback(const WebGLTransformFeedback* tf)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeletedOrNull("isTransformFeedback", tf))
return false;
if (!tf || tf->IsDeleted())
if (!ValidateIsObject("isTransformFeedback", tf))
return false;
MakeContextCurrent();
@ -76,12 +67,9 @@ WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
if (target != LOCAL_GL_TRANSFORM_FEEDBACK)
return ErrorInvalidEnum("%s: `target` must be TRANSFORM_FEEDBACK.", funcName);
if (!ValidateObjectAllowDeletedOrNull(funcName, tf))
if (tf && !ValidateObject(funcName, *tf))
return;
if (tf && tf->IsDeleted())
return ErrorInvalidOperation("%s: TFO already deleted.", funcName);
if (mBoundTransformFeedback->mIsActive &&
!mBoundTransformFeedback->mIsPaused)
{
@ -143,7 +131,7 @@ WebGL2Context::TransformFeedbackVaryings(WebGLProgram& program,
if (IsContextLost())
return;
if (!ValidateObjectRef("transformFeedbackVaryings: program", program))
if (!ValidateObject("transformFeedbackVaryings: program", program))
return;
program.TransformFeedbackVaryings(varyings, bufferMode);
@ -155,7 +143,7 @@ WebGL2Context::GetTransformFeedbackVarying(const WebGLProgram& program, GLuint i
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getTransformFeedbackVarying: program", program))
if (!ValidateObject("getTransformFeedbackVarying: program", program))
return nullptr;
return program.GetTransformFeedbackVarying(index);

View File

@ -138,7 +138,7 @@ WebGL2Context::GetUniformIndices(const WebGLProgram& program,
if (IsContextLost())
return;
if (!ValidateObjectRef("getUniformIndices: program", program))
if (!ValidateObject("getUniformIndices: program", program))
return;
if (!uniformNames.Length())
@ -179,7 +179,7 @@ WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
if (!ValidateUniformEnum(this, pname, funcName))
return;
if (!ValidateObjectRef("getActiveUniforms: program", program))
if (!ValidateObject("getActiveUniforms: program", program))
return;
const auto& count = uniformIndices.Length();
@ -231,7 +231,7 @@ WebGL2Context::GetUniformBlockIndex(const WebGLProgram& program,
if (IsContextLost())
return 0;
if (!ValidateObjectRef("getUniformBlockIndex: program", program))
if (!ValidateObject("getUniformBlockIndex: program", program))
return 0;
return program.GetUniformBlockIndex(uniformBlockName);
@ -247,7 +247,7 @@ WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, const WebGLProgram&
if (IsContextLost())
return;
if (!ValidateObjectRef("getActiveUniformBlockParameter: program", program))
if (!ValidateObject("getActiveUniformBlockParameter: program", program))
return;
MakeContextCurrent();
@ -278,7 +278,7 @@ WebGL2Context::GetActiveUniformBlockName(const WebGLProgram& program,
if (IsContextLost())
return;
if (!ValidateObjectRef("getActiveUniformBlockName: program", program))
if (!ValidateObject("getActiveUniformBlockName: program", program))
return;
program.GetActiveUniformBlockName(uniformBlockIndex, retval);
@ -291,7 +291,7 @@ WebGL2Context::UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockInd
if (IsContextLost())
return;
if (!ValidateObjectRef("uniformBlockBinding: program", program))
if (!ValidateObject("uniformBlockBinding: program", program))
return;
program.UniformBlockBinding(uniformBlockIndex, uniformBlockBinding);

View File

@ -13,7 +13,7 @@
namespace mozilla {
WebGLBuffer::WebGLBuffer(WebGLContext* webgl, GLuint buf)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(buf)
, mContent(Kind::Undefined)
, mUsage(LOCAL_GL_STATIC_DRAW)

View File

@ -22,7 +22,6 @@ class WebGLBuffer final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLBuffer>
, public LinkedListElement<WebGLBuffer>
, public WebGLContextBoundObject
{
friend class WebGLContext;
friend class WebGL2Context;

View File

@ -222,7 +222,7 @@ WebGLContext::~WebGLContext()
}
template<typename T>
static void
void
ClearLinkedList(LinkedList<T>& list)
{
while (!list.isEmpty()) {

View File

@ -616,11 +616,11 @@ public:
GetUniformLocation(const WebGLProgram& prog, const nsAString& name);
void Hint(GLenum target, GLenum mode);
bool IsFramebuffer(WebGLFramebuffer* fb);
bool IsProgram(WebGLProgram* prog);
bool IsRenderbuffer(WebGLRenderbuffer* rb);
bool IsShader(WebGLShader* shader);
bool IsVertexArray(WebGLVertexArray* vao);
bool IsFramebuffer(const WebGLFramebuffer* fb);
bool IsProgram(const WebGLProgram* prog);
bool IsRenderbuffer(const WebGLRenderbuffer* rb);
bool IsShader(const WebGLShader* shader);
bool IsVertexArray(const WebGLVertexArray* vao);
void LineWidth(GLfloat width);
void LinkProgram(WebGLProgram& prog);
void PixelStorei(GLenum pname, GLint param);
@ -1628,33 +1628,69 @@ protected:
//////
public:
// Returns false if `object` is null or not valid.
template<class ObjectType>
bool ValidateObject(const char* info, const ObjectType* object);
bool ValidateObjectAllowDeleted(const char* funcName,
const WebGLContextBoundObject& object)
{
if (!object.IsCompatibleWithContext(this)) {
ErrorInvalidOperation("%s: Object from different WebGL context (or older"
" generation of this one) passed as argument.",
funcName);
return false;
}
// Returns false if `object` is not valid.
template<class ObjectType>
bool ValidateObjectRef(const char* info, const ObjectType& object);
return true;
}
// Returns false if `object` is not valid. Considers null to be valid.
template<class ObjectType>
bool ValidateObjectAllowNull(const char* info, const ObjectType* object);
bool ValidateObject(const char* funcName, const WebGLDeletableObject& object) {
if (!ValidateObjectAllowDeleted(funcName, object))
return false;
// Returns false if `object` is not valid, but considers deleted objects and
// null objects valid.
template<class ObjectType>
bool ValidateObjectAllowDeletedOrNull(const char* info, const ObjectType* object);
if (object.IsDeleteRequested()) {
ErrorInvalidOperation("%s: Object argument cannot be marked for deletion.",
funcName);
return false;
}
// Returns false if `object` is null or not valid, but considers deleted
// objects valid.
template<class ObjectType>
bool ValidateObjectAllowDeleted(const char* info, const ObjectType* object);
return true;
}
private:
// Like ValidateObject, but only for cases when `object` is known to not be
// null already.
template<class ObjectType>
bool ValidateObjectAssumeNonNull(const char* info, const ObjectType* object);
////
bool ValidateIsObject(const char* funcName,
const WebGLDeletableObject* object) const
{
if (IsContextLost())
return false;
if (!object)
return false;
if (!object->IsCompatibleWithContext(this))
return false;
if (object->IsDeleted())
return false;
return true;
}
bool ValidateDeleteObject(const char* funcName, const WebGLDeletableObject* object) {
if (IsContextLost())
return false;
if (!object)
return false;
if (!ValidateObjectAllowDeleted(funcName, *object))
return false;
if (object->IsDeleteRequested())
return false;
return true;
}
////
private:
// -------------------------------------------------------------------------
@ -1953,82 +1989,6 @@ ToSupports(WebGLContext* webgl)
return static_cast<nsIDOMWebGLRenderingContext*>(webgl);
}
/**
** Template implementations
**/
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAllowDeletedOrNull(const char* info, const ObjectType* object)
{
if (object && !object->IsCompatibleWithContext(this)) {
ErrorInvalidOperation("%s: object from different WebGL context "
"(or older generation of this one) "
"passed as argument", info);
return false;
}
return true;
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAssumeNonNull(const char* info, const ObjectType* object)
{
MOZ_ASSERT(object);
if (!ValidateObjectAllowDeletedOrNull(info, object))
return false;
if (object->IsDeleted()) {
ErrorInvalidValue("%s: Deleted object passed as argument.", info);
return false;
}
return true;
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAllowNull(const char* info, const ObjectType* object)
{
if (!object)
return true;
return ValidateObjectAssumeNonNull(info, object);
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAllowDeleted(const char* info, const ObjectType* object)
{
if (!object) {
ErrorInvalidValue("%s: null object passed as argument", info);
return false;
}
return ValidateObjectAllowDeletedOrNull(info, object);
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObject(const char* info, const ObjectType* object)
{
if (!object) {
ErrorInvalidValue("%s: null object passed as argument", info);
return false;
}
return ValidateObjectAssumeNonNull(info, object);
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectRef(const char* info, const ObjectType& object)
{
return ValidateObjectAssumeNonNull(info, &object);
}
// Returns `value` rounded to the next highest multiple of `multiple`.
// AKA PadToAlignment, StrideForAlignment.
template<typename V, typename M>

View File

@ -119,12 +119,9 @@ WebGLContext::BindBuffer(GLenum target, WebGLBuffer* buffer)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
if (buffer && !ValidateObject(funcName, *buffer))
return;
if (buffer && buffer->IsDeleted())
return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
const auto& slot = ValidateBufferSlot(funcName, target);
if (!slot)
return;
@ -183,12 +180,9 @@ WebGLContext::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
if (buffer && !ValidateObject(funcName, *buffer))
return;
if (buffer && buffer->IsDeleted())
return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
WebGLRefPtr<WebGLBuffer>* genericBinding;
IndexedBufferBinding* indexedBinding;
if (!ValidateIndexedBufferBinding(funcName, target, index, &genericBinding,
@ -234,12 +228,9 @@ WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
if (buffer && !ValidateObject(funcName, *buffer))
return;
if (buffer && buffer->IsDeleted())
return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
if (!ValidateNonNegative(funcName, "offset", offset) ||
!ValidateNonNegative(funcName, "size", size))
{
@ -476,13 +467,7 @@ WebGLContext::CreateBuffer()
void
WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteBuffer", buffer))
return;
if (!buffer || buffer->IsDeleted())
if (!ValidateDeleteObject("deleteBuffer", buffer))
return;
////
@ -530,13 +515,7 @@ WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
bool
WebGLContext::IsBuffer(WebGLBuffer* buffer)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isBuffer", buffer))
return false;
if (buffer->IsDeleted())
if (!ValidateIsObject("isBuffer", buffer))
return false;
MakeContextCurrent();

View File

@ -92,8 +92,8 @@ WebGLContext::AttachShader(WebGLProgram& program, WebGLShader& shader)
if (IsContextLost())
return;
if (!ValidateObjectRef("attachShader: program", program) ||
!ValidateObjectRef("attachShader: shader", shader))
if (!ValidateObject("attachShader: program", program) ||
!ValidateObject("attachShader: shader", shader))
{
return;
}
@ -108,7 +108,7 @@ WebGLContext::BindAttribLocation(WebGLProgram& prog, GLuint location,
if (IsContextLost())
return;
if (!ValidateObjectRef("bindAttribLocation: program", prog))
if (!ValidateObject("bindAttribLocation: program", prog))
return;
prog.BindAttribLocation(location, name);
@ -123,12 +123,9 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer* wfb)
if (!ValidateFramebufferTarget(target, "bindFramebuffer"))
return;
if (!ValidateObjectAllowDeletedOrNull("bindFramebuffer", wfb))
if (wfb && !ValidateObject("bindFramebuffer", *wfb))
return;
if (wfb && wfb->IsDeleted())
return ErrorInvalidOperation("bindFramebuffer: Cannot bind a deleted object.");
MakeContextCurrent();
if (!wfb) {
@ -166,12 +163,9 @@ WebGLContext::BindRenderbuffer(GLenum target, WebGLRenderbuffer* wrb)
if (target != LOCAL_GL_RENDERBUFFER)
return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
if (!ValidateObjectAllowDeletedOrNull("bindRenderbuffer", wrb))
if (wrb && !ValidateObject("bindRenderbuffer", *wrb))
return;
if (wrb && wrb->IsDeleted())
return ErrorInvalidOperation("bindRenderbuffer: Cannot bind a deleted object.");
// Usually, we would now call into glBindRenderbuffer. However, since we have to
// potentially emulate packed-depth-stencil, there's not a specific renderbuffer that
// we know we should bind here.
@ -320,13 +314,7 @@ WebGLContext::CullFace(GLenum face)
void
WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteFramebuffer", fbuf))
return;
if (!fbuf || fbuf->IsDeleted())
if (!ValidateDeleteObject("deleteFramebuffer", fbuf))
return;
fbuf->RequestDelete();
@ -348,13 +336,7 @@ WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
void
WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer* rbuf)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteRenderbuffer", rbuf))
return;
if (!rbuf || rbuf->IsDeleted())
if (!ValidateDeleteObject("deleteRenderbuffer", rbuf))
return;
if (mBoundDrawFramebuffer)
@ -374,13 +356,7 @@ WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer* rbuf)
void
WebGLContext::DeleteTexture(WebGLTexture* tex)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteTexture", tex))
return;
if (!tex || tex->IsDeleted())
if (!ValidateDeleteObject("deleteTexture", tex))
return;
if (mBoundDrawFramebuffer)
@ -408,13 +384,7 @@ WebGLContext::DeleteTexture(WebGLTexture* tex)
void
WebGLContext::DeleteProgram(WebGLProgram* prog)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteProgram", prog))
return;
if (!prog || prog->IsDeleted())
if (!ValidateDeleteObject("deleteProgram", prog))
return;
prog->RequestDelete();
@ -423,13 +393,7 @@ WebGLContext::DeleteProgram(WebGLProgram* prog)
void
WebGLContext::DeleteShader(WebGLShader* shader)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteShader", shader))
return;
if (!shader || shader->IsDeleted())
if (!ValidateDeleteObject("deleteShader", shader))
return;
shader->RequestDelete();
@ -443,8 +407,8 @@ WebGLContext::DetachShader(WebGLProgram& program, const WebGLShader& shader)
// It's valid to attempt to detach a deleted shader, since it's still a
// shader.
if (!ValidateObjectRef("detachShader: program", program) ||
!ValidateObjectAllowDeleted("detachShader: shader", &shader))
if (!ValidateObject("detachShader: program", program) ||
!ValidateObjectAllowDeleted("detachShader: shader", shader))
{
return;
}
@ -569,7 +533,7 @@ WebGLContext::GetActiveAttrib(const WebGLProgram& prog, GLuint index)
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getActiveAttrib: program", prog))
if (!ValidateObject("getActiveAttrib: program", prog))
return nullptr;
return prog.GetActiveAttrib(index);
@ -581,7 +545,7 @@ WebGLContext::GetActiveUniform(const WebGLProgram& prog, GLuint index)
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getActiveUniform: program", prog))
if (!ValidateObject("getActiveUniform: program", prog))
return nullptr;
return prog.GetActiveUniform(index);
@ -595,7 +559,7 @@ WebGLContext::GetAttachedShaders(const WebGLProgram& prog,
if (IsContextLost())
return;
if (!ValidateObjectRef("getAttachedShaders", prog))
if (!ValidateObject("getAttachedShaders", prog))
return;
prog.GetAttachedShaders(&retval.SetValue());
@ -607,7 +571,7 @@ WebGLContext::GetAttribLocation(const WebGLProgram& prog, const nsAString& name)
if (IsContextLost())
return -1;
if (!ValidateObjectRef("getAttribLocation: program", prog))
if (!ValidateObject("getAttribLocation: program", prog))
return -1;
return prog.GetAttribLocation(name);
@ -910,7 +874,7 @@ 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);
@ -924,7 +888,7 @@ WebGLContext::GetProgramInfoLog(const WebGLProgram& prog, nsAString& retval)
if (IsContextLost())
return;
if (!ValidateObjectRef("getProgramInfoLog: program", prog))
if (!ValidateObject("getProgramInfoLog: program", prog))
return;
prog.GetProgramInfoLog(&retval);
@ -937,10 +901,10 @@ WebGLContext::GetUniform(JSContext* js, const WebGLProgram& prog,
if (IsContextLost())
return JS::NullValue();
if (!ValidateObjectRef("getUniform: `program`", prog))
if (!ValidateObject("getUniform: `program`", prog))
return JS::NullValue();
if (!ValidateObjectRef("getUniform: `location`", loc))
if (!ValidateObjectAllowDeleted("getUniform: `location`", loc))
return JS::NullValue();
if (!loc.ValidateForProgram(&prog, "getUniform"))
@ -955,7 +919,7 @@ WebGLContext::GetUniformLocation(const WebGLProgram& prog, const nsAString& name
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getUniformLocation: program", prog))
if (!ValidateObject("getUniformLocation: program", prog))
return nullptr;
return prog.GetUniformLocation(name);
@ -995,15 +959,9 @@ WebGLContext::Hint(GLenum target, GLenum mode)
}
bool
WebGLContext::IsFramebuffer(WebGLFramebuffer* fb)
WebGLContext::IsFramebuffer(const WebGLFramebuffer* fb)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isFramebuffer", fb))
return false;
if (fb->IsDeleted())
if (!ValidateIsObject("isFramebuffer", fb))
return false;
#ifdef ANDROID
@ -1019,37 +977,30 @@ WebGLContext::IsFramebuffer(WebGLFramebuffer* fb)
}
bool
WebGLContext::IsProgram(WebGLProgram* prog)
WebGLContext::IsProgram(const WebGLProgram* prog)
{
if (IsContextLost())
if (!ValidateIsObject("isProgram", prog))
return false;
return ValidateObjectAllowDeleted("isProgram", prog) && !prog->IsDeleted();
return true;
}
bool
WebGLContext::IsRenderbuffer(WebGLRenderbuffer* rb)
WebGLContext::IsRenderbuffer(const WebGLRenderbuffer* rb)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isRenderBuffer", rb))
return false;
if (rb->IsDeleted())
if (!ValidateIsObject("isRenderbuffer", rb))
return false;
return rb->mHasBeenBound;
}
bool
WebGLContext::IsShader(WebGLShader* shader)
WebGLContext::IsShader(const WebGLShader* shader)
{
if (IsContextLost())
if (!ValidateIsObject("isShader", shader))
return false;
return ValidateObjectAllowDeleted("isShader", shader) &&
!shader->IsDeleted();
return true;
}
void
@ -1058,7 +1009,7 @@ WebGLContext::LinkProgram(WebGLProgram& prog)
if (IsContextLost())
return;
if (!ValidateObjectRef("linkProgram", prog))
if (!ValidateObject("linkProgram", prog))
return;
prog.LinkProgram();
@ -2101,7 +2052,7 @@ WebGLContext::UseProgram(WebGLProgram* prog)
return;
}
if (!ValidateObject("useProgram", prog))
if (!ValidateObject("useProgram", *prog))
return;
if (prog->UseProgram()) {
@ -2116,7 +2067,7 @@ WebGLContext::ValidateProgram(const WebGLProgram& prog)
if (IsContextLost())
return;
if (!ValidateObjectRef("validateProgram", prog))
if (!ValidateObject("validateProgram", prog))
return;
prog.ValidateProgram();
@ -2171,7 +2122,7 @@ WebGLContext::CompileShader(WebGLShader& shader)
if (IsContextLost())
return;
if (!ValidateObjectRef("compileShader", shader))
if (!ValidateObject("compileShader", shader))
return;
shader.CompileShader();
@ -2183,7 +2134,7 @@ WebGLContext::GetShaderParameter(const WebGLShader& shader, GLenum pname)
if (IsContextLost())
return JS::NullValue();
if (!ValidateObjectRef("getShaderParameter: shader", shader))
if (!ValidateObjectAllowDeleted("getShaderParameter: shader", shader))
return JS::NullValue();
return shader.GetShaderParameter(pname);
@ -2197,7 +2148,7 @@ WebGLContext::GetShaderInfoLog(const WebGLShader& shader, nsAString& retval)
if (IsContextLost())
return;
if (!ValidateObjectRef("getShaderInfoLog: shader", shader))
if (!ValidateObject("getShaderInfoLog: shader", shader))
return;
shader.GetShaderInfoLog(&retval);
@ -2259,7 +2210,7 @@ WebGLContext::GetShaderSource(const WebGLShader& shader, nsAString& retval)
if (IsContextLost())
return;
if (!ValidateObjectRef("getShaderSource: shader", shader))
if (!ValidateObject("getShaderSource: shader", shader))
return;
shader.GetShaderSource(&retval);
@ -2271,7 +2222,7 @@ WebGLContext::ShaderSource(WebGLShader& shader, const nsAString& source)
if (IsContextLost())
return;
if (!ValidateObjectRef("shaderSource: shader", shader))
if (!ValidateObject("shaderSource: shader", shader))
return;
shader.ShaderSource(source);

View File

@ -209,7 +209,7 @@ WebGLContext::BindTexture(GLenum rawTarget, WebGLTexture* newTex)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindTexture", newTex))
if (newTex && !ValidateObject("bindTexture", *newTex))
return;
// Need to check rawTarget first before comparing against newTex->Target() as
@ -290,10 +290,7 @@ WebGLContext::GetTexParameter(GLenum rawTexTarget, GLenum pname)
bool
WebGLContext::IsTexture(WebGLTexture* tex)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isTexture", tex))
if (!ValidateIsObject("isTexture", tex))
return false;
return tex->IsTexture();

View File

@ -207,7 +207,7 @@ WebGLContext::ValidateUniformLocation(WebGLUniformLocation* loc, const char* fun
if (!loc)
return false;
if (!ValidateObject(funcName, loc))
if (!ValidateObjectAllowDeleted(funcName, *loc))
return false;
if (!mCurrentProgram) {

View File

@ -18,20 +18,9 @@ WebGLContext::BindVertexArray(WebGLVertexArray* array)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindVertexArrayObject", array))
if (array && !ValidateObject("bindVertexArrayObject", *array))
return;
if (array && array->IsDeleted()) {
/* http://www.khronos.org/registry/gles/extensions/OES/OES_vertex_array_object.txt
* BindVertexArrayOES fails and an INVALID_OPERATION error is
* generated if array is not a name returned from a previous call to
* GenVertexArraysOES, or if such a name has since been deleted with
* DeleteVertexArraysOES
*/
ErrorInvalidOperation("bindVertexArray: can't bind a deleted array!");
return;
}
InvalidateBufferFetching();
MakeContextCurrent();
@ -68,13 +57,7 @@ WebGLContext::CreateVertexArrayImpl()
void
WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
{
if (IsContextLost())
return;
if (array == nullptr)
return;
if (array->IsDeleted())
if (!ValidateDeleteObject("deleteVertexArray", array))
return;
if (mBoundVertexArray == array)
@ -84,18 +67,9 @@ WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
}
bool
WebGLContext::IsVertexArray(WebGLVertexArray* array)
WebGLContext::IsVertexArray(const WebGLVertexArray* array)
{
if (IsContextLost())
return false;
if (!array)
return false;
if (!ValidateObjectAllowDeleted("isVertexArray", array))
return false;
if (array->IsDeleted())
if (!ValidateIsObject("isVertexArray", array))
return false;
MakeContextCurrent();

View File

@ -38,7 +38,7 @@ WebGLExtensionDebugShaders::GetTranslatedShaderSource(const WebGLShader& shader,
if (mContext->IsContextLost())
return;
if (!mContext->ValidateObjectRef("getShaderTranslatedSource: shader", shader))
if (!mContext->ValidateObject("getShaderTranslatedSource: shader", shader))
return;
shader.GetShaderTranslatedSource(&retval);

View File

@ -83,7 +83,7 @@ WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum targ
if (mIsLost)
return;
if (!mContext->ValidateObjectRef(funcName, query))
if (!mContext->ValidateObject(funcName, query))
return;
query.QueryCounter(funcName, target);

View File

@ -41,7 +41,7 @@ WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
}
bool
WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
WebGLExtensionVertexArray::IsVertexArrayOES(const WebGLVertexArray* array)
{
if (mIsLost)
return false;

View File

@ -344,7 +344,7 @@ public:
already_AddRefed<WebGLVertexArray> CreateVertexArrayOES();
void DeleteVertexArrayOES(WebGLVertexArray* array);
bool IsVertexArrayOES(WebGLVertexArray* array);
bool IsVertexArrayOES(const WebGLVertexArray* array);
void BindVertexArrayOES(WebGLVertexArray* array);
DECL_WEBGL_EXTENSION_GOOP

View File

@ -604,7 +604,7 @@ WebGLFBAttachPoint::GetParameter(const char* funcName, WebGLContext* webgl, JSCo
// WebGLFramebuffer
WebGLFramebuffer::WebGLFramebuffer(WebGLContext* webgl, GLuint fbo)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(fbo)
#ifdef ANDROID
, mIsFB(false)
@ -1301,7 +1301,7 @@ WebGLFramebuffer::FramebufferRenderbuffer(const char* funcName, GLenum attachEnu
}
// `rb`
if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: rb", rb))
if (rb && !mContext->ValidateObject("framebufferRenderbuffer: rb", *rb))
return;
// End of validation.
@ -1343,10 +1343,10 @@ WebGLFramebuffer::FramebufferTexture2D(const char* funcName, GLenum attachEnum,
}
// `texture`
if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture", tex))
return;
if (tex) {
if (!mContext->ValidateObject("framebufferTexture2D: texture", *tex))
return;
if (!tex->HasEverBeenBound()) {
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.",
funcName);
@ -1419,15 +1419,6 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
}
const auto& attach = maybeAttach.value();
// `texture`
if (!mContext->ValidateObjectAllowNull("framebufferTextureLayer: texture", tex))
return;
if (tex && !tex->HasEverBeenBound()) {
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.", funcName);
return;
}
// `level`, `layer`
if (layer < 0)
return mContext->ErrorInvalidValue("%s: `layer` must be >= 0.", funcName);
@ -1435,8 +1426,18 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
if (level < 0)
return mContext->ErrorInvalidValue("%s: `level` must be >= 0.", funcName);
// `texture`
TexImageTarget texImageTarget = LOCAL_GL_TEXTURE_3D;
if (tex) {
if (!mContext->ValidateObject("framebufferTextureLayer: texture", *tex))
return;
if (!tex->HasEverBeenBound()) {
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.",
funcName);
return;
}
texImageTarget = tex->Target().get();
switch (texImageTarget.get()) {
case LOCAL_GL_TEXTURE_3D:

View File

@ -132,7 +132,6 @@ class WebGLFramebuffer final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLFramebuffer>
, public LinkedListElement<WebGLFramebuffer>
, public WebGLContextBoundObject
, public SupportsWeakPtr<WebGLFramebuffer>
{
friend class WebGLContext;

View File

@ -12,8 +12,55 @@
namespace mozilla {
template<typename> class LinkedList;
class WebGLContext;
////
// This class is a mixin for objects that are tied to a specific
// context (which is to say, all of them). They provide initialization
// as well as comparison with the current context.
class WebGLContextBoundObject
{
public:
WebGLContext* const mContext;
private:
const uint32_t mContextGeneration;
public:
explicit WebGLContextBoundObject(WebGLContext* webgl);
bool IsCompatibleWithContext(const WebGLContext* other) const;
};
////
class WebGLDeletableObject : public WebGLContextBoundObject
{
template<typename> friend class WebGLRefCountedObject;
private:
enum DeletionStatus { Default, DeleteRequested, Deleted };
DeletionStatus mDeletionStatus;
////
explicit WebGLDeletableObject(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
, mDeletionStatus(Default)
{}
~WebGLDeletableObject() {
MOZ_ASSERT(mDeletionStatus == Deleted,
"Derived class destructor must call DeleteOnce().");
}
public:
bool IsDeleted() const { return mDeletionStatus == Deleted; }
bool IsDeleteRequested() const { return mDeletionStatus != Default; }
};
/* Each WebGL object class WebGLFoo wants to:
* - inherit WebGLRefCountedObject<WebGLFoo>
* - implement a Delete() method
@ -91,22 +138,25 @@ class WebGLContext;
* class, without either method being virtual. This is a common C++ pattern
* known as the "curiously recursive template pattern (CRTP)".
*/
template<typename Derived>
class WebGLRefCountedObject
{
public:
enum DeletionStatus { Default, DeleteRequested, Deleted };
WebGLRefCountedObject()
: mDeletionStatus(Default)
{}
template<typename Derived>
class WebGLRefCountedObject : public WebGLDeletableObject
{
friend class WebGLContext;
template<typename T> friend void ClearLinkedList(LinkedList<T>& list);
private:
nsAutoRefCnt mWebGLRefCnt;
public:
WebGLRefCountedObject(WebGLContext* webgl)
: WebGLDeletableObject(webgl)
{ }
~WebGLRefCountedObject() {
MOZ_ASSERT(mWebGLRefCnt == 0,
"Destroying WebGL object still referenced by other WebGL"
" objects.");
MOZ_ASSERT(mDeletionStatus == Deleted,
"Derived class destructor must call DeleteOnce().");
}
// called by WebGLRefPtr
@ -129,14 +179,7 @@ public:
MaybeDelete();
}
bool IsDeleted() const {
return mDeletionStatus == Deleted;
}
bool IsDeleteRequested() const {
return mDeletionStatus != Default;
}
protected:
void DeleteOnce() {
if (mDeletionStatus != Deleted) {
static_cast<Derived*>(this)->Delete();
@ -152,10 +195,6 @@ private:
DeleteOnce();
}
}
protected:
nsAutoRefCnt mWebGLRefCnt;
DeletionStatus mDeletionStatus;
};
/* This WebGLRefPtr class is meant to be used for references between WebGL
@ -259,21 +298,6 @@ protected:
T* mRawPtr;
};
// This class is a mixin for objects that are tied to a specific
// context (which is to say, all of them). They provide initialization
// as well as comparison with the current context.
class WebGLContextBoundObject
{
public:
explicit WebGLContextBoundObject(WebGLContext* webgl);
bool IsCompatibleWithContext(const WebGLContext* other) const;
WebGLContext* const mContext;
protected:
const uint32_t mContextGeneration;
};
// this class is a mixin for GL objects that have dimensions
// that we need to track.
class WebGLRectangleObject

View File

@ -443,7 +443,7 @@ CreateProgram(gl::GLContext* gl)
}
WebGLProgram::WebGLProgram(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(CreateProgram(webgl->GL()))
, mNumActiveTFOs(0)
, mNextLink_TransformFeedbackBufferMode(LOCAL_GL_SEPARATE_ATTRIBS)

View File

@ -130,7 +130,6 @@ class WebGLProgram final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLProgram>
, public LinkedListElement<WebGLProgram>
, public WebGLContextBoundObject
{
friend class WebGLTransformFeedback;

View File

@ -40,7 +40,7 @@ GenQuery(gl::GLContext* gl)
}
WebGLQuery::WebGLQuery(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(GenQuery(mContext->gl))
, mTarget(0)
, mActiveSlot(nullptr)
@ -211,8 +211,7 @@ WebGLQuery::GetQueryParameter(GLenum pname, JS::MutableHandleValue retval) const
bool
WebGLQuery::IsQuery() const
{
if (IsDeleted())
return false;
MOZ_ASSERT(!IsDeleted());
if (!mTarget)
return false;
@ -223,8 +222,7 @@ WebGLQuery::IsQuery() const
void
WebGLQuery::DeleteQuery()
{
if (IsDeleted())
return;
MOZ_ASSERT(!IsDeleteRequested());
if (mActiveSlot) {
EndQuery();

View File

@ -18,7 +18,6 @@ class WebGLQuery final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLQuery>
, public LinkedListElement<WebGLQuery>
, public WebGLContextBoundObject
{
friend class AvailableRunnable;
friend class WebGLRefCountedObject<WebGLQuery>;

View File

@ -47,7 +47,7 @@ EmulatePackedDepthStencil(gl::GLContext* gl)
}
WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mPrimaryRB( DoCreateRenderbuffer(webgl->gl) )
, mEmulatePackedDepthStencil( EmulatePackedDepthStencil(webgl->gl) )
, mSecondaryRB(0)

View File

@ -23,7 +23,6 @@ class WebGLRenderbuffer final
, public WebGLRefCountedObject<WebGLRenderbuffer>
, public LinkedListElement<WebGLRenderbuffer>
, public WebGLRectangleObject
, public WebGLContextBoundObject
, public WebGLFramebufferAttachable
{
friend class WebGLContext;

View File

@ -12,7 +12,7 @@
namespace mozilla {
WebGLSampler::WebGLSampler(WebGLContext* webgl, GLuint sampler)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(sampler)
, mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR)
, mMagFilter(LOCAL_GL_LINEAR)

View File

@ -17,7 +17,6 @@ class WebGLSampler final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLSampler>
, public LinkedListElement<WebGLSampler>
, public WebGLContextBoundObject
{
friend class WebGLContext2;
friend class WebGLTexture;

View File

@ -141,7 +141,7 @@ CreateShader(gl::GLContext* gl, GLenum type)
}
WebGLShader::WebGLShader(WebGLContext* webgl, GLenum type)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(CreateShader(webgl->GL(), type))
, mType(type)
, mTranslationSuccessful(false)

View File

@ -28,7 +28,6 @@ class WebGLShader final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLShader>
, public LinkedListElement<WebGLShader>
, public WebGLContextBoundObject
{
friend class WebGLContext;
friend class WebGLProgram;

View File

@ -12,7 +12,7 @@
namespace mozilla {
WebGLSync::WebGLSync(WebGLContext* webgl, GLenum condition, GLbitfield flags)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
{
mContext->mSyncs.insertBack(this);
mGLName = mContext->gl->fFenceSync(condition, flags);

View File

@ -16,7 +16,6 @@ class WebGLSync final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLSync>
, public LinkedListElement<WebGLSync>
, public WebGLContextBoundObject
{
friend class WebGL2Context;

View File

@ -127,7 +127,7 @@ WebGLTexture::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) {
}
WebGLTexture::WebGLTexture(WebGLContext* webgl, GLuint tex)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(tex)
, mTarget(LOCAL_GL_NONE)
, mFaceCount(0)

View File

@ -57,7 +57,6 @@ class WebGLTexture final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLTexture>
, public LinkedListElement<WebGLTexture>
, public WebGLContextBoundObject
{
// Friends
friend class WebGLContext;

View File

@ -12,7 +12,7 @@
namespace mozilla {
WebGLTransformFeedback::WebGLTransformFeedback(WebGLContext* webgl, GLuint tf)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(tf)
, mIndexedBindings(webgl->mGLMaxTransformFeedbackSeparateAttribs)
, mIsPaused(false)

View File

@ -16,7 +16,6 @@ class WebGLTransformFeedback final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLTransformFeedback>
, public LinkedListElement<WebGLTransformFeedback>
, public WebGLContextBoundObject
{
friend class ScopedDrawWithTransformFeedback;
friend class WebGLContext;

View File

@ -21,7 +21,7 @@ WebGLVertexArray::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
}
WebGLVertexArray::WebGLVertexArray(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(0)
{
mContext->mVertexArrays.insertBack(this);
@ -50,7 +50,7 @@ WebGLVertexArray::Delete()
}
bool
WebGLVertexArray::IsVertexArray()
WebGLVertexArray::IsVertexArray() const
{
return IsVertexArrayImpl();
}

View File

@ -23,7 +23,6 @@ class WebGLVertexArray
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLVertexArray>
, public LinkedListElement<WebGLVertexArray>
, public WebGLContextBoundObject
{
public:
static WebGLVertexArray* Create(WebGLContext* webgl);
@ -44,7 +43,7 @@ public:
// Implement parent classes:
void Delete();
bool IsVertexArray();
bool IsVertexArray() const;
WebGLContext* GetParentObject() const {
return mContext;
@ -67,7 +66,7 @@ protected:
virtual void GenVertexArray() = 0;
virtual void BindVertexArrayImpl() = 0;
virtual void DeleteImpl() = 0;
virtual bool IsVertexArrayImpl() = 0;
virtual bool IsVertexArrayImpl() const = 0;
GLuint mGLName;
nsTArray<WebGLVertexAttribData> mAttribs;

View File

@ -62,7 +62,7 @@ WebGLVertexArrayFake::DeleteImpl()
}
bool
WebGLVertexArrayFake::IsVertexArrayImpl()
WebGLVertexArrayFake::IsVertexArrayImpl() const
{
return mIsVAO;
}

View File

@ -19,7 +19,7 @@ protected:
virtual void BindVertexArrayImpl() override;
virtual void DeleteImpl() override;
virtual void GenVertexArray() override {};
virtual bool IsVertexArrayImpl() override;
virtual bool IsVertexArrayImpl() const override;
private:
explicit WebGLVertexArrayFake(WebGLContext* webgl);

View File

@ -47,7 +47,7 @@ WebGLVertexArrayGL::GenVertexArray()
}
bool
WebGLVertexArrayGL::IsVertexArrayImpl()
WebGLVertexArrayGL::IsVertexArrayImpl() const
{
gl::GLContext* gl = mContext->gl;
if (gl->WorkAroundDriverBugs())

View File

@ -19,7 +19,7 @@ public:
virtual void DeleteImpl() override;
virtual void BindVertexArrayImpl() override;
virtual void GenVertexArray() override;
virtual bool IsVertexArrayImpl() override;
virtual bool IsVertexArrayImpl() const override;
protected:
explicit WebGLVertexArrayGL(WebGLContext* webgl);