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

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

Issue 1278643006: Make GrBatch carry its own GrPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more 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
« no previous file with comments | « src/gpu/GrTargetCommands.cpp ('k') | 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 29 matching lines...) Expand all
40 #if GR_BATCH_SPEW 40 #if GR_BATCH_SPEW
41 #define GrBATCH_INFO(...) SkDebugf(__VA_ARGS__) 41 #define GrBATCH_INFO(...) SkDebugf(__VA_ARGS__)
42 #define GrBATCH_SPEW(code) code 42 #define GrBATCH_SPEW(code) code
43 #else 43 #else
44 #define GrBATCH_SPEW(code) 44 #define GrBATCH_SPEW(code)
45 #define GrBATCH_INFO(...) 45 #define GrBATCH_INFO(...)
46 #endif 46 #endif
47 47
48 class GrBatch : public GrNonAtomicRef { 48 class GrBatch : public GrNonAtomicRef {
49 public: 49 public:
50 GrBatch() 50 GrBatch();
51 : fClassID(kIllegalBatchID) 51 ~GrBatch() override;
52 , fNumberOfDraws(0)
53 #if GR_BATCH_SPEW
54 , fUniqueID(GenID(&gCurrBatchUniqueID))
55 #endif
56 { SkDEBUGCODE(fUsed = false;) }
57 virtual ~GrBatch() {}
58 52
59 virtual const char* name() const = 0; 53 virtual const char* name() const = 0;
60 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; 54 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
61 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0; 55 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
62 56
63 bool combineIfPossible(GrBatch* that) { 57 bool combineIfPossible(GrBatch* that) {
64 if (this->classID() != that->classID()) { 58 if (this->classID() != that->classID()) {
65 return false; 59 return false;
66 } 60 }
67 61
(...skipping 26 matching lines...) Expand all
94 template <typename T> const T& cast() const { return *static_cast<const T*>( this); } 88 template <typename T> const T& cast() const { return *static_cast<const T*>( this); }
95 template <typename T> T* cast() { return static_cast<T*>(this); } 89 template <typename T> T* cast() { return static_cast<T*>(this); }
96 90
97 uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fCl assID; } 91 uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fCl assID; }
98 92
99 // TODO no GrPrimitiveProcessors yet read fragment position 93 // TODO no GrPrimitiveProcessors yet read fragment position
100 bool willReadFragmentPosition() const { return false; } 94 bool willReadFragmentPosition() const { return false; }
101 95
102 SkDEBUGCODE(bool isUsed() const { return fUsed; }) 96 SkDEBUGCODE(bool isUsed() const { return fUsed; })
103 97
104 const GrPipeline* pipeline() const { return fPipeline; } 98 const GrPipeline* pipeline() const {
99 SkASSERT(fPipelineInstalled);
100 return reinterpret_cast<const GrPipeline*>(fPipelineStorage.get());
101 }
105 102
106 void setPipeline(const GrPipeline* pipeline, const GrPipelineOptimizations& optimizations) { 103 bool installPipeline(const GrPipeline::CreateArgs&);
107 fPipeline.reset(SkRef(pipeline));
108 this->initBatchTracker(optimizations);
109 }
110 104
111 #if GR_BATCH_SPEW 105 #if GR_BATCH_SPEW
112 uint32_t uniqueID() const { return fUniqueID; } 106 uint32_t uniqueID() const { return fUniqueID; }
113 #endif 107 #endif
114 108
115 protected: 109 protected:
116 template <typename PROC_SUBCLASS> void initClassID() { 110 template <typename PROC_SUBCLASS> void initClassID() {
117 static uint32_t kClassID = GenID(&gCurrBatchClassID); 111 static uint32_t kClassID = GenID(&gCurrBatchClassID);
118 fClassID = kClassID; 112 fClassID = kClassID;
119 } 113 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (!id) { 177 if (!id) {
184 SkFAIL("This should never wrap as it should only be called once for each GrBatch " 178 SkFAIL("This should never wrap as it should only be called once for each GrBatch "
185 "subclass."); 179 "subclass.");
186 } 180 }
187 return id; 181 return id;
188 } 182 }
189 183
190 enum { 184 enum {
191 kIllegalBatchID = 0, 185 kIllegalBatchID = 0,
192 }; 186 };
193 SkAutoTUnref<const GrPipeline> fPipeline; 187 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage;
188 int fNumberOfDraws;
189 SkDEBUGCODE(bool fUsed;)
190 bool fPipelineInstalled;
191 #if GR_BATCH_SPEW
192 uint32_t fUniqueID;
193 static int32_t gCurrBatchUniqueID;
194 #endif
194 static int32_t gCurrBatchClassID; 195 static int32_t gCurrBatchClassID;
195 int fNumberOfDraws;
196 SkDEBUGCODE(bool fUsed;)
197 #if GR_BATCH_SPEW
198 static int32_t gCurrBatchUniqueID;
199 uint32_t fUniqueID;
200 #endif
201
202 typedef SkRefCnt INHERITED; 196 typedef SkRefCnt INHERITED;
203 }; 197 };
204 198
205 #endif 199 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTargetCommands.cpp ('k') | src/gpu/batches/GrBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698