diff options
Diffstat (limited to 'src/gpu/GrRenderTarget.cpp')
-rw-r--r-- | src/gpu/GrRenderTarget.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index ad56cf761f..e547021227 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -16,6 +16,13 @@ #include "GrRenderTargetPriv.h" #include "GrStencilAttachment.h" +GrRenderTarget::~GrRenderTarget() { + if (fLastDrawTarget) { + fLastDrawTarget->clearRT(); + } + SkSafeUnref(fLastDrawTarget); +} + void GrRenderTarget::discard() { // go through context so that all necessary flushing occurs GrContext* context = this->getContext(); @@ -57,24 +64,30 @@ void GrRenderTarget::overrideResolveRect(const SkIRect rect) { void GrRenderTarget::onRelease() { SkSafeSetNull(fStencilAttachment); - fLastDrawTarget = nullptr; INHERITED::onRelease(); } void GrRenderTarget::onAbandon() { SkSafeSetNull(fStencilAttachment); - fLastDrawTarget = nullptr; + + // The contents of this renderTarget are gone/invalid. It isn't useful to point back + // the creating drawTarget. + this->setLastDrawTarget(nullptr); INHERITED::onAbandon(); } void GrRenderTarget::setLastDrawTarget(GrDrawTarget* dt) { if (fLastDrawTarget) { + // The non-MDB world never closes so we can't check this condition +#ifdef ENABLE_MDB SkASSERT(fLastDrawTarget->isClosed()); +#endif + fLastDrawTarget->clearRT(); } - fLastDrawTarget = dt; + SkRefCnt_SafeAssign(fLastDrawTarget, dt); } /////////////////////////////////////////////////////////////////////////////// |