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

Unified Diff: include/gpu/GrProgramElementRef.h

Issue 551083002: Make GrEffectStage copy constructor work correctly with pending execution refs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ; Created 6 years, 3 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 | « include/gpu/GrEffectStage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrProgramElementRef.h
diff --git a/include/gpu/GrProgramElementRef.h b/include/gpu/GrProgramElementRef.h
index 920ab78a48a42be9ed41b5cef8ac1dff0fc0e7e2..df083c07386d8c79ea4aa2487c25ff8f13e66f27 100644
--- a/include/gpu/GrProgramElementRef.h
+++ b/include/gpu/GrProgramElementRef.h
@@ -38,6 +38,26 @@ public:
fOwnPendingExec = true;
}
+ // In the short term we need to support copying a GrEffectStage and making the copy own
+ // the same type of ref as the source. This function exists to support this. TODO: Once
+ // GrDrawState and GrOptDrawState no longer share a base class they won't have to share
+ // GrEffectStage and we can have GrOptDrawState always own pending executions rather than
+ // refs on GrProgramElements. At that point we should be able to delete this function.
+ // This function makes assumptions that are valid in the GrEffectStage use case and should
+ // not be used elsewhere.
+ void initAndRef(const GrProgramElementRef& that) {
+ SkASSERT(!fObj);
+ SkASSERT(that.fObj);
+ if (that.fOwnPendingExec) {
+ SkASSERT(that.fObj->fPendingExecutions > 0);
+ that.fObj->fPendingExecutions++;
+ } else {
+ that.fObj->ref();
+ }
+ this->fOwnPendingExec = that.fOwnPendingExec;
+ this->fObj = that.fObj;
+ }
+
T* get() const { return fObj; }
operator T*() { return fObj; }
« no previous file with comments | « include/gpu/GrEffectStage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698