OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrTessellatingPathRenderer.h" | 8 #include "GrTessellatingPathRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1368 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1368 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1369 out->setKnownFourComponents(fColor); | 1369 out->setKnownFourComponents(fColor); |
1370 } | 1370 } |
1371 | 1371 |
1372 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1372 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1373 out->setUnknownSingleComponent(); | 1373 out->setUnknownSingleComponent(); |
1374 } | 1374 } |
1375 | 1375 |
1376 void initBatchTracker(const GrPipelineInfo& init) override { | 1376 void initBatchTracker(const GrPipelineInfo& init) override { |
1377 // Handle any color overrides | 1377 // Handle any color overrides |
1378 if (!init.readsColor()) { | 1378 if (init.fColorIgnored) { |
1379 fColor = GrColor_ILLEGAL; | 1379 fColor = GrColor_ILLEGAL; |
| 1380 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 1381 fColor = init.fOverrideColor; |
1380 } | 1382 } |
1381 init.getOverrideColorIfSet(&fColor); | |
1382 fPipelineInfo = init; | 1383 fPipelineInfo = init; |
1383 } | 1384 } |
1384 | 1385 |
1385 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1386 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1386 SkRect pathBounds = fPath.getBounds(); | 1387 SkRect pathBounds = fPath.getBounds(); |
1387 Comparator c; | 1388 Comparator c; |
1388 if (pathBounds.width() > pathBounds.height()) { | 1389 if (pathBounds.width() > pathBounds.height()) { |
1389 c.sweep_lt = sweep_lt_horiz; | 1390 c.sweep_lt = sweep_lt_horiz; |
1390 c.sweep_gt = sweep_gt_horiz; | 1391 c.sweep_gt = sweep_gt_horiz; |
1391 } else { | 1392 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
1404 return; | 1405 return; |
1405 } | 1406 } |
1406 SkPath::FillType fillType = fPath.getFillType(); | 1407 SkPath::FillType fillType = fPath.getFillType(); |
1407 if (SkPath::IsInverseFillType(fillType)) { | 1408 if (SkPath::IsInverseFillType(fillType)) { |
1408 contourCnt++; | 1409 contourCnt++; |
1409 } | 1410 } |
1410 | 1411 |
1411 LOG("got %d pts, %d contours\n", maxPts, contourCnt); | 1412 LOG("got %d pts, %d contours\n", maxPts, contourCnt); |
1412 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; | 1413 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; |
1413 SkAutoTUnref<const GrGeometryProcessor> gp( | 1414 SkAutoTUnref<const GrGeometryProcessor> gp( |
1414 GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.readsLo
calCoords(), | 1415 GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.fUsesLo
calCoords, |
1415 !fPipelineInfo.readsCoverage(), fVie
wMatrix, | 1416 fPipelineInfo.fCoverageIgnored, fVie
wMatrix, |
1416 SkMatrix::I())); | 1417 SkMatrix::I())); |
1417 batchTarget->initDraw(gp, pipeline); | 1418 batchTarget->initDraw(gp, pipeline); |
1418 | 1419 |
1419 SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt)); | 1420 SkAutoTDeleteArray<Vertex*> contours(SkNEW_ARRAY(Vertex *, contourCnt)); |
1420 | 1421 |
1421 // For the initial size of the chunk allocator, estimate based on the po
int count: | 1422 // For the initial size of the chunk allocator, estimate based on the po
int count: |
1422 // one vertex per point for the initial passes, plus two for the vertice
s in the | 1423 // one vertex per point for the initial passes, plus two for the vertice
s in the |
1423 // resulting Polys, since the same point may end up in two Polys. Assum
e minimal | 1424 // resulting Polys, since the same point may end up in two Polys. Assum
e minimal |
1424 // connectivity of one Edge per Vertex (will grow for intersections). | 1425 // connectivity of one Edge per Vertex (will grow for intersections). |
1425 SkChunkAlloc alloc(maxPts * (3 * sizeof(Vertex) + sizeof(Edge))); | 1426 SkChunkAlloc alloc(maxPts * (3 * sizeof(Vertex) + sizeof(Edge))); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 SkMatrix vmi; | 1529 SkMatrix vmi; |
1529 bool result = viewMatrix.invert(&vmi); | 1530 bool result = viewMatrix.invert(&vmi); |
1530 if (!result) { | 1531 if (!result) { |
1531 SkFAIL("Cannot invert matrix\n"); | 1532 SkFAIL("Cannot invert matrix\n"); |
1532 } | 1533 } |
1533 vmi.mapRect(&clipBounds); | 1534 vmi.mapRect(&clipBounds); |
1534 return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds); | 1535 return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds); |
1535 } | 1536 } |
1536 | 1537 |
1537 #endif | 1538 #endif |
OLD | NEW |