| 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 // We lazily initialize the uniqueID because currently the only user is GrAu
ditTrail |
| 99 uint32_t uniqueID() const { return fUniqueID; } | 99 uint32_t uniqueID() const { |
| 100 #endif | 100 if (kIllegalBatchID == fUniqueID) { |
| 101 fUniqueID = GenBatchID(); |
| 102 } |
| 103 return fUniqueID; |
| 104 } |
| 101 SkDEBUGCODE(bool isUsed() const { return fUsed; }) | 105 SkDEBUGCODE(bool isUsed() const { return fUsed; }) |
| 102 | 106 |
| 103 /** Called prior to drawing. The batch should perform any resource creation
necessary to | 107 /** Called prior to drawing. The batch should perform any resource creation
necessary to |
| 104 to quickly issue its draw when draw is called. */ | 108 to quickly issue its draw when draw is called. */ |
| 105 void prepare(GrBatchFlushState* state) { this->onPrepare(state); } | 109 void prepare(GrBatchFlushState* state) { this->onPrepare(state); } |
| 106 | 110 |
| 107 /** Issues the batches commands to GrGpu. */ | 111 /** Issues the batches commands to GrGpu. */ |
| 108 void draw(GrBatchFlushState* state) { this->onDraw(state); } | 112 void draw(GrBatchFlushState* state) { this->onDraw(state); } |
| 109 | 113 |
| 110 /** Used to block batching across render target changes. Remove this once we
store | 114 /** 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 } | 150 } |
| 147 return id; | 151 return id; |
| 148 } | 152 } |
| 149 | 153 |
| 150 enum { | 154 enum { |
| 151 kIllegalBatchID = 0, | 155 kIllegalBatchID = 0, |
| 152 }; | 156 }; |
| 153 | 157 |
| 154 SkDEBUGCODE(bool fUsed;) | 158 SkDEBUGCODE(bool fUsed;) |
| 155 const uint32_t fClassID; | 159 const uint32_t fClassID; |
| 156 #if GR_BATCH_SPEW | |
| 157 static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } | 160 static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } |
| 158 const uint32_t fUniqueID; | 161 mutable uint32_t fUniqueID; |
| 159 static int32_t gCurrBatchUniqueID; | 162 static int32_t gCurrBatchUniqueID; |
| 160 #endif | |
| 161 static int32_t gCurrBatchClassID; | 163 static int32_t gCurrBatchClassID; |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 #endif | 166 #endif |
| OLD | NEW |