Bug 795186 - Declare refptrs between WebGL objects to the CC even if there is no cycle at C++ level - r=opettay

This commit is contained in:
Benoit Jacob 2012-10-22 17:17:42 -04:00
parent 1f78e9ca0c
commit 47a6960085
5 changed files with 81 additions and 14 deletions

View File

@ -1373,20 +1373,33 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLContext)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCanvasElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mExtensions)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mBound2DTextures)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mBoundCubeMapTextures)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBoundArrayBuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBoundElementArrayBuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCurrentProgram)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBoundFramebuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBoundRenderbuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mAttribBuffers)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCanvasElement, nsINode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mExtensions)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mBound2DTextures)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mBoundCubeMapTextures)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBoundArrayBuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBoundElementArrayBuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCurrentProgram)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBoundFramebuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBoundRenderbuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mAttribBuffers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

View File

@ -1522,6 +1522,11 @@ struct WebGLVertexAttribData {
if (stride) return stride;
return size * componentSize();
}
// for cycle collection
WebGLBuffer* get() {
return buf.get();
}
};
class WebGLBuffer MOZ_FINAL
@ -2643,6 +2648,8 @@ class WebGLFramebufferAttachment
WebGLint mTextureLevel;
WebGLenum mTextureCubeMapFace;
friend class WebGLFramebuffer;
public:
WebGLFramebufferAttachment(WebGLenum aAttachmentPoint)
: mAttachmentPoint(aAttachmentPoint)
@ -3105,7 +3112,9 @@ public:
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope);
NS_DECL_ISUPPORTS
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation)
protected:
// nsRefPtr, not WebGLRefPtr, so that we don't prevent the program from being explicitly deleted.
// we just want to avoid having a dangling pointer.

View File

@ -12,8 +12,32 @@ JSObject*
WebGLFramebuffer::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap) {
return dom::WebGLFramebufferBinding::Wrap(cx, scope, this, triedToWrap);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLFramebuffer)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(WebGLFramebuffer)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLFramebuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLFramebuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mColorAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mColorAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDepthAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDepthAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mStencilAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mStencilAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDepthStencilAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDepthStencilAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLFramebuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mColorAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mColorAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDepthAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDepthAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mStencilAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mStencilAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDepthStencilAttachment.mTexturePtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDepthStencilAttachment.mRenderbufferPtr)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLFramebuffer)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLFramebuffer)

View File

@ -13,7 +13,18 @@ WebGLProgram::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap) {
return dom::WebGLProgramBinding::Wrap(cx, scope, this, triedToWrap);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLProgram)
NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLProgram)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(WebGLProgram)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLProgram)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mAttachedShaders)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLProgram)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mAttachedShaders)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLProgram)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLProgram)

View File

@ -8,15 +8,25 @@
using namespace mozilla;
NS_IMPL_ADDREF(WebGLUniformLocation)
NS_IMPL_RELEASE(WebGLUniformLocation)
NS_INTERFACE_MAP_BEGIN(WebGLUniformLocation)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
JSObject*
WebGLUniformLocation::WrapObject(JSContext *cx, JSObject *scope)
{
return dom::WebGLUniformLocationBinding::Wrap(cx, scope, this);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLUniformLocation)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgram)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLUniformLocation)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProgram)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLUniformLocation)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLUniformLocation)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLUniformLocation)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END