| 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 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 class TessellatingPathBatch : public GrBatch { | 1441 class TessellatingPathBatch : public GrBatch { |
| 1442 public: | 1442 public: |
| 1443 | 1443 |
| 1444 static GrBatch* Create(const GrColor& color, | 1444 static GrBatch* Create(const GrColor& color, |
| 1445 const SkPath& path, | 1445 const SkPath& path, |
| 1446 const SkMatrix& viewMatrix, | 1446 const SkMatrix& viewMatrix, |
| 1447 SkRect clipBounds) { | 1447 SkRect clipBounds) { |
| 1448 return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipB
ounds)); | 1448 return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipB
ounds)); |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 const char* name() const SK_OVERRIDE { return "TessellatingPathBatch"; } | 1451 const char* name() const override { return "TessellatingPathBatch"; } |
| 1452 | 1452 |
| 1453 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { | 1453 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1454 out->setKnownFourComponents(fColor); | 1454 out->setKnownFourComponents(fColor); |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID
E { | 1457 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 1458 out->setUnknownSingleComponent(); | 1458 out->setUnknownSingleComponent(); |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { | 1461 void initBatchTracker(const GrPipelineInfo& init) override { |
| 1462 // Handle any color overrides | 1462 // Handle any color overrides |
| 1463 if (init.fColorIgnored) { | 1463 if (init.fColorIgnored) { |
| 1464 fColor = GrColor_ILLEGAL; | 1464 fColor = GrColor_ILLEGAL; |
| 1465 } else if (GrColor_ILLEGAL != init.fOverrideColor) { | 1465 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 1466 fColor = init.fOverrideColor; | 1466 fColor = init.fOverrideColor; |
| 1467 } | 1467 } |
| 1468 fPipelineInfo = init; | 1468 fPipelineInfo = init; |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) SK_OVERRIDE { | 1471 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
| 1472 SkScalar tol = GrPathUtils::scaleToleranceToSrc(SK_Scalar1, fViewMatrix,
fPath.getBounds()); | 1472 SkScalar tol = GrPathUtils::scaleToleranceToSrc(SK_Scalar1, fViewMatrix,
fPath.getBounds()); |
| 1473 int contourCnt; | 1473 int contourCnt; |
| 1474 int maxPts = GrPathUtils::worstCasePointCount(fPath, &contourCnt, tol); | 1474 int maxPts = GrPathUtils::worstCasePointCount(fPath, &contourCnt, tol); |
| 1475 if (maxPts <= 0) { | 1475 if (maxPts <= 0) { |
| 1476 return; | 1476 return; |
| 1477 } | 1477 } |
| 1478 if (maxPts > ((int)SK_MaxU16 + 1)) { | 1478 if (maxPts > ((int)SK_MaxU16 + 1)) { |
| 1479 SkDebugf("Path not rendered, too many verts (%d)\n", maxPts); | 1479 SkDebugf("Path not rendered, too many verts (%d)\n", maxPts); |
| 1480 return; | 1480 return; |
| 1481 } | 1481 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 drawInfo.setStartVertex(firstVertex); | 1536 drawInfo.setStartVertex(firstVertex); |
| 1537 drawInfo.setVertexCount(actualCount); | 1537 drawInfo.setVertexCount(actualCount); |
| 1538 drawInfo.setStartIndex(0); | 1538 drawInfo.setStartIndex(0); |
| 1539 drawInfo.setIndexCount(0); | 1539 drawInfo.setIndexCount(0); |
| 1540 batchTarget->draw(drawInfo); | 1540 batchTarget->draw(drawInfo); |
| 1541 | 1541 |
| 1542 batchTarget->putBackVertices((size_t)(count - actualCount), stride); | 1542 batchTarget->putBackVertices((size_t)(count - actualCount), stride); |
| 1543 return; | 1543 return; |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 bool onCombineIfPossible(GrBatch*) SK_OVERRIDE { | 1546 bool onCombineIfPossible(GrBatch*) override { |
| 1547 return false; | 1547 return false; |
| 1548 } | 1548 } |
| 1549 | 1549 |
| 1550 private: | 1550 private: |
| 1551 TessellatingPathBatch(const GrColor& color, | 1551 TessellatingPathBatch(const GrColor& color, |
| 1552 const SkPath& path, | 1552 const SkPath& path, |
| 1553 const SkMatrix& viewMatrix, | 1553 const SkMatrix& viewMatrix, |
| 1554 const SkRect& clipBounds) | 1554 const SkRect& clipBounds) |
| 1555 : fColor(color) | 1555 : fColor(color) |
| 1556 , fPath(path) | 1556 , fPath(path) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1585 SkMatrix vmi; | 1585 SkMatrix vmi; |
| 1586 if (!viewM.invert(&vmi)) { | 1586 if (!viewM.invert(&vmi)) { |
| 1587 return false; | 1587 return false; |
| 1588 } | 1588 } |
| 1589 vmi.mapRect(&clipBounds); | 1589 vmi.mapRect(&clipBounds); |
| 1590 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); | 1590 SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(color, path, viewM
, clipBounds)); |
| 1591 target->drawBatch(pipelineBuilder, batch); | 1591 target->drawBatch(pipelineBuilder, batch); |
| 1592 | 1592 |
| 1593 return true; | 1593 return true; |
| 1594 } | 1594 } |
| OLD | NEW |