OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrDefaultGeoProcFactory.h" | 8 #include "GrDefaultGeoProcFactory.h" |
9 | 9 |
10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, | 30 return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags, |
31 color, | 31 color, |
32 viewMatrix, | 32 viewMatrix, |
33 localMatrix, | 33 localMatrix, |
34 opaqueVertexColors, | 34 opaqueVertexColors, |
35 coverage)); | 35 coverage)); |
36 } | 36 } |
37 | 37 |
38 const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; } | 38 const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; } |
39 | 39 |
40 const GrAttribute* inPosition() const { return fInPosition; } | 40 const Attribute* inPosition() const { return fInPosition; } |
41 const GrAttribute* inColor() const { return fInColor; } | 41 const Attribute* inColor() const { return fInColor; } |
42 const GrAttribute* inLocalCoords() const { return fInLocalCoords; } | 42 const Attribute* inLocalCoords() const { return fInLocalCoords; } |
43 const GrAttribute* inCoverage() const { return fInCoverage; } | 43 const Attribute* inCoverage() const { return fInCoverage; } |
44 uint8_t coverage() const { return fCoverage; } | 44 uint8_t coverage() const { return fCoverage; } |
45 | 45 |
46 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 46 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
47 BatchTracker* local = bt->cast<BatchTracker>(); | 47 BatchTracker* local = bt->cast<BatchTracker>(); |
48 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, | 48 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, |
49 SkToBool(fInColor)); | 49 SkToBool(fInColor)); |
50 | 50 |
51 bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored
; | 51 bool hasVertexCoverage = SkToBool(fInCoverage) && !init.fCoverageIgnored
; |
52 bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage(); | 52 bool covIsSolidWhite = !hasVertexCoverage && 0xff == this->coverage(); |
53 if (covIsSolidWhite) { | 53 if (covIsSolidWhite) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 , fInPosition(NULL) | 194 , fInPosition(NULL) |
195 , fInColor(NULL) | 195 , fInColor(NULL) |
196 , fInLocalCoords(NULL) | 196 , fInLocalCoords(NULL) |
197 , fInCoverage(NULL) | 197 , fInCoverage(NULL) |
198 , fCoverage(coverage) | 198 , fCoverage(coverage) |
199 , fFlags(gpTypeFlags) { | 199 , fFlags(gpTypeFlags) { |
200 this->initClassID<DefaultGeoProc>(); | 200 this->initClassID<DefaultGeoProc>(); |
201 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G
PType); | 201 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G
PType); |
202 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo
calCoord_GPType); | 202 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo
calCoord_GPType); |
203 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove
rage_GPType); | 203 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove
rage_GPType); |
204 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 204 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
205 if (hasColor) { | 205 if (hasColor) { |
206 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrV
ertexAttribType)); | 206 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVer
texAttribType)); |
207 this->setHasVertexColor(); | 207 this->setHasVertexColor(); |
208 } | 208 } |
209 if (hasLocalCoord) { | 209 if (hasLocalCoord) { |
210 fInLocalCoords = &this->addVertexAttrib(GrAttribute("inLocalCoord", | 210 fInLocalCoords = &this->addVertexAttrib(Attribute("inLocalCoord", |
211 kVec2f_GrVertexA
ttribType)); | 211 kVec2f_GrVertexA
ttribType)); |
212 this->setHasLocalCoords(); | 212 this->setHasLocalCoords(); |
213 } | 213 } |
214 if (hasCoverage) { | 214 if (hasCoverage) { |
215 fInCoverage = &this->addVertexAttrib(GrAttribute("inCoverage", | 215 fInCoverage = &this->addVertexAttrib(Attribute("inCoverage", |
216 kFloat_GrVertexAttr
ibType)); | 216 kFloat_GrVertexAttr
ibType)); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 220 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
221 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); | 221 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); |
222 return gp.fFlags == this->fFlags; | 222 return gp.fFlags == this->fFlags; |
223 } | 223 } |
224 | 224 |
225 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { | 225 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { |
226 if (fInCoverage) { | 226 if (fInCoverage) { |
227 out->setUnknownSingleComponent(); | 227 out->setUnknownSingleComponent(); |
228 } else { | 228 } else { |
229 // uniform coverage | 229 // uniform coverage |
230 out->setKnownSingleComponent(this->coverage()); | 230 out->setKnownSingleComponent(this->coverage()); |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 struct BatchTracker { | 234 struct BatchTracker { |
235 GrGPInput fInputColorType; | 235 GrGPInput fInputColorType; |
236 GrGPInput fInputCoverageType; | 236 GrGPInput fInputCoverageType; |
237 GrColor fColor; | 237 GrColor fColor; |
238 GrColor fCoverage; | 238 GrColor fCoverage; |
239 bool fUsesLocalCoords; | 239 bool fUsesLocalCoords; |
240 }; | 240 }; |
241 | 241 |
242 const GrAttribute* fInPosition; | 242 const Attribute* fInPosition; |
243 const GrAttribute* fInColor; | 243 const Attribute* fInColor; |
244 const GrAttribute* fInLocalCoords; | 244 const Attribute* fInLocalCoords; |
245 const GrAttribute* fInCoverage; | 245 const Attribute* fInCoverage; |
246 uint8_t fCoverage; | 246 uint8_t fCoverage; |
247 uint32_t fFlags; | 247 uint32_t fFlags; |
248 | 248 |
249 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 249 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
250 | 250 |
251 typedef GrGeometryProcessor INHERITED; | 251 typedef GrGeometryProcessor INHERITED; |
252 }; | 252 }; |
253 | 253 |
254 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); | 254 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); |
255 | 255 |
(...skipping 26 matching lines...) Expand all Loading... |
282 const SkMatrix& local
Matrix, | 282 const SkMatrix& local
Matrix, |
283 bool opaqueVertexColo
rs, | 283 bool opaqueVertexColo
rs, |
284 uint8_t coverage) { | 284 uint8_t coverage) { |
285 return DefaultGeoProc::Create(gpTypeFlags, | 285 return DefaultGeoProc::Create(gpTypeFlags, |
286 color, | 286 color, |
287 viewMatrix, | 287 viewMatrix, |
288 localMatrix, | 288 localMatrix, |
289 opaqueVertexColors, | 289 opaqueVertexColors, |
290 coverage); | 290 coverage); |
291 } | 291 } |
OLD | NEW |