Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: src/gpu/GrRenderTarget.cpp

Issue 1414903002: Dependencies are now added between the drawTargets in GrPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@mdb-adddeps
Patch Set: Fix leak on abandon issue Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrPipeline.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrRenderTarget.cpp
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index ad56cf761fff6e62afc5380d2532d9c82af48708..e547021227724d03e11ab0bb4c9053989eb8288e 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);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrPipeline.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698