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
This commit is contained in:
hendrikw 2014-12-09 14:26:47 -08:00 committed by Commit bot
parent 7af39f6e8d
commit 9a0c7abfd7
4 changed files with 16 additions and 2 deletions

View File

@ -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::onGpuMemorySize() 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();
}

View File

@ -76,6 +76,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)

View File

@ -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();
}

View File

@ -68,6 +68,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;
};