OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrPrimitiveProcessor_DEFINED | 8 #ifndef GrPrimitiveProcessor_DEFINED |
9 #define GrPrimitiveProcessor_DEFINED | 9 #define GrPrimitiveProcessor_DEFINED |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 kIgnored_GrGPInput, | 95 kIgnored_GrGPInput, |
96 }; | 96 }; |
97 | 97 |
98 /* | 98 /* |
99 * GrPrimitiveProcessor defines an interface which all subclasses must implement
. All | 99 * GrPrimitiveProcessor defines an interface which all subclasses must implement
. All |
100 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co
lor / coverage | 100 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co
lor / coverage |
101 * pipelines, and they must provide some notion of equality | 101 * pipelines, and they must provide some notion of equality |
102 */ | 102 */ |
103 class GrPrimitiveProcessor : public GrProcessor { | 103 class GrPrimitiveProcessor : public GrProcessor { |
104 public: | 104 public: |
105 // TODO let the PrimProc itself set this in its setData call, this should re
ally live on the | |
106 // bundle of primitive data | |
107 const SkMatrix& localMatrix() const { return fLocalMatrix; } | |
108 | |
109 virtual void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const
= 0; | 105 virtual void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const
= 0; |
110 | 106 |
111 virtual bool canMakeEqual(const GrBatchTracker& mine, | 107 virtual bool canMakeEqual(const GrBatchTracker& mine, |
112 const GrPrimitiveProcessor& that, | 108 const GrPrimitiveProcessor& that, |
113 const GrBatchTracker& theirs) const = 0; | 109 const GrBatchTracker& theirs) const = 0; |
114 | 110 |
115 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; | 111 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; |
116 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; | 112 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; |
117 | 113 |
118 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex
attributes, but | 114 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex
attributes, but |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 162 |
167 /** Returns a new instance of the appropriate *GL* implementation class | 163 /** Returns a new instance of the appropriate *GL* implementation class |
168 for the given GrProcessor; caller is responsible for deleting | 164 for the given GrProcessor; caller is responsible for deleting |
169 the object. */ | 165 the object. */ |
170 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 166 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
171 const GrGLSLCaps& caps) con
st = 0; | 167 const GrGLSLCaps& caps) con
st = 0; |
172 | 168 |
173 bool isPathRendering() const { return fIsPathRendering; } | 169 bool isPathRendering() const { return fIsPathRendering; } |
174 | 170 |
175 protected: | 171 protected: |
176 GrPrimitiveProcessor(const SkMatrix& localMatrix, bool isPathRendering) | 172 GrPrimitiveProcessor(bool isPathRendering) |
177 : fNumAttribs(0) | 173 : fNumAttribs(0) |
178 , fVertexStride(0) | 174 , fVertexStride(0) |
179 , fLocalMatrix(localMatrix) | |
180 , fIsPathRendering(isPathRendering) {} | 175 , fIsPathRendering(isPathRendering) {} |
181 | 176 |
182 /* | |
183 * CanCombineOutput will return true if two draws are 'batchable' from a col
or perspective. | |
184 * TODO remove this when GPs can upgrade to attribute color | |
185 */ | |
186 static bool CanCombineOutput(GrGPInput left, GrColor lColor, GrGPInput right
, GrColor rColor) { | |
187 if (left != right) { | |
188 return false; | |
189 } | |
190 | |
191 if (kUniform_GrGPInput == left && lColor != rColor) { | |
192 return false; | |
193 } | |
194 | |
195 return true; | |
196 } | |
197 | |
198 static bool CanCombineLocalMatrices(const GrPrimitiveProcessor& left, | |
199 bool leftUsesLocalCoords, | |
200 const GrPrimitiveProcessor& right, | |
201 bool rightUsesLocalCoords) { | |
202 if (leftUsesLocalCoords != rightUsesLocalCoords) { | |
203 return false; | |
204 } | |
205 | |
206 if (leftUsesLocalCoords && !left.localMatrix().cheapEqualTo(right.localM
atrix())) { | |
207 return false; | |
208 } | |
209 return true; | |
210 } | |
211 | |
212 Attribute fAttribs[kMaxVertexAttribs]; | 177 Attribute fAttribs[kMaxVertexAttribs]; |
213 int fNumAttribs; | 178 int fNumAttribs; |
214 size_t fVertexStride; | 179 size_t fVertexStride; |
215 | 180 |
216 private: | 181 private: |
217 virtual bool hasExplicitLocalCoords() const = 0; | 182 virtual bool hasExplicitLocalCoords() const = 0; |
218 | 183 |
219 SkMatrix fLocalMatrix; | |
220 bool fIsPathRendering; | 184 bool fIsPathRendering; |
221 | 185 |
222 typedef GrProcessor INHERITED; | 186 typedef GrProcessor INHERITED; |
223 }; | 187 }; |
224 | 188 |
225 #endif | 189 #endif |
OLD | NEW |