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 28 matching lines...) Expand all Loading... |
39 * information will be communicated to the GrBatch prior to geometry generation. | 39 * information will be communicated to the GrBatch prior to geometry generation. |
40 */ | 40 */ |
41 | 41 |
42 struct GrBatchOpt { | 42 struct GrBatchOpt { |
43 bool fCanTweakAlphaForCoverage; | 43 bool fCanTweakAlphaForCoverage; |
44 }; | 44 }; |
45 | 45 |
46 class GrBatch : public SkRefCnt { | 46 class GrBatch : public SkRefCnt { |
47 public: | 47 public: |
48 SK_DECLARE_INST_COUNT(GrBatch) | 48 SK_DECLARE_INST_COUNT(GrBatch) |
49 GrBatch() { SkDEBUGCODE(fUsed = false;) } | 49 GrBatch() : fNumberOfDraws(0) { SkDEBUGCODE(fUsed = false;) } |
50 virtual ~GrBatch() {} | 50 virtual ~GrBatch() {} |
51 | 51 |
52 virtual const char* name() const = 0; | 52 virtual const char* name() const = 0; |
53 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; | 53 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; |
54 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; | 54 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; |
55 | 55 |
56 /* | 56 /* |
57 * initBatchOpt is used to communicate possible optimizations to the GrBatch
. initBatchTracker | 57 * initBatchOpt is used to communicate possible optimizations to the GrBatch
. initBatchTracker |
58 * is a hook for the some additional overrides from the GrXferProcessor. Th
is is a bit | 58 * is a hook for the some additional overrides from the GrXferProcessor. Th
is is a bit |
59 * confusing but has to be like this until GrBatch is everywhere. | 59 * confusing but has to be like this until GrBatch is everywhere. |
60 * | 60 * |
61 * TODO combine to a single init call when GrBatch is everywhere. | 61 * TODO combine to a single init call when GrBatch is everywhere. |
62 */ | 62 */ |
63 virtual void initBatchOpt(const GrBatchOpt&) = 0; | 63 virtual void initBatchOpt(const GrBatchOpt&) = 0; |
64 virtual void initBatchTracker(const GrPipelineInfo& init) = 0; | 64 virtual void initBatchTracker(const GrPipelineInfo& init) = 0; |
65 | 65 |
66 bool combineIfPossible(GrBatch* that) { | 66 bool combineIfPossible(GrBatch* that) { |
67 if (this->classID() != that->classID()) { | 67 if (this->classID() != that->classID()) { |
68 return false; | 68 return false; |
69 } | 69 } |
70 | 70 |
71 return onCombineIfPossible(that); | 71 return onCombineIfPossible(that); |
72 } | 72 } |
73 | 73 |
74 virtual bool onCombineIfPossible(GrBatch*) = 0; | 74 virtual bool onCombineIfPossible(GrBatch*) = 0; |
75 | 75 |
76 virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0; | 76 virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0; |
77 | 77 |
| 78 // TODO this goes away when batches are everywhere |
| 79 void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; } |
| 80 int numberOfDraws() const { return fNumberOfDraws; } |
| 81 |
78 void* operator new(size_t size); | 82 void* operator new(size_t size); |
79 void operator delete(void* target); | 83 void operator delete(void* target); |
80 | 84 |
81 void* operator new(size_t size, void* placement) { | 85 void* operator new(size_t size, void* placement) { |
82 return ::operator new(size, placement); | 86 return ::operator new(size, placement); |
83 } | 87 } |
84 void operator delete(void* target, void* placement) { | 88 void operator delete(void* target, void* placement) { |
85 ::operator delete(target, placement); | 89 ::operator delete(target, placement); |
86 } | 90 } |
87 | 91 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return id; | 123 return id; |
120 } | 124 } |
121 | 125 |
122 enum { | 126 enum { |
123 kIllegalBatchClassID = 0, | 127 kIllegalBatchClassID = 0, |
124 }; | 128 }; |
125 static int32_t gCurrBatchClassID; | 129 static int32_t gCurrBatchClassID; |
126 | 130 |
127 SkDEBUGCODE(bool fUsed;) | 131 SkDEBUGCODE(bool fUsed;) |
128 | 132 |
| 133 int fNumberOfDraws; |
| 134 |
129 typedef SkRefCnt INHERITED; | 135 typedef SkRefCnt INHERITED; |
130 }; | 136 }; |
131 | 137 |
132 #endif | 138 #endif |
OLD | NEW |