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

Side by Side 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: remove unused function in pendingprogramelement 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 unified diff | Download patch
« no previous file with comments | « include/gpu/GrProcessorStage.h ('k') | include/gpu/GrProgramElementRef.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrProgramElement_DEFINED 8 #ifndef GrProgramElement_DEFINED
9 #define GrProgramElement_DEFINED 9 #define GrProgramElement_DEFINED
10 10
(...skipping 17 matching lines...) Expand all
28 SK_DECLARE_INST_COUNT_ROOT(GrProgramElement) 28 SK_DECLARE_INST_COUNT_ROOT(GrProgramElement)
29 29
30 virtual ~GrProgramElement() { 30 virtual ~GrProgramElement() {
31 // fRefCnt can be one when an effect is created statically using GR_CREA TE_STATIC_EFFECT 31 // fRefCnt can be one when an effect is created statically using GR_CREA TE_STATIC_EFFECT
32 SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions); 32 SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions);
33 // Set to invalid values. 33 // Set to invalid values.
34 SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;) 34 SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;)
35 } 35 }
36 36
37 void ref() const { 37 void ref() const {
38 this->validate();
38 // Once the ref cnt reaches zero it should never be ref'ed again. 39 // Once the ref cnt reaches zero it should never be ref'ed again.
39 SkASSERT(fRefCnt > 0); 40 SkASSERT(fRefCnt > 0);
41 ++fRefCnt;
40 this->validate(); 42 this->validate();
41 ++fRefCnt;
42 } 43 }
43 44
44 void unref() const { 45 void unref() const {
45 this->validate(); 46 this->validate();
46 --fRefCnt; 47 --fRefCnt;
47 if (0 == fRefCnt) { 48 if (0 == fRefCnt) {
48 if (0 == fPendingExecutions) { 49 if (0 == fPendingExecutions) {
49 SkDELETE(this); 50 SkDELETE(this);
51 return;
50 } else { 52 } else {
51 this->removeRefs(); 53 this->removeRefs();
52 } 54 }
53 } 55 }
56 this->validate();
54 } 57 }
55 58
56 /** 59 /**
57 * Gets an id that is unique for this GrProgramElement object. This will nev er return 0. 60 * Gets an id that is unique for this GrProgramElement object. This will nev er return 0.
58 */ 61 */
59 uint32_t getUniqueID() const { return fUniqueID; } 62 uint32_t getUniqueID() const { return fUniqueID; }
60 63
61 void validate() const { 64 void validate() const {
62 #ifdef SK_DEBUG 65 #ifdef SK_DEBUG
63 SkASSERT(fRefCnt >= 0); 66 SkASSERT(fRefCnt >= 0);
64 SkASSERT(fPendingExecutions >= 0); 67 SkASSERT(fPendingExecutions >= 0);
65 SkASSERT(fRefCnt + fPendingExecutions > 0); 68 SkASSERT(fRefCnt + fPendingExecutions > 0);
66 #endif 69 #endif
67 } 70 }
68 71
69 protected: 72 protected:
70 GrProgramElement() : fRefCnt(1), fPendingExecutions(0), fUniqueID(CreateUniq ueID()) {} 73 GrProgramElement() : fRefCnt(1), fPendingExecutions(0), fUniqueID(CreateUniq ueID()) {}
71 74
72 /** Subclasses registers their resources using this function. It is assumed the GrProgramResouce 75 /** Subclasses registers their resources using this function. It is assumed the GrProgramResouce
73 is and will remain owned by the subclass and this function will retain a raw ptr. Once a 76 is and will remain owned by the subclass and this function will retain a raw ptr. Once a
74 GrGpuResourceRef is registered its setResource must not be called. 77 GrGpuResourceRef is registered its setResource must not be called.
75 */ 78 */
76 void addGpuResource(const GrGpuResourceRef* res) { 79 void addGpuResource(const GrGpuResourceRef* res) {
77 fGpuResources.push_back(res); 80 fGpuResources.push_back(res);
78 } 81 }
79 82
80 private: 83 private:
81 static uint32_t CreateUniqueID(); 84 static uint32_t CreateUniqueID();
82 85
83 void convertRefToPendingExecution() const; 86 void addPendingExecution() const {
87 this->validate();
88 SkASSERT(fRefCnt > 0);
89 if (0 == fPendingExecutions) {
90 this->addPendingIOs();
91 }
92 ++fPendingExecutions;
93 this->validate();
94 }
84 95
85 void completedExecution() const; 96 void completedExecution() const {
97 this->validate();
98 --fPendingExecutions;
99 if (0 == fPendingExecutions) {
100 if (0 == fRefCnt) {
101 SkDELETE(this);
102 return;
103 } else {
104 this->pendingIOComplete();
105 }
106 }
107 this->validate();
108 }
86 109
87 void removeRefs() const; 110 void removeRefs() const;
111 void addPendingIOs() const;
112 void pendingIOComplete() const;
88 113
89 mutable int32_t fRefCnt; 114 mutable int32_t fRefCnt;
90 // Count of deferred executions not yet issued to the 3D API. 115 // Count of deferred executions not yet issued to the 3D API.
91 mutable int32_t fPendingExecutions; 116 mutable int32_t fPendingExecutions;
92 uint32_t fUniqueID; 117 uint32_t fUniqueID;
93 118
94 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; 119 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources;
95 120
96 // Only this class can access convertRefToPendingExecution() and completedEx ecution(). 121 // Only this class can access addPendingExecution() and completedExecution() .
97 template <typename T> friend class GrProgramElementRef; 122 template <typename T> friend class GrPendingProgramElement;
98 123
99 typedef SkNoncopyable INHERITED; 124 typedef SkNoncopyable INHERITED;
100 }; 125 };
101 126
102 #endif 127 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrProcessorStage.h ('k') | include/gpu/GrProgramElementRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698