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 "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 return DefaultGeoProc::Create(flags, | 252 return DefaultGeoProc::Create(flags, |
253 GrRandomColor(d->fRandom), | 253 GrRandomColor(d->fRandom), |
254 GrTest::TestMatrix(d->fRandom), | 254 GrTest::TestMatrix(d->fRandom), |
255 GrTest::TestMatrix(d->fRandom), | 255 GrTest::TestMatrix(d->fRandom), |
256 d->fRandom->nextBool(), | 256 d->fRandom->nextBool(), |
257 d->fRandom->nextBool(), | 257 d->fRandom->nextBool(), |
258 GrRandomCoverage(d->fRandom)); | 258 GrRandomCoverage(d->fRandom)); |
259 } | 259 } |
260 | 260 |
| 261 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags, |
| 262 GrColor color, |
| 263 bool localCoordsWillB
eRead, |
| 264 bool coverageWillBeIg
nored, |
| 265 const SkMatrix& viewM
atrix, |
| 266 const SkMatrix& local
Matrix, |
| 267 uint8_t coverage) { |
| 268 return DefaultGeoProc::Create(gpTypeFlags, |
| 269 color, |
| 270 viewMatrix, |
| 271 localMatrix, |
| 272 localCoordsWillBeRead, |
| 273 coverageWillBeIgnored, |
| 274 coverage); |
| 275 } |
| 276 |
261 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color, | 277 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(const Color& color, |
262 const Coverage& cover
age, | 278 const Coverage& cover
age, |
263 const LocalCoords& lo
calCoords, | 279 const LocalCoords& lo
calCoords, |
264 const SkMatrix& viewM
atrix) { | 280 const SkMatrix& viewM
atrix) { |
265 uint32_t flags = 0; | 281 uint32_t flags = 0; |
266 flags |= color.fType == Color::kAttribute_Type ? kColor_GPType : 0; | 282 flags |= color.fType == Color::kAttribute_Type ? kColor_GPType : 0; |
267 flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverage_GPType : 0; | 283 flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverage_GPType : 0; |
268 flags |= localCoords.fType == LocalCoords::kHasExplicit_Type ? kLocalCoord_G
PType : 0; | 284 flags |= localCoords.fType == LocalCoords::kHasExplicit_Type ? kLocalCoord_G
PType : 0; |
269 | 285 |
270 uint8_t inCoverage = coverage.fCoverage; | 286 uint8_t inCoverage = coverage.fCoverage; |
271 bool coverageWillBeIgnored = coverage.fType == Coverage::kNone_Type; | 287 bool coverageWillBeIgnored = coverage.fType == Coverage::kNone_Type; |
272 bool localCoordsWillBeRead = localCoords.fType != LocalCoords::kUnused_Type; | 288 bool localCoordsWillBeRead = localCoords.fType != LocalCoords::kUnused_Type; |
273 | 289 |
274 GrColor inColor = color.fColor; | 290 GrColor inColor = color.fColor; |
275 return DefaultGeoProc::Create(flags, | 291 return DefaultGeoProc::Create(flags, |
276 inColor, | 292 inColor, |
277 viewMatrix, | 293 viewMatrix, |
278 localCoords.fMatrix ? *localCoords.fMatrix : S
kMatrix::I(), | 294 localCoords.fMatrix ? *localCoords.fMatrix : S
kMatrix::I(), |
279 localCoordsWillBeRead, | 295 localCoordsWillBeRead, |
280 coverageWillBeIgnored, | 296 coverageWillBeIgnored, |
281 inCoverage); | 297 inCoverage); |
282 } | 298 } |
283 | 299 |
284 const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace( | 300 const GrGeometryProcessor* GrDefaultGeoProcFactory::CreateForDeviceSpace( |
285 const Color
& color, | 301 const Color
& color, |
286 const Cover
age& coverage, | 302 const Cover
age& coverage, |
287 const Local
Coords& localCoords, | 303 const Local
Coords& localCoords, |
288 const SkMat
rix& viewMatrix) { | 304 const SkMat
rix& viewMatrix) { |
| 305 SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType); |
289 SkMatrix invert = SkMatrix::I(); | 306 SkMatrix invert = SkMatrix::I(); |
290 if (LocalCoords::kUnused_Type != localCoords.fType) { | 307 if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) { |
291 SkASSERT(LocalCoords::kUsePosition_Type == localCoords.fType); | 308 SkDebugf("Could not invert\n"); |
292 if (!viewMatrix.isIdentity() && !viewMatrix.invert(&invert)) { | 309 return NULL; |
293 SkDebugf("Could not invert\n"); | 310 } |
294 return NULL; | |
295 } | |
296 | 311 |
297 if (localCoords.hasLocalMatrix()) { | 312 if (localCoords.hasLocalMatrix()) { |
298 invert.preConcat(*localCoords.fMatrix); | 313 invert.preConcat(*localCoords.fMatrix); |
299 } | |
300 } | 314 } |
301 | 315 |
302 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); | 316 LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert); |
303 return Create(color, coverage, inverted, SkMatrix::I()); | 317 return Create(color, coverage, inverted); |
304 } | 318 } |
OLD | NEW |