diff options
author | 2013-07-17 21:39:58 +0000 | |
---|---|---|
committer | 2013-07-17 21:39:58 +0000 | |
commit | 59e16e4e1d30eee3ce564e0b513d952579065cb3 (patch) | |
tree | 64804173738fc89efbd05958e42368086a547012 /src | |
parent | a524d5ea2259a9ee71906478d4924088303e4455 (diff) |
Fix leak of GrGLTexID when its owning GrGLTexture has been abandoned.
BUG=260708
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://chromiumcodereview.appspot.com/19580003
git-svn-id: http://skia.googlecode.com/svn/trunk@10132 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.cpp | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 18 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.h | 10 |
4 files changed, 17 insertions, 23 deletions
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index 69d7b9ca58..a6fc1862b3 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -20,8 +20,7 @@ void GrGLRenderTarget::init(const Desc& desc, fTexFBOID = desc.fTexFBOID; fMSColorRenderbufferID = desc.fMSColorRenderbufferID; fViewport = viewport; - fTexIDObj = texID; - GrSafeRef(fTexIDObj); + fTexIDObj.reset(SkSafeRef(texID)); } namespace { @@ -95,8 +94,7 @@ void GrGLRenderTarget::onRelease() { fRTFBOID = 0; fTexFBOID = 0; fMSColorRenderbufferID = 0; - GrSafeUnref(fTexIDObj); - fTexIDObj = NULL; + fTexIDObj.reset(NULL); INHERITED::onRelease(); } @@ -104,9 +102,9 @@ void GrGLRenderTarget::onAbandon() { fRTFBOID = 0; fTexFBOID = 0; fMSColorRenderbufferID = 0; - if (NULL != fTexIDObj) { + if (NULL != fTexIDObj.get()) { fTexIDObj->abandon(); - fTexIDObj = NULL; + fTexIDObj.reset(NULL); } INHERITED::onAbandon(); } diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h index d558297958..de9f4c1aa0 100644 --- a/src/gpu/gl/GrGLRenderTarget.h +++ b/src/gpu/gl/GrGLRenderTarget.h @@ -97,7 +97,7 @@ private: GrGLIRect fViewport; // non-NULL if this RT was created by Gr with an associated GrGLTexture. - GrGLTexID* fTexIDObj; + SkAutoTUnref<GrGLTexID> fTexIDObj; void init(const Desc& desc, const GrGLIRect& viewport, GrGLTexID* texID); diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 6314b0c8f1..aee25bc023 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -22,10 +22,9 @@ void GrGLTexture::init(GrGpuGL* gpu, fTexParams.invalidate(); fTexParamsTimestamp = GrGpu::kExpiredTimestamp; - fTexIDObj = SkNEW_ARGS(GrGLTexID, - (GPUGL->glInterface(), - textureDesc.fTextureID, - textureDesc.fIsWrapped)); + fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(), + textureDesc.fTextureID, + textureDesc.fIsWrapped))); if (NULL != rtDesc) { GrGLIRect vp; @@ -53,22 +52,19 @@ GrGLTexture::GrGLTexture(GrGpuGL* gpu, void GrGLTexture::onRelease() { GPUGL->notifyTextureDelete(this); - if (NULL != fTexIDObj) { - fTexIDObj->unref(); - fTexIDObj = NULL; - } - + fTexIDObj.reset(NULL); INHERITED::onRelease(); } void GrGLTexture::onAbandon() { - if (NULL != fTexIDObj) { + if (NULL != fTexIDObj.get()) { fTexIDObj->abandon(); + fTexIDObj.reset(NULL); } INHERITED::onAbandon(); } GrBackendObject GrGLTexture::getTextureHandle() const { - return fTexIDObj->id(); + return static_cast<GrBackendObject>(this->textureID()); } diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index 79cea08663..025faded72 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -70,27 +70,27 @@ public: GrGLTexture(GrGpuGL* gpu, const Desc& textureDesc); - virtual ~GrGLTexture() { this->release(); } virtual GrBackendObject getTextureHandle() const SK_OVERRIDE; virtual void invalidateCachedState() SK_OVERRIDE { fTexParams.invalidate(); } - // these functions + // These functions are used to track the texture parameters associated with the texture. const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const { *timestamp = fTexParamsTimestamp; return fTexParams; } + void setCachedTexParams(const TexParams& texParams, GrGpu::ResetTimestamp timestamp) { fTexParams = texParams; fTexParamsTimestamp = timestamp; } - GrGLuint textureID() const { return fTexIDObj->id(); } -protected: + GrGLuint textureID() const { return (NULL != fTexIDObj.get()) ? fTexIDObj->id() : 0; } +protected: // overrides of GrTexture virtual void onAbandon() SK_OVERRIDE; virtual void onRelease() SK_OVERRIDE; @@ -98,7 +98,7 @@ protected: private: TexParams fTexParams; GrGpu::ResetTimestamp fTexParamsTimestamp; - GrGLTexID* fTexIDObj; + SkAutoTUnref<GrGLTexID> fTexIDObj; void init(GrGpuGL* gpu, const Desc& textureDesc, |