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 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces
sor"; } | 38 virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProces
sor"; } |
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 , fInPosition(NULL) | 198 , fInPosition(NULL) |
199 , fInColor(NULL) | 199 , fInColor(NULL) |
200 , fInLocalCoords(NULL) | 200 , fInLocalCoords(NULL) |
201 , fInCoverage(NULL) | 201 , fInCoverage(NULL) |
202 , fCoverage(coverage) | 202 , fCoverage(coverage) |
203 , fFlags(gpTypeFlags) { | 203 , fFlags(gpTypeFlags) { |
204 this->initClassID<DefaultGeoProc>(); | 204 this->initClassID<DefaultGeoProc>(); |
205 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G
PType); | 205 bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_G
PType); |
206 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo
calCoord_GPType); | 206 bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLo
calCoord_GPType); |
207 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove
rage_GPType); | 207 bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCove
rage_GPType); |
208 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 208 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
209 if (hasColor) { | 209 if (hasColor) { |
210 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrV
ertexAttribType)); | 210 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVer
texAttribType)); |
211 this->setHasVertexColor(); | 211 this->setHasVertexColor(); |
212 } | 212 } |
213 if (hasLocalCoord) { | 213 if (hasLocalCoord) { |
214 fInLocalCoords = &this->addVertexAttrib(GrAttribute("inLocalCoord", | 214 fInLocalCoords = &this->addVertexAttrib(Attribute("inLocalCoord", |
215 kVec2f_GrVertexA
ttribType)); | 215 kVec2f_GrVertexA
ttribType)); |
216 this->setHasLocalCoords(); | 216 this->setHasLocalCoords(); |
217 } | 217 } |
218 if (hasCoverage) { | 218 if (hasCoverage) { |
219 fInCoverage = &this->addVertexAttrib(GrAttribute("inCoverage", | 219 fInCoverage = &this->addVertexAttrib(Attribute("inCoverage", |
220 kFloat_GrVertexAttr
ibType)); | 220 kFloat_GrVertexAttr
ibType)); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 224 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
225 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); | 225 const DefaultGeoProc& gp = other.cast<DefaultGeoProc>(); |
226 return gp.fFlags == this->fFlags; | 226 return gp.fFlags == this->fFlags; |
227 } | 227 } |
228 | 228 |
229 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 229 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
230 if (fInCoverage) { | 230 if (fInCoverage) { |
231 out->setUnknownSingleComponent(); | 231 out->setUnknownSingleComponent(); |
232 } else { | 232 } else { |
233 // uniform coverage | 233 // uniform coverage |
234 out->setKnownSingleComponent(this->coverage()); | 234 out->setKnownSingleComponent(this->coverage()); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 struct BatchTracker { | 238 struct BatchTracker { |
239 GrGPInput fInputColorType; | 239 GrGPInput fInputColorType; |
240 GrGPInput fInputCoverageType; | 240 GrGPInput fInputCoverageType; |
241 GrColor fColor; | 241 GrColor fColor; |
242 GrColor fCoverage; | 242 GrColor fCoverage; |
243 bool fUsesLocalCoords; | 243 bool fUsesLocalCoords; |
244 }; | 244 }; |
245 | 245 |
246 const GrAttribute* fInPosition; | 246 const Attribute* fInPosition; |
247 const GrAttribute* fInColor; | 247 const Attribute* fInColor; |
248 const GrAttribute* fInLocalCoords; | 248 const Attribute* fInLocalCoords; |
249 const GrAttribute* fInCoverage; | 249 const Attribute* fInCoverage; |
250 uint8_t fCoverage; | 250 uint8_t fCoverage; |
251 uint32_t fFlags; | 251 uint32_t fFlags; |
252 | 252 |
253 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 253 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
254 | 254 |
255 typedef GrGeometryProcessor INHERITED; | 255 typedef GrGeometryProcessor INHERITED; |
256 }; | 256 }; |
257 | 257 |
258 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); | 258 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); |
259 | 259 |
(...skipping 26 matching lines...) Expand all Loading... |
286 const SkMatrix& local
Matrix, | 286 const SkMatrix& local
Matrix, |
287 bool opaqueVertexColo
rs, | 287 bool opaqueVertexColo
rs, |
288 uint8_t coverage) { | 288 uint8_t coverage) { |
289 return DefaultGeoProc::Create(gpTypeFlags, | 289 return DefaultGeoProc::Create(gpTypeFlags, |
290 color, | 290 color, |
291 viewMatrix, | 291 viewMatrix, |
292 localMatrix, | 292 localMatrix, |
293 opaqueVertexColors, | 293 opaqueVertexColors, |
294 coverage); | 294 coverage); |
295 } | 295 } |
OLD | NEW |