OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrBatch_DEFINED | 8 #ifndef GrBatch_DEFINED |
9 #define GrBatch_DEFINED | 9 #define GrBatch_DEFINED |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 return *static_cast<const T*>(this); | 88 return *static_cast<const T*>(this); |
89 } | 89 } |
90 | 90 |
91 template <typename T> T* cast() { | 91 template <typename T> T* cast() { |
92 SkASSERT(T::ClassID() == this->classID()); | 92 SkASSERT(T::ClassID() == this->classID()); |
93 return static_cast<T*>(this); | 93 return static_cast<T*>(this); |
94 } | 94 } |
95 | 95 |
96 uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fCl assID; } | 96 uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fCl assID; } |
97 | 97 |
98 #if GR_BATCH_SPEW | 98 uint32_t uniqueID() const { |
bsalomon
2016/03/08 16:38:35
Maybe a comment that we lazily initialize because
| |
99 uint32_t uniqueID() const { return fUniqueID; } | 99 if (kIllegalBatchID == fUniqueID) { |
100 #endif | 100 fUniqueID = GenBatchID(); |
101 } | |
102 return fUniqueID; | |
103 } | |
101 SkDEBUGCODE(bool isUsed() const { return fUsed; }) | 104 SkDEBUGCODE(bool isUsed() const { return fUsed; }) |
102 | 105 |
103 /** Called prior to drawing. The batch should perform any resource creation necessary to | 106 /** Called prior to drawing. The batch should perform any resource creation necessary to |
104 to quickly issue its draw when draw is called. */ | 107 to quickly issue its draw when draw is called. */ |
105 void prepare(GrBatchFlushState* state) { this->onPrepare(state); } | 108 void prepare(GrBatchFlushState* state) { this->onPrepare(state); } |
106 | 109 |
107 /** Issues the batches commands to GrGpu. */ | 110 /** Issues the batches commands to GrGpu. */ |
108 void draw(GrBatchFlushState* state) { this->onDraw(state); } | 111 void draw(GrBatchFlushState* state) { this->onDraw(state); } |
109 | 112 |
110 /** Used to block batching across render target changes. Remove this once we store | 113 /** Used to block batching across render target changes. Remove this once we store |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 } | 149 } |
147 return id; | 150 return id; |
148 } | 151 } |
149 | 152 |
150 enum { | 153 enum { |
151 kIllegalBatchID = 0, | 154 kIllegalBatchID = 0, |
152 }; | 155 }; |
153 | 156 |
154 SkDEBUGCODE(bool fUsed;) | 157 SkDEBUGCODE(bool fUsed;) |
155 const uint32_t fClassID; | 158 const uint32_t fClassID; |
156 #if GR_BATCH_SPEW | |
157 static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } | 159 static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } |
158 const uint32_t fUniqueID; | 160 mutable uint32_t fUniqueID; |
159 static int32_t gCurrBatchUniqueID; | 161 static int32_t gCurrBatchUniqueID; |
160 #endif | |
161 static int32_t gCurrBatchClassID; | 162 static int32_t gCurrBatchClassID; |
162 }; | 163 }; |
163 | 164 |
164 #endif | 165 #endif |
OLD | NEW |