diff options
author | hendrikw <hendrikw@chromium.org> | 2014-12-09 14:26:47 -0800 |
---|---|---|
committer | Brian Salomon <bsalomon@google.com> | 2014-12-12 09:51:26 -0500 |
commit | b83253202f87a021efbef27ffeb316335d39a5ac (patch) | |
tree | 364079618ad94d495d511df33308182062669dfa | |
parent | f6a7f38c6d2450e915bb1dce16885e1073d91f4d (diff) | |
download | skia-b83253202f87a021efbef27ffeb316335d39a5ac.tar.gz |
Skia: Track the fIsWrapped separately so that we delete correctly
GrGlTextureRenderTarget inherits virtually from both GrGlRenderTarget and
GrGLTexture, which both have a 'wrap' flag. The passed in wrap setting could
be different for the two base classes, but since it's virtually inherited,
they share the same flag, so they're either both on, or both off.
As a result, we fail to delete the frambuffer.
To fix this, we now keep a separate isWrapped flag for GrGlRenderTarget.
BUG=437998
Review URL: https://codereview.chromium.org/791493003
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.h | 4 |
4 files changed, 16 insertions, 2 deletions
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index 8482ecdc6..2d6c19c04 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -31,6 +31,7 @@ void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { fRTFBOID = idDesc.fRTFBOID; fTexFBOID = idDesc.fTexFBOID; fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; + fIsWrapped = idDesc.fIsWrapped; fViewport.fLeft = 0; fViewport.fBottom = 0; @@ -54,7 +55,7 @@ size_t GrGLRenderTarget::gpuMemorySize() const { } void GrGLRenderTarget::onRelease() { - if (!this->isWrapped()) { + if (!fIsWrapped) { if (fTexFBOID) { GL_CALL(DeleteFramebuffers(1, &fTexFBOID)); } @@ -68,6 +69,7 @@ void GrGLRenderTarget::onRelease() { fRTFBOID = 0; fTexFBOID = 0; fMSColorRenderbufferID = 0; + fIsWrapped = false; INHERITED::onRelease(); } @@ -75,5 +77,6 @@ void GrGLRenderTarget::onAbandon() { fRTFBOID = 0; fTexFBOID = 0; fMSColorRenderbufferID = 0; + fIsWrapped = false; INHERITED::onAbandon(); } diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h index 0f041600e..50e3b5ace 100644 --- a/src/gpu/gl/GrGLRenderTarget.h +++ b/src/gpu/gl/GrGLRenderTarget.h @@ -77,6 +77,10 @@ private: GrGLuint fTexFBOID; GrGLuint fMSColorRenderbufferID; + // We track this separately from GrGpuResource because this may be both a texture and a render + // target, and the texture may be wrapped while the render target is not. + bool fIsWrapped; + // when we switch to this render target we want to set the viewport to // only render to content area (as opposed to the whole allocation) and // we want the rendering to be at top left (GL has origin in bottom left) diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 8777d1b75..ce892ddbb 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -30,20 +30,23 @@ void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { fTexParams.invalidate(); fTexParamsTimestamp = GrGpu::kExpiredTimestamp; fTextureID = idDesc.fTextureID; + fIsWrapped = idDesc.fIsWrapped; } void GrGLTexture::onRelease() { if (fTextureID) { - if (!this->isWrapped()) { + if (!fIsWrapped) { GL_CALL(DeleteTextures(1, &fTextureID)); } fTextureID = 0; + fIsWrapped = false; } INHERITED::onRelease(); } void GrGLTexture::onAbandon() { fTextureID = 0; + fIsWrapped = false; INHERITED::onAbandon(); } diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index f23adae0d..c3c396eff 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -70,6 +70,10 @@ private: GrGpu::ResetTimestamp fTexParamsTimestamp; GrGLuint fTextureID; + // We track this separately from GrGpuResource because this may be both a texture and a render + // target, and the texture may be wrapped while the render target is not. + bool fIsWrapped; + typedef GrTexture INHERITED; }; |