diff --git a/gfx/2d/GenericRefCounted.h b/gfx/2d/GenericRefCounted.h index 062f61f14bf1..1c0ead10789e 100644 --- a/gfx/2d/GenericRefCounted.h +++ b/gfx/2d/GenericRefCounted.h @@ -37,6 +37,11 @@ class GenericRefCountedBase // mechanism, it is welcome to do so by overriding AddRef() and Release(). void ref() { AddRef(); } void deref() { Release(); } + +#ifdef MOZ_REFCOUNTED_LEAK_CHECKING + virtual const char* typeName() const = 0; + virtual size_t typeSize() const = 0; +#endif }; namespace detail { @@ -55,11 +60,18 @@ class GenericRefCounted : public GenericRefCountedBase virtual void AddRef() { MOZ_ASSERT(int32_t(refCnt) >= 0); ++refCnt; +#ifdef MOZ_REFCOUNTED_LEAK_CHECKING + detail::RefCountLogger::logAddRef(this, refCnt, typeName(), typeSize()); +#endif } virtual void Release() { MOZ_ASSERT(int32_t(refCnt) > 0); - if (0 == --refCnt) { + --refCnt; +#ifdef MOZ_REFCOUNTED_LEAK_CHECKING + detail::RefCountLogger::logRelease(this, refCnt, typeName()); +#endif + if (0 == refCnt) { #ifdef DEBUG refCnt = detail::DEAD; #endif diff --git a/gfx/gl/GLContextCGL.h b/gfx/gl/GLContextCGL.h index 99e975f251ed..06eec2bb1eee 100644 --- a/gfx/gl/GLContextCGL.h +++ b/gfx/gl/GLContextCGL.h @@ -27,6 +27,7 @@ class GLContextCGL : public GLContext NSOpenGLContext *mContext; public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL) GLContextCGL(const SurfaceCaps& caps, GLContext *shareContext, NSOpenGLContext *context, diff --git a/gfx/gl/GLContextEGL.h b/gfx/gl/GLContextEGL.h index 6f9487d0184b..99a51d52d74b 100644 --- a/gfx/gl/GLContextEGL.h +++ b/gfx/gl/GLContextEGL.h @@ -29,6 +29,7 @@ class GLContextEGL : public GLContext EGLSurface surface); public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL) GLContextEGL(const SurfaceCaps& caps, GLContext* shareContext, bool isOffscreen, diff --git a/gfx/gl/GLContextGLX.h b/gfx/gl/GLContextGLX.h index d7ae88375927..0c0b8848b06e 100644 --- a/gfx/gl/GLContextGLX.h +++ b/gfx/gl/GLContextGLX.h @@ -16,6 +16,7 @@ namespace gl { class GLContextGLX : public GLContext { public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextGLX) static already_AddRefed CreateGLContext(const SurfaceCaps& caps, GLContextGLX* shareContext, diff --git a/gfx/gl/GLContextWGL.h b/gfx/gl/GLContextWGL.h index bded9746b4ce..0c2c345ac48b 100644 --- a/gfx/gl/GLContextWGL.h +++ b/gfx/gl/GLContextWGL.h @@ -16,6 +16,7 @@ namespace gl { class GLContextWGL : public GLContext { public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextWGL) // From Window: (possibly for offscreen!) GLContextWGL(const SurfaceCaps& caps, GLContext* sharedContext, diff --git a/gfx/gl/SkiaGLGlue.h b/gfx/gl/SkiaGLGlue.h index 1d80021566fb..2e550d04fb5c 100755 --- a/gfx/gl/SkiaGLGlue.h +++ b/gfx/gl/SkiaGLGlue.h @@ -17,6 +17,7 @@ namespace gl { class SkiaGLGlue : public GenericAtomicRefCounted { public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue) SkiaGLGlue(GLContext* context); GLContext* GetGLContext() const { return mGLContext.get(); } GrContext* GetGrContext() const { return mGrContext.get(); } diff --git a/gfx/gl/SurfaceStream.h b/gfx/gl/SurfaceStream.h index a7b4f5961ee6..e9d372319176 100644 --- a/gfx/gl/SurfaceStream.h +++ b/gfx/gl/SurfaceStream.h @@ -28,6 +28,7 @@ class SurfaceFactory; class SurfaceStream : public GenericAtomicRefCounted { public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream) typedef enum { MainThread, OffMainThread @@ -145,6 +146,7 @@ protected: SharedSurface* mConsumer; // Only present after resize-swap. public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_SingleBuffer) SurfaceStream_SingleBuffer(SurfaceStream* prevStream); virtual ~SurfaceStream_SingleBuffer(); @@ -169,6 +171,7 @@ protected: SharedSurface* mConsumer; public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_TripleBuffer_Copy) SurfaceStream_TripleBuffer_Copy(SurfaceStream* prevStream); virtual ~SurfaceStream_TripleBuffer_Copy(); @@ -192,6 +195,7 @@ protected: SurfaceStream_TripleBuffer(SurfaceStreamType type, SurfaceStream* prevStream); public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_TripleBuffer) SurfaceStream_TripleBuffer(SurfaceStream* prevStream); virtual ~SurfaceStream_TripleBuffer(); virtual bool CopySurfaceToProducer(SharedSurface* src, SurfaceFactory* factory);