diff options
author | 2012-09-05 18:37:39 +0000 | |
---|---|---|
committer | 2012-09-05 18:37:39 +0000 | |
commit | d364554bcfd391c3b6111af8bff963a35ab87ba7 (patch) | |
tree | 18e5c6ed646c22b9ca1effcf86b16bb148eb0066 | |
parent | 981b33abc65d968523d78d45e69cb071e8e03e91 (diff) |
Enforce calling of inherited onRelease & onAbandon mthds in GrResource-derived classes
http://codereview.appspot.com/6499077/
git-svn-id: http://skia.googlecode.com/svn/trunk@5405 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/gpu/GrResource.h | 6 | ||||
-rw-r--r-- | src/gpu/GrRenderTarget.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrTexture.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLIndexBuffer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLIndexBuffer.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPath.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLStencilBuffer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLVertexBuffer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLVertexBuffer.h | 4 |
10 files changed, 36 insertions, 8 deletions
diff --git a/include/gpu/GrResource.h b/include/gpu/GrResource.h index 5c3e24aac7..aeab180226 100644 --- a/include/gpu/GrResource.h +++ b/include/gpu/GrResource.h @@ -75,8 +75,10 @@ protected: GrGpu* getGpu() const { return fGpu; } - virtual void onRelease() = 0; - virtual void onAbandon() = 0; + // Derived classes should always call their parent class' onRelease + // and onAbandon methods in their overrides. + virtual void onRelease() {}; + virtual void onAbandon() {}; bool isInCache() const { return NULL != fCacheEntry; } diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index 6235808762..761966400c 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -112,8 +112,12 @@ void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) { void GrRenderTarget::onRelease() { this->setStencilBuffer(NULL); + + INHERITED::onRelease(); } void GrRenderTarget::onAbandon() { this->setStencilBuffer(NULL); + + INHERITED::onAbandon(); } diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index 027521bf93..c31d774544 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -85,12 +85,16 @@ void GrTexture::releaseRenderTarget() { void GrTexture::onRelease() { GrAssert(!this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit)); this->releaseRenderTarget(); + + INHERITED::onRelease(); } void GrTexture::onAbandon() { if (NULL != fRenderTarget) { fRenderTarget->abandon(); } + + INHERITED::onAbandon(); } void GrTexture::validateDesc() const { diff --git a/src/gpu/gl/GrGLIndexBuffer.cpp b/src/gpu/gl/GrGLIndexBuffer.cpp index 26fdeb6687..66ee09537a 100644 --- a/src/gpu/gl/GrGLIndexBuffer.cpp +++ b/src/gpu/gl/GrGLIndexBuffer.cpp @@ -31,11 +31,15 @@ void GrGLIndexBuffer::onRelease() { GL_CALL(DeleteBuffers(1, &fBufferID)); fBufferID = 0; } + + INHERITED::onRelease(); } void GrGLIndexBuffer::onAbandon() { fBufferID = 0; fLockPtr = NULL; + + INHERITED::onAbandon(); } void GrGLIndexBuffer::bind() const { diff --git a/src/gpu/gl/GrGLIndexBuffer.h b/src/gpu/gl/GrGLIndexBuffer.h index 3a08c0e334..e28200135c 100644 --- a/src/gpu/gl/GrGLIndexBuffer.h +++ b/src/gpu/gl/GrGLIndexBuffer.h @@ -37,8 +37,8 @@ protected: bool dynamic); // overrides of GrResource - virtual void onAbandon(); - virtual void onRelease(); + virtual void onAbandon() SK_OVERRIDE; + virtual void onRelease() SK_OVERRIDE; private: void bind() const; diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp index 95e11f2167..5324dcd1fe 100644 --- a/src/gpu/gl/GrGLPath.cpp +++ b/src/gpu/gl/GrGLPath.cpp @@ -94,9 +94,13 @@ void GrGLPath::onRelease() { GL_CALL(DeletePaths(fPathID, 1)); fPathID = 0; } + + INHERITED::onRelease(); } void GrGLPath::onAbandon() { fPathID = 0; + + INHERITED::onAbandon(); } diff --git a/src/gpu/gl/GrGLStencilBuffer.cpp b/src/gpu/gl/GrGLStencilBuffer.cpp index a9612f5d04..030b54e3ee 100644 --- a/src/gpu/gl/GrGLStencilBuffer.cpp +++ b/src/gpu/gl/GrGLStencilBuffer.cpp @@ -28,10 +28,14 @@ void GrGLStencilBuffer::onRelease() { GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID)); fRenderbufferID = 0; } + + INHERITED::onRelease(); } void GrGLStencilBuffer::onAbandon() { fRenderbufferID = 0; + + INHERITED::onAbandon(); } diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 2c5e4a2367..1e34fe56a2 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -55,19 +55,21 @@ GrGLTexture::GrGLTexture(GrGpuGL* gpu, } void GrGLTexture::onRelease() { - INHERITED::onRelease(); GPUGL->notifyTextureDelete(this); if (NULL != fTexIDObj) { fTexIDObj->unref(); fTexIDObj = NULL; } + + INHERITED::onRelease(); } void GrGLTexture::onAbandon() { - INHERITED::onAbandon(); if (NULL != fTexIDObj) { fTexIDObj->abandon(); } + + INHERITED::onAbandon(); } intptr_t GrGLTexture::getTextureHandle() const { diff --git a/src/gpu/gl/GrGLVertexBuffer.cpp b/src/gpu/gl/GrGLVertexBuffer.cpp index 71ea66df69..7cee29e081 100644 --- a/src/gpu/gl/GrGLVertexBuffer.cpp +++ b/src/gpu/gl/GrGLVertexBuffer.cpp @@ -30,11 +30,15 @@ void GrGLVertexBuffer::onRelease() { GL_CALL(DeleteBuffers(1, &fBufferID)); fBufferID = 0; } + + INHERITED::onRelease(); } void GrGLVertexBuffer::onAbandon() { fBufferID = 0; fLockPtr = NULL; + + INHERITED::onAbandon(); } void GrGLVertexBuffer::bind() const { diff --git a/src/gpu/gl/GrGLVertexBuffer.h b/src/gpu/gl/GrGLVertexBuffer.h index 7df759e043..bb829d34d2 100644 --- a/src/gpu/gl/GrGLVertexBuffer.h +++ b/src/gpu/gl/GrGLVertexBuffer.h @@ -34,8 +34,8 @@ protected: bool dynamic); // overrides of GrResource - virtual void onAbandon(); - virtual void onRelease(); + virtual void onAbandon() SK_OVERRIDE; + virtual void onRelease() SK_OVERRIDE; private: void bind() const; |