OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // When this is called on a batch, there is only one geometry bundle | 654 // When this is called on a batch, there is only one geometry bundle |
655 out->setKnownFourComponents(fGeoData[0].fColor); | 655 out->setKnownFourComponents(fGeoData[0].fColor); |
656 } | 656 } |
657 | 657 |
658 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 658 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
659 out->setUnknownSingleComponent(); | 659 out->setUnknownSingleComponent(); |
660 } | 660 } |
661 | 661 |
662 void initBatchTracker(const GrPipelineInfo& init) override { | 662 void initBatchTracker(const GrPipelineInfo& init) override { |
663 // Handle any color overrides | 663 // Handle any color overrides |
664 if (!init.readsColor()) { | 664 if (init.fColorIgnored) { |
665 fGeoData[0].fColor = GrColor_ILLEGAL; | 665 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 666 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 667 fGeoData[0].fColor = init.fOverrideColor; |
666 } | 668 } |
667 init.getOverrideColorIfSet(&fGeoData[0].fColor); | |
668 | 669 |
669 // setup batch properties | 670 // setup batch properties |
670 fBatch.fColorIgnored = !init.readsColor(); | 671 fBatch.fColorIgnored = init.fColorIgnored; |
671 fBatch.fColor = fGeoData[0].fColor; | 672 fBatch.fColor = fGeoData[0].fColor; |
672 fBatch.fStroke = fGeoData[0].fStroke; | 673 fBatch.fStroke = fGeoData[0].fStroke; |
673 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 674 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
674 fBatch.fCoverageIgnored = !init.readsCoverage(); | 675 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
675 } | 676 } |
676 | 677 |
677 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 678 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
678 SkMatrix invert; | 679 SkMatrix invert; |
679 if (!this->viewMatrix().invert(&invert)) { | 680 if (!this->viewMatrix().invert(&invert)) { |
680 return; | 681 return; |
681 } | 682 } |
682 | 683 |
683 // Setup geometry processor | 684 // Setup geometry processor |
684 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), | 685 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 869 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
869 // When this is called on a batch, there is only one geometry bundle | 870 // When this is called on a batch, there is only one geometry bundle |
870 out->setKnownFourComponents(fGeoData[0].fColor); | 871 out->setKnownFourComponents(fGeoData[0].fColor); |
871 } | 872 } |
872 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 873 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
873 out->setUnknownSingleComponent(); | 874 out->setUnknownSingleComponent(); |
874 } | 875 } |
875 | 876 |
876 void initBatchTracker(const GrPipelineInfo& init) override { | 877 void initBatchTracker(const GrPipelineInfo& init) override { |
877 // Handle any color overrides | 878 // Handle any color overrides |
878 if (!init.readsCoverage()) { | 879 if (init.fColorIgnored) { |
879 fGeoData[0].fColor = GrColor_ILLEGAL; | 880 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 881 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 882 fGeoData[0].fColor = init.fOverrideColor; |
880 } | 883 } |
881 init.getOverrideColorIfSet(&fGeoData[0].fColor); | |
882 | 884 |
883 // setup batch properties | 885 // setup batch properties |
884 fBatch.fColorIgnored = !init.readsColor(); | 886 fBatch.fColorIgnored = init.fColorIgnored; |
885 fBatch.fColor = fGeoData[0].fColor; | 887 fBatch.fColor = fGeoData[0].fColor; |
886 fBatch.fStroke = fGeoData[0].fStroke; | 888 fBatch.fStroke = fGeoData[0].fStroke; |
887 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 889 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
888 fBatch.fCoverageIgnored = !init.readsCoverage(); | 890 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
889 } | 891 } |
890 | 892 |
891 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 893 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
892 SkMatrix invert; | 894 SkMatrix invert; |
893 if (!this->viewMatrix().invert(&invert)) { | 895 if (!this->viewMatrix().invert(&invert)) { |
894 return; | 896 return; |
895 } | 897 } |
896 | 898 |
897 // Setup geometry processor | 899 // Setup geometry processor |
898 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 900 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1133 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1132 // When this is called on a batch, there is only one geometry bundle | 1134 // When this is called on a batch, there is only one geometry bundle |
1133 out->setKnownFourComponents(fGeoData[0].fColor); | 1135 out->setKnownFourComponents(fGeoData[0].fColor); |
1134 } | 1136 } |
1135 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1137 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1136 out->setUnknownSingleComponent(); | 1138 out->setUnknownSingleComponent(); |
1137 } | 1139 } |
1138 | 1140 |
1139 void initBatchTracker(const GrPipelineInfo& init) override { | 1141 void initBatchTracker(const GrPipelineInfo& init) override { |
1140 // Handle any color overrides | 1142 // Handle any color overrides |
1141 if (!init.readsColor()) { | 1143 if (init.fColorIgnored) { |
1142 fGeoData[0].fColor = GrColor_ILLEGAL; | 1144 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 1145 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 1146 fGeoData[0].fColor = init.fOverrideColor; |
1143 } | 1147 } |
1144 init.getOverrideColorIfSet(&fGeoData[0].fColor); | |
1145 | 1148 |
1146 // setup batch properties | 1149 // setup batch properties |
1147 fBatch.fColorIgnored = !init.readsColor(); | 1150 fBatch.fColorIgnored = init.fColorIgnored; |
1148 fBatch.fColor = fGeoData[0].fColor; | 1151 fBatch.fColor = fGeoData[0].fColor; |
1149 fBatch.fMode = fGeoData[0].fMode; | 1152 fBatch.fMode = fGeoData[0].fMode; |
1150 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 1153 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
1151 fBatch.fCoverageIgnored = !init.readsCoverage(); | 1154 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
1152 } | 1155 } |
1153 | 1156 |
1154 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1157 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1155 // Setup geometry processor | 1158 // Setup geometry processor |
1156 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), | 1159 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), |
1157 this->v
iewMatrix(), | 1160 this->v
iewMatrix(), |
1158 this->m
ode(), | 1161 this->m
ode(), |
1159 this->u
sesLocalCoords())); | 1162 this->u
sesLocalCoords())); |
1160 | 1163 |
1161 batchTarget->initDraw(gp, pipeline); | 1164 batchTarget->initDraw(gp, pipeline); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1482 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1480 // When this is called on a batch, there is only one geometry bundle | 1483 // When this is called on a batch, there is only one geometry bundle |
1481 out->setKnownFourComponents(fGeoData[0].fColor); | 1484 out->setKnownFourComponents(fGeoData[0].fColor); |
1482 } | 1485 } |
1483 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1486 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1484 out->setUnknownSingleComponent(); | 1487 out->setUnknownSingleComponent(); |
1485 } | 1488 } |
1486 | 1489 |
1487 void initBatchTracker(const GrPipelineInfo& init) override { | 1490 void initBatchTracker(const GrPipelineInfo& init) override { |
1488 // Handle any color overrides | 1491 // Handle any color overrides |
1489 if (!init.readsColor()) { | 1492 if (init.fColorIgnored) { |
1490 fGeoData[0].fColor = GrColor_ILLEGAL; | 1493 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 1494 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 1495 fGeoData[0].fColor = init.fOverrideColor; |
1491 } | 1496 } |
1492 init.getOverrideColorIfSet(&fGeoData[0].fColor); | |
1493 | 1497 |
1494 // setup batch properties | 1498 // setup batch properties |
1495 fBatch.fColorIgnored = !init.readsColor(); | 1499 fBatch.fColorIgnored = init.fColorIgnored; |
1496 fBatch.fColor = fGeoData[0].fColor; | 1500 fBatch.fColor = fGeoData[0].fColor; |
1497 fBatch.fStroke = fGeoData[0].fStroke; | 1501 fBatch.fStroke = fGeoData[0].fStroke; |
1498 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 1502 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
1499 fBatch.fCoverageIgnored = !init.readsCoverage(); | 1503 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
1500 } | 1504 } |
1501 | 1505 |
1502 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1506 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1503 // reset to device coordinates | 1507 // reset to device coordinates |
1504 SkMatrix invert; | 1508 SkMatrix invert; |
1505 if (!this->viewMatrix().invert(&invert)) { | 1509 if (!this->viewMatrix().invert(&invert)) { |
1506 SkDebugf("Failed to invert\n"); | 1510 SkDebugf("Failed to invert\n"); |
1507 return; | 1511 return; |
1508 } | 1512 } |
1509 | 1513 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1655 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1652 // When this is called on a batch, there is only one geometry bundle | 1656 // When this is called on a batch, there is only one geometry bundle |
1653 out->setKnownFourComponents(fGeoData[0].fColor); | 1657 out->setKnownFourComponents(fGeoData[0].fColor); |
1654 } | 1658 } |
1655 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1659 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1656 out->setUnknownSingleComponent(); | 1660 out->setUnknownSingleComponent(); |
1657 } | 1661 } |
1658 | 1662 |
1659 void initBatchTracker(const GrPipelineInfo& init) override { | 1663 void initBatchTracker(const GrPipelineInfo& init) override { |
1660 // Handle any color overrides | 1664 // Handle any color overrides |
1661 if (!init.readsColor()) { | 1665 if (init.fColorIgnored) { |
1662 fGeoData[0].fColor = GrColor_ILLEGAL; | 1666 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 1667 } else if (GrColor_ILLEGAL != init.fOverrideColor) { |
| 1668 fGeoData[0].fColor = init.fOverrideColor; |
1663 } | 1669 } |
1664 init.getOverrideColorIfSet(&fGeoData[0].fColor); | |
1665 | 1670 |
1666 // setup batch properties | 1671 // setup batch properties |
1667 fBatch.fColorIgnored = !init.readsColor(); | 1672 fBatch.fColorIgnored = init.fColorIgnored; |
1668 fBatch.fColor = fGeoData[0].fColor; | 1673 fBatch.fColor = fGeoData[0].fColor; |
1669 fBatch.fStroke = fGeoData[0].fStroke; | 1674 fBatch.fStroke = fGeoData[0].fStroke; |
1670 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 1675 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; |
1671 fBatch.fCoverageIgnored = !init.readsCoverage(); | 1676 fBatch.fCoverageIgnored = init.fCoverageIgnored; |
1672 } | 1677 } |
1673 | 1678 |
1674 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1679 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { |
1675 // reset to device coordinates | 1680 // reset to device coordinates |
1676 SkMatrix invert; | 1681 SkMatrix invert; |
1677 if (!this->viewMatrix().invert(&invert)) { | 1682 if (!this->viewMatrix().invert(&invert)) { |
1678 SkDebugf("Failed to invert\n"); | 1683 SkDebugf("Failed to invert\n"); |
1679 return; | 1684 return; |
1680 } | 1685 } |
1681 | 1686 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 } | 2028 } |
2024 | 2029 |
2025 BATCH_TEST_DEFINE(RRectBatch) { | 2030 BATCH_TEST_DEFINE(RRectBatch) { |
2026 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2031 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
2027 GrColor color = GrRandomColor(random); | 2032 GrColor color = GrRandomColor(random); |
2028 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2033 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
2029 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2034 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
2030 } | 2035 } |
2031 | 2036 |
2032 #endif | 2037 #endif |
OLD | NEW |