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

Side by Side Diff: src/gpu/batches/GrBatch.h

Issue 1772023003: Lazy init batch unique ID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 4 years, 9 months 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 | « no previous file | src/gpu/batches/GrBatch.cpp » ('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 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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/gpu/batches/GrBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698