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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities | 54 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities |
55 * from the GrXferProcessor. | 55 * from the GrXferProcessor. |
56 */ | 56 */ |
57 virtual void initBatchTracker(const GrPipelineInfo& init) = 0; | 57 virtual void initBatchTracker(const GrPipelineInfo& init) = 0; |
58 | 58 |
59 bool combineIfPossible(GrBatch* that) { | 59 bool combineIfPossible(GrBatch* that) { |
60 if (this->classID() != that->classID()) { | 60 if (this->classID() != that->classID()) { |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 return onCombineIfPossible(that); | 64 return this->onCombineIfPossible(that); |
65 } | 65 } |
66 | 66 |
67 virtual bool onCombineIfPossible(GrBatch*) = 0; | 67 virtual bool onCombineIfPossible(GrBatch*) = 0; |
68 | 68 |
69 virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0; | 69 virtual void generateGeometry(GrBatchTarget*, const GrPipeline*) = 0; |
70 | 70 |
71 const SkRect& bounds() const { return fBounds; } | |
72 | |
71 // TODO this goes away when batches are everywhere | 73 // TODO this goes away when batches are everywhere |
72 void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; } | 74 void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; } |
73 int numberOfDraws() const { return fNumberOfDraws; } | 75 int numberOfDraws() const { return fNumberOfDraws; } |
74 | 76 |
75 void* operator new(size_t size); | 77 void* operator new(size_t size); |
76 void operator delete(void* target); | 78 void operator delete(void* target); |
77 | 79 |
78 void* operator new(size_t size, void* placement) { | 80 void* operator new(size_t size, void* placement) { |
79 return ::operator new(size, placement); | 81 return ::operator new(size, placement); |
80 } | 82 } |
(...skipping 15 matching lines...) Expand all Loading... | |
96 SkDEBUGCODE(bool isUsed() const { return fUsed; }) | 98 SkDEBUGCODE(bool isUsed() const { return fUsed; }) |
97 | 99 |
98 protected: | 100 protected: |
99 template <typename PROC_SUBCLASS> void initClassID() { | 101 template <typename PROC_SUBCLASS> void initClassID() { |
100 static uint32_t kClassID = GenClassID(); | 102 static uint32_t kClassID = GenClassID(); |
101 fClassID = kClassID; | 103 fClassID = kClassID; |
102 } | 104 } |
103 | 105 |
104 uint32_t fClassID; | 106 uint32_t fClassID; |
105 | 107 |
108 // Its always better to compute some conservative bounds, but some calls are exceedingly | |
109 // infrequent or the cost to compute bounds would be extremely expensive | |
110 void setBoundsLargest() { fBounds.setLargest(); } | |
111 void setBounds(const SkRect& newBounds) { fBounds = newBounds; } | |
robertphillips
2015/05/01 13:03:00
Why not "const SkRect&" ?
joshualitt
2015/05/01 13:22:28
not sure I follow, the function signature is "cons
bsalomon
2015/05/01 13:24:53
Rob writes his comments using 0-based indexing. So
joshualitt
2015/05/01 13:49:58
lol, okay so, clients need to outset / map this re
bsalomon
2015/05/01 14:29:55
Does making fBounds protected solve your problem?
| |
112 SkRect* getBounds() { return &fBounds; } | |
113 | |
114 // TODO will our bounds ever actually be empty? | |
bsalomon
2015/04/30 18:53:23
probably should never be empty. Why have a batch t
joshualitt
2015/05/01 13:49:57
Well, it looks like the bounds for horizontal / ve
bsalomon
2015/05/01 14:29:55
Oh, duh. I guess we have a different meaning of "e
| |
115 void joinBounds(const SkRect& otherBounds) { return fBounds.join(otherBounds ); } | |
116 | |
106 private: | 117 private: |
107 static uint32_t GenClassID() { | 118 static uint32_t GenClassID() { |
108 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The | 119 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The |
109 // atomic inc returns the old value not the incremented value. So we add | 120 // atomic inc returns the old value not the incremented value. So we add |
110 // 1 to the returned value. | 121 // 1 to the returned value. |
111 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrBatchClassID)) + 1; | 122 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrBatchClassID)) + 1; |
112 if (!id) { | 123 if (!id) { |
113 SkFAIL("This should never wrap as it should only be called once for each GrBatch " | 124 SkFAIL("This should never wrap as it should only be called once for each GrBatch " |
114 "subclass."); | 125 "subclass."); |
115 } | 126 } |
116 return id; | 127 return id; |
117 } | 128 } |
118 | 129 |
119 enum { | 130 enum { |
120 kIllegalBatchClassID = 0, | 131 kIllegalBatchClassID = 0, |
121 }; | 132 }; |
122 static int32_t gCurrBatchClassID; | 133 static int32_t gCurrBatchClassID; |
123 | 134 |
124 SkDEBUGCODE(bool fUsed;) | 135 SkDEBUGCODE(bool fUsed;) |
125 | 136 |
126 int fNumberOfDraws; | 137 int fNumberOfDraws; |
138 SkRect fBounds; | |
127 | 139 |
128 typedef SkRefCnt INHERITED; | 140 typedef SkRefCnt INHERITED; |
129 }; | 141 }; |
130 | 142 |
131 #endif | 143 #endif |
OLD | NEW |