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

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

Issue 1282893002: Make initBatchTracker private, move towards pipeline on batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #if GR_BATCH_SPEW 53 #if GR_BATCH_SPEW
54 , fUniqueID(GenID(&gCurrBatchUniqueID)) 54 , fUniqueID(GenID(&gCurrBatchUniqueID))
55 #endif 55 #endif
56 { SkDEBUGCODE(fUsed = false;) } 56 { SkDEBUGCODE(fUsed = false;) }
57 virtual ~GrBatch() {} 57 virtual ~GrBatch() {}
58 58
59 virtual const char* name() const = 0; 59 virtual const char* name() const = 0;
60 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; 60 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
61 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0; 61 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
62 62
63 /*
64 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities
65 * from the GrXferProcessor.
66 */
67 virtual void initBatchTracker(const GrPipelineOptimizations&) = 0;
68
69 bool combineIfPossible(GrBatch* that) { 63 bool combineIfPossible(GrBatch* that) {
70 if (this->classID() != that->classID()) { 64 if (this->classID() != that->classID()) {
71 return false; 65 return false;
72 } 66 }
73 67
74 return this->onCombineIfPossible(that); 68 return this->onCombineIfPossible(that);
75 } 69 }
76 70
77 virtual bool onCombineIfPossible(GrBatch*) = 0; 71 virtual bool onCombineIfPossible(GrBatch*) = 0;
78 72
(...skipping 22 matching lines...) Expand all
101 template <typename T> T* cast() { return static_cast<T*>(this); } 95 template <typename T> T* cast() { return static_cast<T*>(this); }
102 96
103 uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fCl assID; } 97 uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fCl assID; }
104 98
105 // TODO no GrPrimitiveProcessors yet read fragment position 99 // TODO no GrPrimitiveProcessors yet read fragment position
106 bool willReadFragmentPosition() const { return false; } 100 bool willReadFragmentPosition() const { return false; }
107 101
108 SkDEBUGCODE(bool isUsed() const { return fUsed; }) 102 SkDEBUGCODE(bool isUsed() const { return fUsed; })
109 103
110 const GrPipeline* pipeline() const { return fPipeline; } 104 const GrPipeline* pipeline() const { return fPipeline; }
111 void setPipeline(const GrPipeline* pipeline) { fPipeline.reset(SkRef(pipelin e)); } 105
106 void setPipeline(const GrPipeline* pipeline, const GrPipelineOptimizations& optimizations) {
107 fPipeline.reset(SkRef(pipeline));
108 this->initBatchTracker(optimizations);
109 }
112 110
113 #if GR_BATCH_SPEW 111 #if GR_BATCH_SPEW
114 uint32_t uniqueID() const { return fUniqueID; } 112 uint32_t uniqueID() const { return fUniqueID; }
115 #endif 113 #endif
116 114
117 protected: 115 protected:
118 template <typename PROC_SUBCLASS> void initClassID() { 116 template <typename PROC_SUBCLASS> void initClassID() {
119 static uint32_t kClassID = GenID(&gCurrBatchClassID); 117 static uint32_t kClassID = GenID(&gCurrBatchClassID);
120 fClassID = kClassID; 118 fClassID = kClassID;
121 } 119 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 using InstancedHelper::issueDraw; 161 using InstancedHelper::issueDraw;
164 162
165 private: 163 private:
166 typedef InstancedHelper INHERITED; 164 typedef InstancedHelper INHERITED;
167 }; 165 };
168 166
169 uint32_t fClassID; 167 uint32_t fClassID;
170 SkRect fBounds; 168 SkRect fBounds;
171 169
172 private: 170 private:
171 /*
172 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities
173 * from the GrXferProcessor.
174 */
175 virtual void initBatchTracker(const GrPipelineOptimizations&) = 0;
176
177
173 static uint32_t GenID(int32_t* idCounter) { 178 static uint32_t GenID(int32_t* idCounter) {
174 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The 179 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The
175 // atomic inc returns the old value not the incremented value. So we add 180 // atomic inc returns the old value not the incremented value. So we add
176 // 1 to the returned value. 181 // 1 to the returned value.
177 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1; 182 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1;
178 if (!id) { 183 if (!id) {
179 SkFAIL("This should never wrap as it should only be called once for each GrBatch " 184 SkFAIL("This should never wrap as it should only be called once for each GrBatch "
180 "subclass."); 185 "subclass.");
181 } 186 }
182 return id; 187 return id;
183 } 188 }
184 189
185 enum { 190 enum {
186 kIllegalBatchID = 0, 191 kIllegalBatchID = 0,
187 }; 192 };
188 SkAutoTUnref<const GrPipeline> fPipeline; 193 SkAutoTUnref<const GrPipeline> fPipeline;
189 static int32_t gCurrBatchClassID; 194 static int32_t gCurrBatchClassID;
190 int fNumberOfDraws; 195 int fNumberOfDraws;
191 SkDEBUGCODE(bool fUsed;) 196 SkDEBUGCODE(bool fUsed;)
192 #if GR_BATCH_SPEW 197 #if GR_BATCH_SPEW
193 static int32_t gCurrBatchUniqueID; 198 static int32_t gCurrBatchUniqueID;
194 uint32_t fUniqueID; 199 uint32_t fUniqueID;
195 #endif 200 #endif
196 201
197 typedef SkRefCnt INHERITED; 202 typedef SkRefCnt INHERITED;
198 }; 203 };
199 204
200 #endif 205 #endif
OLDNEW
« src/gpu/GrReorderCommandBuilder.cpp ('K') | « src/gpu/GrTargetCommands.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698