Bug 1288643 - Delete on Detach. - r=jerry
MozReview-Commit-ID: 7nI0SYFqf1
--- a/dom/canvas/WebGLBuffer.cpp
+++ b/dom/canvas/WebGLBuffer.cpp
@@ -18,17 +18,17 @@ WebGLBuffer::WebGLBuffer(WebGLContext* w
, mContent(Kind::Undefined)
, mByteLength(0)
{
mContext->mBuffers.insertBack(this);
}
WebGLBuffer::~WebGLBuffer()
{
- DeleteOnce();
+ DetachOnce();
}
void
WebGLBuffer::BindTo(GLenum target)
{
switch (target) {
case LOCAL_GL_ELEMENT_ARRAY_BUFFER:
mContent = Kind::ElementArray;
--- a/dom/canvas/WebGLFramebuffer.h
+++ b/dom/canvas/WebGLFramebuffer.h
@@ -205,17 +205,17 @@ private:
bool mIsFB;
#endif
public:
WebGLFramebuffer(WebGLContext* webgl, GLuint fbo);
private:
~WebGLFramebuffer() {
- DeleteOnce();
+ DetachOnce();
}
const WebGLRectangleObject& GetAnyRectObject() const;
public:
void Delete();
void FramebufferRenderbuffer(GLenum attachment, RBTarget rbtarget,
--- a/dom/canvas/WebGLObjectModel.h
+++ b/dom/canvas/WebGLObjectModel.h
@@ -148,16 +148,20 @@ private:
void MaybeDelete() {
if (mWebGLRefCnt == 0 &&
mDeletionStatus == DeleteRequested)
{
DeleteOnce();
}
}
+ virtual void DetachImpl() override {
+ DeleteOnce();
+ }
+
protected:
nsAutoRefCnt mWebGLRefCnt;
DeletionStatus mDeletionStatus;
};
/* This WebGLRefPtr class is meant to be used for references between WebGL
* objects. For example, a WebGLProgram holds WebGLRefPtr's to the WebGLShader's
* attached to it.
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -434,17 +434,17 @@ WebGLProgram::WebGLProgram(WebGLContext*
, mGLName(CreateProgram(webgl->GL()))
, mTransformFeedbackBufferMode(LOCAL_GL_NONE)
{
mContext->mPrograms.insertBack(this);
}
WebGLProgram::~WebGLProgram()
{
- DeleteOnce();
+ DetachOnce();
}
void
WebGLProgram::Delete()
{
gl::GLContext* gl = mContext->GL();
gl->MakeCurrent();
--- a/dom/canvas/WebGLQuery.h
+++ b/dom/canvas/WebGLQuery.h
@@ -56,17 +56,17 @@ public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQuery)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQuery)
// Track whether the event loop has spun
bool mCanBeAvailable;
private:
~WebGLQuery() {
- DeleteOnce();
+ DetachOnce();
};
GLuint mGLName;
GLenum mType;
friend class WebGL2Context;
};
--- a/dom/canvas/WebGLRenderbuffer.h
+++ b/dom/canvas/WebGLRenderbuffer.h
@@ -77,17 +77,17 @@ public:
GLenum internalFormat, uint32_t width, uint32_t height);
// Only handles a subset of `pname`s.
GLint GetRenderbufferParameter(RBTarget target, RBParam pname) const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
protected:
~WebGLRenderbuffer() {
- DeleteOnce();
+ DetachOnce();
}
void DoFramebufferRenderbuffer(GLenum attachment) const;
GLenum DoRenderbufferStorage(uint32_t samples, const webgl::FormatUsageInfo* format,
uint32_t width, uint32_t height);
};
} // namespace mozilla
--- a/dom/canvas/WebGLSampler.cpp
+++ b/dom/canvas/WebGLSampler.cpp
@@ -24,17 +24,17 @@ WebGLSampler::WebGLSampler(WebGLContext*
, mCompareMode(LOCAL_GL_NONE)
, mCompareFunc(LOCAL_GL_LEQUAL)
{
mContext->mSamplers.insertBack(this);
}
WebGLSampler::~WebGLSampler()
{
- DeleteOnce();
+ DetachOnce();
}
void
WebGLSampler::Delete()
{
mContext->MakeContextCurrent();
mContext->gl->fDeleteSamplers(1, &mGLName);
--- a/dom/canvas/WebGLShader.cpp
+++ b/dom/canvas/WebGLShader.cpp
@@ -147,17 +147,17 @@ WebGLShader::WebGLShader(WebGLContext* w
, mTranslationSuccessful(false)
, mCompilationSuccessful(false)
{
mContext->mShaders.insertBack(this);
}
WebGLShader::~WebGLShader()
{
- DeleteOnce();
+ DetachOnce();
}
void
WebGLShader::ShaderSource(const nsAString& source)
{
StripComments stripComments(source);
const nsAString& cleanSource = Substring(stripComments.result().Elements(),
stripComments.length());
--- a/dom/canvas/WebGLShaderPrecisionFormat.h
+++ b/dom/canvas/WebGLShaderPrecisionFormat.h
@@ -38,16 +38,18 @@ public:
}
NS_INLINE_DECL_REFCOUNTING(WebGLShaderPrecisionFormat)
private:
// Private destructor, to discourage deletion outside of Release():
~WebGLShaderPrecisionFormat() { }
+ virtual void DetachImpl() override { }
+
GLint mRangeMin;
GLint mRangeMax;
GLint mPrecision;
};
} // namespace mozilla
#endif // WEBGL_SHADER_PRECISION_FORMAT_H_
--- a/dom/canvas/WebGLSync.cpp
+++ b/dom/canvas/WebGLSync.cpp
@@ -15,17 +15,17 @@ WebGLSync::WebGLSync(WebGLContext* webgl
: WebGLContextBoundObject(webgl)
{
mContext->mSyncs.insertBack(this);
mGLName = mContext->gl->fFenceSync(condition, flags);
}
WebGLSync::~WebGLSync()
{
- DeleteOnce();
+ DetachOnce();
}
void
WebGLSync::Delete()
{
mContext->MakeContextCurrent();
mContext->gl->fDeleteSync(mGLName);
mGLName = 0;
--- a/dom/canvas/WebGLTexture.h
+++ b/dom/canvas/WebGLTexture.h
@@ -200,17 +200,17 @@ public:
WebGLContext* GetParentObject() const {
return mContext;
}
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
protected:
~WebGLTexture() {
- DeleteOnce();
+ DetachOnce();
}
public:
////////////////////////////////////
// GL calls
bool BindTexture(TexTarget texTarget);
void GenerateMipmap(TexTarget texTarget);
JS::Value GetTexParameter(TexTarget texTarget, GLenum pname);
--- a/dom/canvas/WebGLTimerQuery.cpp
+++ b/dom/canvas/WebGLTimerQuery.cpp
@@ -26,17 +26,17 @@ WebGLTimerQuery::WebGLTimerQuery(WebGLCo
, mTarget(LOCAL_GL_NONE)
, mCanBeAvailable(false)
{
mContext->mTimerQueries.insertBack(this);
}
WebGLTimerQuery::~WebGLTimerQuery()
{
- DeleteOnce();
+ DetachOnce();
}
WebGLTimerQuery*
WebGLTimerQuery::Create(WebGLContext* webgl)
{
GLuint name = 0;
webgl->MakeContextCurrent();
webgl->gl->fGenQueries(1, &name);
--- a/dom/canvas/WebGLTransformFeedback.cpp
+++ b/dom/canvas/WebGLTransformFeedback.cpp
@@ -22,17 +22,17 @@ WebGLTransformFeedback::WebGLTransformFe
mContext->mTransformFeedbacks.insertBack(this);
}
WebGLTransformFeedback::~WebGLTransformFeedback()
{
mMode = LOCAL_GL_NONE;
mIsActive = false;
mIsPaused = false;
- DeleteOnce();
+ DetachOnce();
}
void
WebGLTransformFeedback::Delete()
{
mContext->MakeContextCurrent();
mContext->gl->fDeleteTransformFeedbacks(1, &mGLName);
removeFrom(mContext->mTransformFeedbacks);
--- a/dom/canvas/WebGLUniformLocation.h
+++ b/dom/canvas/WebGLUniformLocation.h
@@ -60,13 +60,16 @@ public:
JS::Value GetUniform(JSContext* js) const;
// Needed for certain helper functions like ValidateObject.
// `WebGLUniformLocation`s can't be 'Deleted' in the WebGL sense.
bool IsDeleted() const { return false; }
protected:
~WebGLUniformLocation();
+
+private:
+ virtual void DetachImpl() override { }
};
} // namespace mozilla
#endif // WEBGL_UNIFORM_LOCATION_H_
--- a/dom/canvas/WebGLVertexArrayFake.h
+++ b/dom/canvas/WebGLVertexArrayFake.h
@@ -20,17 +20,17 @@ protected:
virtual void DeleteImpl() override;
virtual void GenVertexArray() override {};
virtual bool IsVertexArrayImpl() override;
private:
explicit WebGLVertexArrayFake(WebGLContext* webgl);
~WebGLVertexArrayFake() {
- DeleteOnce();
+ DetachOnce();
}
bool mIsVAO;
};
} // namespace mozilla
#endif // WEBGL_VERTEX_ARRAY_FAKE_H_
--- a/dom/canvas/WebGLVertexArrayGL.cpp
+++ b/dom/canvas/WebGLVertexArrayGL.cpp
@@ -12,17 +12,17 @@ namespace mozilla {
WebGLVertexArrayGL::WebGLVertexArrayGL(WebGLContext* webgl)
: WebGLVertexArray(webgl)
, mIsVAO(false)
{ }
WebGLVertexArrayGL::~WebGLVertexArrayGL()
{
- DeleteOnce();
+ DetachOnce();
}
void
WebGLVertexArrayGL::DeleteImpl()
{
mElementArrayBuffer = nullptr;
mContext->MakeContextCurrent();
--- a/dom/canvas/WebGLVertexArrayObject.h
+++ b/dom/canvas/WebGLVertexArrayObject.h
@@ -27,16 +27,16 @@ public:
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
private:
explicit WebGLVertexArrayObject(WebGLContext* webgl)
: WebGLVertexArrayGL(webgl)
{ }
~WebGLVertexArrayObject() {
- DeleteOnce();
+ DetachOnce();
}
};
} // namespace dom
} // namespace mozilla
#endif // !mozilla_dom_WebGLVertexArrayObject_h