8 #ifndef GrProgramElement_DEFINED
9 #define GrProgramElement_DEFINED
11 #include "../private/SkTArray.h"
48 SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions);
50 SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;)
56 SkASSERT(fRefCnt > 0);
66 if (0 == fPendingExecutions) {
81 void validate()
const {
83 SkASSERT(fRefCnt >= 0);
84 SkASSERT(fPendingExecutions >= 0);
85 SkASSERT(fRefCnt + fPendingExecutions > 0);
90 GrProgramElement() : fRefCnt(1), fPendingExecutions(0), fUniqueID(CreateUniqueID()) {}
97 fGpuResources.push_back(res);
100 void addPendingExecution()
const {
102 SkASSERT(fRefCnt > 0);
103 if (0 == fPendingExecutions) {
104 this->addPendingIOs();
106 ++fPendingExecutions;
110 void completedExecution()
const {
112 --fPendingExecutions;
113 if (0 == fPendingExecutions) {
118 this->pendingIOComplete();
129 static uint32_t CreateUniqueID();
131 void removeRefs()
const;
132 void addPendingIOs()
const;
133 void pendingIOComplete()
const;
135 mutable int32_t fRefCnt;
137 mutable int32_t fPendingExecutions;
140 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources;
143 template <
typename T>
friend class GrPendingProgramElement;
145 typedef SkNoncopyable INHERITED;
void addGpuResource(const GrGpuResourceRef *res)
Subclasses registers their resources using this function.
Definition: GrProgramElement.h:96
virtual void notifyRefCntIsZero() const =0
This will be called when the ref cnt is zero.
Base class for GrProcessor.
Definition: GrProgramElement.h:44
This class is intended only for internal use in core Gr code.
Definition: GrGpuResourceRef.h:37
uint32_t getUniqueID() const
Gets an id that is unique for this GrProgramElement object.
Definition: GrProgramElement.h:79