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