aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrProgramElementRef.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-09-08 12:06:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-08 12:06:20 -0700
commit655ad128d054005ce5e55cc6f0b75a4dec07ccce (patch)
tree468f3c112576d1e816c30cd0611563afdd6e38e0 /include/gpu/GrProgramElementRef.h
parent46625e06e23b65c05013fc686a8223d6d5b49050 (diff)
Make GrEffectStage copy constructor work correctly with pending execution refs.
R=egdaniel@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/551083002
Diffstat (limited to 'include/gpu/GrProgramElementRef.h')
-rw-r--r--include/gpu/GrProgramElementRef.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/gpu/GrProgramElementRef.h b/include/gpu/GrProgramElementRef.h
index 920ab78a48..df083c0738 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; }