OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 fBatch.fColorIgnored = init.fColorIgnored; | 247 fBatch.fColorIgnored = init.fColorIgnored; |
248 fBatch.fColor = fGeoData[0].fColor; | 248 fBatch.fColor = fGeoData[0].fColor; |
249 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; | 249 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
250 fBatch.fCoverageIgnored = init.fCoverageIgnored; | 250 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
251 } | 251 } |
252 | 252 |
253 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 253 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
254 SkAutoTUnref<const GrGeometryProcessor> gp( | 254 SkAutoTUnref<const GrGeometryProcessor> gp( |
255 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi
on_GPType, | 255 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi
on_GPType, |
256 this->color(), | 256 this->color(), |
| 257 this->usesLocalCoords(), |
| 258 this->coverageIgnored(), |
257 this->viewMatrix(), | 259 this->viewMatrix(), |
258 SkMatrix::I(), | 260 SkMatrix::I(), |
259 this->coverage())); | 261 this->coverage())); |
260 | 262 |
261 size_t vertexStride = gp->getVertexStride(); | 263 size_t vertexStride = gp->getVertexStride(); |
262 SkASSERT(vertexStride == sizeof(SkPoint)); | 264 SkASSERT(vertexStride == sizeof(SkPoint)); |
263 | 265 |
264 batchTarget->initDraw(gp, pipeline); | 266 batchTarget->initDraw(gp, pipeline); |
265 | 267 |
266 // TODO this is hacky, but the only way we have to initialize the GP is
to use the | |
267 // GrPipelineInfo struct so we can generate the correct shader. Once we
have GrBatch | |
268 // everywhere we can remove this nastiness | |
269 GrPipelineInfo init; | |
270 init.fColorIgnored = fBatch.fColorIgnored; | |
271 init.fOverrideColor = GrColor_ILLEGAL; | |
272 init.fCoverageIgnored = fBatch.fCoverageIgnored; | |
273 init.fUsesLocalCoords = this->usesLocalCoords(); | |
274 gp->initBatchTracker(batchTarget->currentBatchTracker(), init); | |
275 | |
276 int instanceCount = fGeoData.count(); | 268 int instanceCount = fGeoData.count(); |
277 | 269 |
278 // compute number of vertices | 270 // compute number of vertices |
279 int maxVertices = 0; | 271 int maxVertices = 0; |
280 | 272 |
281 // We will use index buffers if we have multiple paths or one path with
multiple contours | 273 // We will use index buffers if we have multiple paths or one path with
multiple contours |
282 bool isIndexed = instanceCount > 1; | 274 bool isIndexed = instanceCount > 1; |
283 for (int i = 0; i < instanceCount; i++) { | 275 for (int i = 0; i < instanceCount; i++) { |
284 Geometry& args = fGeoData[i]; | 276 Geometry& args = fGeoData[i]; |
285 | 277 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 503 |
512 } | 504 } |
513 return true; | 505 return true; |
514 } | 506 } |
515 | 507 |
516 GrColor color() const { return fBatch.fColor; } | 508 GrColor color() const { return fBatch.fColor; } |
517 uint8_t coverage() const { return fBatch.fCoverage; } | 509 uint8_t coverage() const { return fBatch.fCoverage; } |
518 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 510 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
519 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } | 511 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; } |
520 bool isHairline() const { return fBatch.fIsHairline; } | 512 bool isHairline() const { return fBatch.fIsHairline; } |
| 513 bool coverageIgnored() const { return fBatch.fCoverageIgnored; } |
521 | 514 |
522 struct BatchTracker { | 515 struct BatchTracker { |
523 GrColor fColor; | 516 GrColor fColor; |
524 uint8_t fCoverage; | 517 uint8_t fCoverage; |
525 SkMatrix fViewMatrix; | 518 SkMatrix fViewMatrix; |
526 bool fUsesLocalCoords; | 519 bool fUsesLocalCoords; |
527 bool fColorIgnored; | 520 bool fColorIgnored; |
528 bool fCoverageIgnored; | 521 bool fCoverageIgnored; |
529 bool fIsHairline; | 522 bool fIsHairline; |
530 }; | 523 }; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 geometry.fColor = color; | 759 geometry.fColor = color; |
767 geometry.fPath = path; | 760 geometry.fPath = path; |
768 geometry.fTolerance = srcSpaceTol; | 761 geometry.fTolerance = srcSpaceTol; |
769 | 762 |
770 viewMatrix.mapRect(&bounds); | 763 viewMatrix.mapRect(&bounds); |
771 uint8_t coverage = GrRandomCoverage(random); | 764 uint8_t coverage = GrRandomCoverage(random); |
772 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 765 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
773 } | 766 } |
774 | 767 |
775 #endif | 768 #endif |
OLD | NEW |