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

Unified Diff: include/gpu/GrProgramElement.h

Issue 739673002: Create GrOptDrawState before recording draw in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years, 1 month 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
Index: include/gpu/GrProgramElement.h
diff --git a/include/gpu/GrProgramElement.h b/include/gpu/GrProgramElement.h
index 2cdd1cc5635014e81d3362b4fb8ca3a0600abca7..e1adcc31f726eccd7e68754ea80b371ec2685a9f 100644
--- a/include/gpu/GrProgramElement.h
+++ b/include/gpu/GrProgramElement.h
@@ -35,10 +35,11 @@ public:
}
void ref() const {
+ this->validate();
// Once the ref cnt reaches zero it should never be ref'ed again.
SkASSERT(fRefCnt > 0);
- this->validate();
++fRefCnt;
+ this->validate();
}
void unref() const {
@@ -47,10 +48,12 @@ public:
if (0 == fRefCnt) {
if (0 == fPendingExecutions) {
SkDELETE(this);
+ return;
} else {
this->removeRefs();
}
}
+ this->validate();
}
/**
@@ -80,11 +83,33 @@ protected:
private:
static uint32_t CreateUniqueID();
- void convertRefToPendingExecution() const;
+ void addPendingExecution() const {
+ this->validate();
+ SkASSERT(fRefCnt > 0);
+ if (0 == fPendingExecutions) {
+ this->addPendingIOs();
+ }
+ ++fPendingExecutions;
+ this->validate();
+ }
- void completedExecution() const;
+ void completedExecution() const {
+ this->validate();
+ --fPendingExecutions;
+ if (0 == fPendingExecutions) {
+ if (0 == fRefCnt) {
+ SkDELETE(this);
+ return;
+ } else {
+ this->pendingIOComplete();
+ }
+ }
+ this->validate();
joshualitt 2014/11/19 14:22:39 Is there anyway to refactor this->validate so we
bsalomon 2014/11/19 15:04:43 It doesn't need to be called twice (or at all)...
bsalomon 2014/11/19 15:20:06 Actually I can't do that since some of the calls d
+ }
void removeRefs() const;
+ void addPendingIOs() const;
+ void pendingIOComplete() const;
mutable int32_t fRefCnt;
// Count of deferred executions not yet issued to the 3D API.
@@ -93,8 +118,8 @@ private:
SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources;
- // Only this class can access convertRefToPendingExecution() and completedExecution().
- template <typename T> friend class GrProgramElementRef;
+ // Only this class can access addPendingExecution() and completedExecution().
+ template <typename T> friend class GrPendingProgramElement;
typedef SkNoncopyable INHERITED;
};

Powered by Google App Engine
This is Rietveld 408576698