| 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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 fGeoData[i].fColor, | 660 fGeoData[i].fColor, |
| 661 fGeoData[i].fDevBounds.fLeft, fGeoData[i].fDevBounds.
fTop, | 661 fGeoData[i].fDevBounds.fLeft, fGeoData[i].fDevBounds.
fTop, |
| 662 fGeoData[i].fDevBounds.fRight, fGeoData[i].fDevBounds
.fBottom, | 662 fGeoData[i].fDevBounds.fRight, fGeoData[i].fDevBounds
.fBottom, |
| 663 fGeoData[i].fInnerRadius, | 663 fGeoData[i].fInnerRadius, |
| 664 fGeoData[i].fOuterRadius); | 664 fGeoData[i].fOuterRadius); |
| 665 } | 665 } |
| 666 string.append(INHERITED::dumpInfo()); | 666 string.append(INHERITED::dumpInfo()); |
| 667 return string; | 667 return string; |
| 668 } | 668 } |
| 669 | 669 |
| 670 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 670 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 671 GrInitInvariantOutput* coverage, |
| 672 GrBatchToXPOverrides* overrides) const ove
rride { |
| 671 // When this is called on a batch, there is only one geometry bundle | 673 // When this is called on a batch, there is only one geometry bundle |
| 672 out->setKnownFourComponents(fGeoData[0].fColor); | 674 color->setKnownFourComponents(fGeoData[0].fColor); |
| 673 } | 675 coverage->setUnknownSingleComponent(); |
| 674 | 676 overrides->fUsePLSDstRead = false; |
| 675 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | |
| 676 out->setUnknownSingleComponent(); | |
| 677 } | 677 } |
| 678 | 678 |
| 679 private: | 679 private: |
| 680 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 680 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 681 // Handle any color overrides | 681 // Handle any color overrides |
| 682 if (!opt.readsColor()) { | 682 if (!overrides.readsColor()) { |
| 683 fGeoData[0].fColor = GrColor_ILLEGAL; | 683 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 684 } | 684 } |
| 685 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 685 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 686 | 686 |
| 687 // setup batch properties | 687 // setup batch properties |
| 688 fBatch.fColorIgnored = !opt.readsColor(); | 688 fBatch.fColorIgnored = !overrides.readsColor(); |
| 689 fBatch.fColor = fGeoData[0].fColor; | 689 fBatch.fColor = fGeoData[0].fColor; |
| 690 fBatch.fStroke = fGeoData[0].fStroke; | 690 fBatch.fStroke = fGeoData[0].fStroke; |
| 691 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 691 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
| 692 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 692 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
| 693 } | 693 } |
| 694 | 694 |
| 695 void onPrepareDraws(Target* target) override { | 695 void onPrepareDraws(Target* target) override { |
| 696 SkMatrix invert; | 696 SkMatrix invert; |
| 697 if (!this->viewMatrix().invert(&invert)) { | 697 if (!this->viewMatrix().invert(&invert)) { |
| 698 return; | 698 return; |
| 699 } | 699 } |
| 700 | 700 |
| 701 // Setup geometry processor | 701 // Setup geometry processor |
| 702 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), | 702 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 SkScalar fInnerXRadius; | 880 SkScalar fInnerXRadius; |
| 881 SkScalar fInnerYRadius; | 881 SkScalar fInnerYRadius; |
| 882 GrColor fColor; | 882 GrColor fColor; |
| 883 bool fStroke; | 883 bool fStroke; |
| 884 }; | 884 }; |
| 885 | 885 |
| 886 static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBat
ch(geometry); } | 886 static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBat
ch(geometry); } |
| 887 | 887 |
| 888 const char* name() const override { return "EllipseBatch"; } | 888 const char* name() const override { return "EllipseBatch"; } |
| 889 | 889 |
| 890 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 890 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 891 GrInitInvariantOutput* coverage, |
| 892 GrBatchToXPOverrides* overrides) const ove
rride { |
| 891 // When this is called on a batch, there is only one geometry bundle | 893 // When this is called on a batch, there is only one geometry bundle |
| 892 out->setKnownFourComponents(fGeoData[0].fColor); | 894 color->setKnownFourComponents(fGeoData[0].fColor); |
| 893 } | 895 coverage->setUnknownSingleComponent(); |
| 894 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 896 overrides->fUsePLSDstRead = false; |
| 895 out->setUnknownSingleComponent(); | |
| 896 } | 897 } |
| 897 | 898 |
| 898 private: | 899 private: |
| 899 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 900 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 900 // Handle any color overrides | 901 // Handle any color overrides |
| 901 if (!opt.readsCoverage()) { | 902 if (!overrides.readsCoverage()) { |
| 902 fGeoData[0].fColor = GrColor_ILLEGAL; | 903 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 903 } | 904 } |
| 904 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 905 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 905 | 906 |
| 906 // setup batch properties | 907 // setup batch properties |
| 907 fBatch.fColorIgnored = !opt.readsColor(); | 908 fBatch.fColorIgnored = !overrides.readsColor(); |
| 908 fBatch.fColor = fGeoData[0].fColor; | 909 fBatch.fColor = fGeoData[0].fColor; |
| 909 fBatch.fStroke = fGeoData[0].fStroke; | 910 fBatch.fStroke = fGeoData[0].fStroke; |
| 910 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 911 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
| 911 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 912 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
| 912 } | 913 } |
| 913 | 914 |
| 914 void onPrepareDraws(Target* target) override { | 915 void onPrepareDraws(Target* target) override { |
| 915 SkMatrix invert; | 916 SkMatrix invert; |
| 916 if (!this->viewMatrix().invert(&invert)) { | 917 if (!this->viewMatrix().invert(&invert)) { |
| 917 return; | 918 return; |
| 918 } | 919 } |
| 919 | 920 |
| 920 // Setup geometry processor | 921 // Setup geometry processor |
| 921 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 922 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 GrColor fColor; | 1152 GrColor fColor; |
| 1152 DIEllipseEdgeEffect::Mode fMode; | 1153 DIEllipseEdgeEffect::Mode fMode; |
| 1153 }; | 1154 }; |
| 1154 | 1155 |
| 1155 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { | 1156 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { |
| 1156 return new DIEllipseBatch(geometry, bounds); | 1157 return new DIEllipseBatch(geometry, bounds); |
| 1157 } | 1158 } |
| 1158 | 1159 |
| 1159 const char* name() const override { return "DIEllipseBatch"; } | 1160 const char* name() const override { return "DIEllipseBatch"; } |
| 1160 | 1161 |
| 1161 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1162 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 1163 GrInitInvariantOutput* coverage, |
| 1164 GrBatchToXPOverrides* overrides) const ove
rride { |
| 1162 // When this is called on a batch, there is only one geometry bundle | 1165 // When this is called on a batch, there is only one geometry bundle |
| 1163 out->setKnownFourComponents(fGeoData[0].fColor); | 1166 color->setKnownFourComponents(fGeoData[0].fColor); |
| 1164 } | 1167 coverage->setUnknownSingleComponent(); |
| 1165 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1168 overrides->fUsePLSDstRead = false; |
| 1166 out->setUnknownSingleComponent(); | |
| 1167 } | 1169 } |
| 1168 | 1170 |
| 1169 private: | 1171 private: |
| 1170 | 1172 |
| 1171 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 1173 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 1172 // Handle any color overrides | 1174 // Handle any color overrides |
| 1173 if (!opt.readsColor()) { | 1175 if (!overrides.readsColor()) { |
| 1174 fGeoData[0].fColor = GrColor_ILLEGAL; | 1176 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 1175 } | 1177 } |
| 1176 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 1178 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 1177 | 1179 |
| 1178 // setup batch properties | 1180 // setup batch properties |
| 1179 fBatch.fColorIgnored = !opt.readsColor(); | 1181 fBatch.fColorIgnored = !overrides.readsColor(); |
| 1180 fBatch.fColor = fGeoData[0].fColor; | 1182 fBatch.fColor = fGeoData[0].fColor; |
| 1181 fBatch.fMode = fGeoData[0].fMode; | 1183 fBatch.fMode = fGeoData[0].fMode; |
| 1182 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 1184 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
| 1183 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 1185 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
| 1184 } | 1186 } |
| 1185 | 1187 |
| 1186 void onPrepareDraws(Target* target) override { | 1188 void onPrepareDraws(Target* target) override { |
| 1187 // Setup geometry processor | 1189 // Setup geometry processor |
| 1188 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), | 1190 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), |
| 1189 this->v
iewMatrix(), | 1191 this->v
iewMatrix(), |
| 1190 this->m
ode(), | 1192 this->m
ode(), |
| 1191 this->u
sesLocalCoords())); | 1193 this->u
sesLocalCoords())); |
| 1192 | 1194 |
| 1193 target->initDraw(gp, this->pipeline()); | 1195 target->initDraw(gp, this->pipeline()); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 GrColor fColor; | 1508 GrColor fColor; |
| 1507 bool fStroke; | 1509 bool fStroke; |
| 1508 }; | 1510 }; |
| 1509 | 1511 |
| 1510 static GrDrawBatch* Create(const Geometry& geometry) { | 1512 static GrDrawBatch* Create(const Geometry& geometry) { |
| 1511 return new RRectCircleRendererBatch(geometry); | 1513 return new RRectCircleRendererBatch(geometry); |
| 1512 } | 1514 } |
| 1513 | 1515 |
| 1514 const char* name() const override { return "RRectCircleBatch"; } | 1516 const char* name() const override { return "RRectCircleBatch"; } |
| 1515 | 1517 |
| 1516 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1518 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 1519 GrInitInvariantOutput* coverage, |
| 1520 GrBatchToXPOverrides* overrides) const ove
rride { |
| 1517 // When this is called on a batch, there is only one geometry bundle | 1521 // When this is called on a batch, there is only one geometry bundle |
| 1518 out->setKnownFourComponents(fGeoData[0].fColor); | 1522 color->setKnownFourComponents(fGeoData[0].fColor); |
| 1519 } | 1523 coverage->setUnknownSingleComponent(); |
| 1520 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1524 overrides->fUsePLSDstRead = false; |
| 1521 out->setUnknownSingleComponent(); | |
| 1522 } | 1525 } |
| 1523 | 1526 |
| 1524 private: | 1527 private: |
| 1525 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 1528 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 1526 // Handle any color overrides | 1529 // Handle any color overrides |
| 1527 if (!opt.readsColor()) { | 1530 if (!overrides.readsColor()) { |
| 1528 fGeoData[0].fColor = GrColor_ILLEGAL; | 1531 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 1529 } | 1532 } |
| 1530 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 1533 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 1531 | 1534 |
| 1532 // setup batch properties | 1535 // setup batch properties |
| 1533 fBatch.fColorIgnored = !opt.readsColor(); | 1536 fBatch.fColorIgnored = !overrides.readsColor(); |
| 1534 fBatch.fColor = fGeoData[0].fColor; | 1537 fBatch.fColor = fGeoData[0].fColor; |
| 1535 fBatch.fStroke = fGeoData[0].fStroke; | 1538 fBatch.fStroke = fGeoData[0].fStroke; |
| 1536 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 1539 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
| 1537 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 1540 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
| 1538 } | 1541 } |
| 1539 | 1542 |
| 1540 void onPrepareDraws(Target* target) override { | 1543 void onPrepareDraws(Target* target) override { |
| 1541 // reset to device coordinates | 1544 // reset to device coordinates |
| 1542 SkMatrix invert; | 1545 SkMatrix invert; |
| 1543 if (!this->viewMatrix().invert(&invert)) { | 1546 if (!this->viewMatrix().invert(&invert)) { |
| 1544 SkDebugf("Failed to invert\n"); | 1547 SkDebugf("Failed to invert\n"); |
| 1545 return; | 1548 return; |
| 1546 } | 1549 } |
| 1547 | 1550 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 GrColor fColor; | 1688 GrColor fColor; |
| 1686 bool fStroke; | 1689 bool fStroke; |
| 1687 }; | 1690 }; |
| 1688 | 1691 |
| 1689 static GrDrawBatch* Create(const Geometry& geometry) { | 1692 static GrDrawBatch* Create(const Geometry& geometry) { |
| 1690 return new RRectEllipseRendererBatch(geometry); | 1693 return new RRectEllipseRendererBatch(geometry); |
| 1691 } | 1694 } |
| 1692 | 1695 |
| 1693 const char* name() const override { return "RRectEllipseRendererBatch"; } | 1696 const char* name() const override { return "RRectEllipseRendererBatch"; } |
| 1694 | 1697 |
| 1695 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1698 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 1699 GrInitInvariantOutput* coverage, |
| 1700 GrBatchToXPOverrides* overrides) const ove
rride { |
| 1696 // When this is called on a batch, there is only one geometry bundle | 1701 // When this is called on a batch, there is only one geometry bundle |
| 1697 out->setKnownFourComponents(fGeoData[0].fColor); | 1702 color->setKnownFourComponents(fGeoData[0].fColor); |
| 1698 } | 1703 coverage->setUnknownSingleComponent(); |
| 1699 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1704 overrides->fUsePLSDstRead = false; |
| 1700 out->setUnknownSingleComponent(); | |
| 1701 } | 1705 } |
| 1702 | 1706 |
| 1703 private: | 1707 private: |
| 1704 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 1708 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 1705 // Handle any color overrides | 1709 // Handle any color overrides |
| 1706 if (!opt.readsColor()) { | 1710 if (!overrides.readsColor()) { |
| 1707 fGeoData[0].fColor = GrColor_ILLEGAL; | 1711 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 1708 } | 1712 } |
| 1709 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 1713 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 1710 | 1714 |
| 1711 // setup batch properties | 1715 // setup batch properties |
| 1712 fBatch.fColorIgnored = !opt.readsColor(); | 1716 fBatch.fColorIgnored = !overrides.readsColor(); |
| 1713 fBatch.fColor = fGeoData[0].fColor; | 1717 fBatch.fColor = fGeoData[0].fColor; |
| 1714 fBatch.fStroke = fGeoData[0].fStroke; | 1718 fBatch.fStroke = fGeoData[0].fStroke; |
| 1715 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); | 1719 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
| 1716 fBatch.fCoverageIgnored = !opt.readsCoverage(); | 1720 fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
| 1717 } | 1721 } |
| 1718 | 1722 |
| 1719 void onPrepareDraws(Target* target) override { | 1723 void onPrepareDraws(Target* target) override { |
| 1720 // reset to device coordinates | 1724 // reset to device coordinates |
| 1721 SkMatrix invert; | 1725 SkMatrix invert; |
| 1722 if (!this->viewMatrix().invert(&invert)) { | 1726 if (!this->viewMatrix().invert(&invert)) { |
| 1723 SkDebugf("Failed to invert\n"); | 1727 SkDebugf("Failed to invert\n"); |
| 1724 return; | 1728 return; |
| 1725 } | 1729 } |
| 1726 | 1730 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 } | 2077 } |
| 2074 | 2078 |
| 2075 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 2079 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
| 2076 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2080 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
| 2077 GrColor color = GrRandomColor(random); | 2081 GrColor color = GrRandomColor(random); |
| 2078 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2082 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
| 2079 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2083 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
| 2080 } | 2084 } |
| 2081 | 2085 |
| 2082 #endif | 2086 #endif |
| OLD | NEW |