Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: src/gpu/GrOvalRenderer.cpp

Issue 1301663002: Privatize GrBatch subclass overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@drawsonvb
Patch Set: more Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 644
645 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 645 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
646 // When this is called on a batch, there is only one geometry bundle 646 // When this is called on a batch, there is only one geometry bundle
647 out->setKnownFourComponents(fGeoData[0].fColor); 647 out->setKnownFourComponents(fGeoData[0].fColor);
648 } 648 }
649 649
650 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 650 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
651 out->setUnknownSingleComponent(); 651 out->setUnknownSingleComponent();
652 } 652 }
653 653
654 private:
654 void initBatchTracker(const GrPipelineOptimizations& opt) override { 655 void initBatchTracker(const GrPipelineOptimizations& opt) override {
655 // Handle any color overrides 656 // Handle any color overrides
656 if (!opt.readsColor()) { 657 if (!opt.readsColor()) {
657 fGeoData[0].fColor = GrColor_ILLEGAL; 658 fGeoData[0].fColor = GrColor_ILLEGAL;
658 } 659 }
659 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 660 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
660 661
661 // setup batch properties 662 // setup batch properties
662 fBatch.fColorIgnored = !opt.readsColor(); 663 fBatch.fColorIgnored = !opt.readsColor();
663 fBatch.fColor = fGeoData[0].fColor; 664 fBatch.fColor = fGeoData[0].fColor;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 verts[3].fOuterRadius = outerRadius; 721 verts[3].fOuterRadius = outerRadius;
721 verts[3].fInnerRadius = innerRadius; 722 verts[3].fInnerRadius = innerRadius;
722 723
723 verts += kVerticesPerQuad; 724 verts += kVerticesPerQuad;
724 } 725 }
725 helper.recordDraw(target); 726 helper.recordDraw(target);
726 } 727 }
727 728
728 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 729 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
729 730
730 private:
731 CircleBatch(const Geometry& geometry) { 731 CircleBatch(const Geometry& geometry) {
732 this->initClassID<CircleBatch>(); 732 this->initClassID<CircleBatch>();
733 fGeoData.push_back(geometry); 733 fGeoData.push_back(geometry);
734 734
735 this->setBounds(geometry.fDevBounds); 735 this->setBounds(geometry.fDevBounds);
736 } 736 }
737 737
738 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 738 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
739 CircleBatch* that = t->cast<CircleBatch>(); 739 CircleBatch* that = t->cast<CircleBatch>();
740 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 740 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 const char* name() const override { return "EllipseBatch"; } 862 const char* name() const override { return "EllipseBatch"; }
863 863
864 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 864 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
865 // When this is called on a batch, there is only one geometry bundle 865 // When this is called on a batch, there is only one geometry bundle
866 out->setKnownFourComponents(fGeoData[0].fColor); 866 out->setKnownFourComponents(fGeoData[0].fColor);
867 } 867 }
868 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 868 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
869 out->setUnknownSingleComponent(); 869 out->setUnknownSingleComponent();
870 } 870 }
871 871
872 private:
872 void initBatchTracker(const GrPipelineOptimizations& opt) override { 873 void initBatchTracker(const GrPipelineOptimizations& opt) override {
873 // Handle any color overrides 874 // Handle any color overrides
874 if (!opt.readsCoverage()) { 875 if (!opt.readsCoverage()) {
875 fGeoData[0].fColor = GrColor_ILLEGAL; 876 fGeoData[0].fColor = GrColor_ILLEGAL;
876 } 877 }
877 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 878 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
878 879
879 // setup batch properties 880 // setup batch properties
880 fBatch.fColorIgnored = !opt.readsColor(); 881 fBatch.fColorIgnored = !opt.readsColor();
881 fBatch.fColor = fGeoData[0].fColor; 882 fBatch.fColor = fGeoData[0].fColor;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 944 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
944 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip) ; 945 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip) ;
945 946
946 verts += kVerticesPerQuad; 947 verts += kVerticesPerQuad;
947 } 948 }
948 helper.recordDraw(target); 949 helper.recordDraw(target);
949 } 950 }
950 951
951 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 952 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
952 953
953 private:
954 EllipseBatch(const Geometry& geometry) { 954 EllipseBatch(const Geometry& geometry) {
955 this->initClassID<EllipseBatch>(); 955 this->initClassID<EllipseBatch>();
956 fGeoData.push_back(geometry); 956 fGeoData.push_back(geometry);
957 957
958 this->setBounds(geometry.fDevBounds); 958 this->setBounds(geometry.fDevBounds);
959 } 959 }
960 960
961 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 961 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
962 EllipseBatch* that = t->cast<EllipseBatch>(); 962 EllipseBatch* that = t->cast<EllipseBatch>();
963 963
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 const char* name() const override { return "DIEllipseBatch"; } 1130 const char* name() const override { return "DIEllipseBatch"; }
1131 1131
1132 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1132 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1133 // When this is called on a batch, there is only one geometry bundle 1133 // When this is called on a batch, there is only one geometry bundle
1134 out->setKnownFourComponents(fGeoData[0].fColor); 1134 out->setKnownFourComponents(fGeoData[0].fColor);
1135 } 1135 }
1136 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1136 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
1137 out->setUnknownSingleComponent(); 1137 out->setUnknownSingleComponent();
1138 } 1138 }
1139 1139
1140 private:
1141
1140 void initBatchTracker(const GrPipelineOptimizations& opt) override { 1142 void initBatchTracker(const GrPipelineOptimizations& opt) override {
1141 // Handle any color overrides 1143 // Handle any color overrides
1142 if (!opt.readsColor()) { 1144 if (!opt.readsColor()) {
1143 fGeoData[0].fColor = GrColor_ILLEGAL; 1145 fGeoData[0].fColor = GrColor_ILLEGAL;
1144 } 1146 }
1145 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 1147 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
1146 1148
1147 // setup batch properties 1149 // setup batch properties
1148 fBatch.fColorIgnored = !opt.readsColor(); 1150 fBatch.fColorIgnored = !opt.readsColor();
1149 fBatch.fColor = fGeoData[0].fColor; 1151 fBatch.fColor = fGeoData[0].fColor;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse tDy); 1204 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse tDy);
1203 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner RatioY - offsetDy); 1205 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner RatioY - offsetDy);
1204 1206
1205 verts += kVerticesPerQuad; 1207 verts += kVerticesPerQuad;
1206 } 1208 }
1207 helper.recordDraw(target); 1209 helper.recordDraw(target);
1208 } 1210 }
1209 1211
1210 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 1212 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
1211 1213
1212 private:
1213 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) { 1214 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) {
1214 this->initClassID<DIEllipseBatch>(); 1215 this->initClassID<DIEllipseBatch>();
1215 fGeoData.push_back(geometry); 1216 fGeoData.push_back(geometry);
1216 1217
1217 this->setBounds(bounds); 1218 this->setBounds(bounds);
1218 } 1219 }
1219 1220
1220 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 1221 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
1221 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); 1222 DIEllipseBatch* that = t->cast<DIEllipseBatch>();
1222 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 1223 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 const char* name() const override { return "RRectCircleBatch"; } 1482 const char* name() const override { return "RRectCircleBatch"; }
1482 1483
1483 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1484 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1484 // When this is called on a batch, there is only one geometry bundle 1485 // When this is called on a batch, there is only one geometry bundle
1485 out->setKnownFourComponents(fGeoData[0].fColor); 1486 out->setKnownFourComponents(fGeoData[0].fColor);
1486 } 1487 }
1487 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1488 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
1488 out->setUnknownSingleComponent(); 1489 out->setUnknownSingleComponent();
1489 } 1490 }
1490 1491
1492 private:
1491 void initBatchTracker(const GrPipelineOptimizations& opt) override { 1493 void initBatchTracker(const GrPipelineOptimizations& opt) override {
1492 // Handle any color overrides 1494 // Handle any color overrides
1493 if (!opt.readsColor()) { 1495 if (!opt.readsColor()) {
1494 fGeoData[0].fColor = GrColor_ILLEGAL; 1496 fGeoData[0].fColor = GrColor_ILLEGAL;
1495 } 1497 }
1496 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 1498 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
1497 1499
1498 // setup batch properties 1500 // setup batch properties
1499 fBatch.fColorIgnored = !opt.readsColor(); 1501 fBatch.fColorIgnored = !opt.readsColor();
1500 fBatch.fColor = fGeoData[0].fColor; 1502 fBatch.fColor = fGeoData[0].fColor;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 verts->fInnerRadius = innerRadius; 1581 verts->fInnerRadius = innerRadius;
1580 verts++; 1582 verts++;
1581 } 1583 }
1582 } 1584 }
1583 1585
1584 helper.recordDraw(target); 1586 helper.recordDraw(target);
1585 } 1587 }
1586 1588
1587 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 1589 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
1588 1590
1589 private:
1590 RRectCircleRendererBatch(const Geometry& geometry) { 1591 RRectCircleRendererBatch(const Geometry& geometry) {
1591 this->initClassID<RRectCircleRendererBatch>(); 1592 this->initClassID<RRectCircleRendererBatch>();
1592 fGeoData.push_back(geometry); 1593 fGeoData.push_back(geometry);
1593 1594
1594 this->setBounds(geometry.fDevBounds); 1595 this->setBounds(geometry.fDevBounds);
1595 } 1596 }
1596 1597
1597 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 1598 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
1598 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); 1599 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>();
1599 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 1600 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 const char* name() const override { return "RRectEllipseRendererBatch"; } 1658 const char* name() const override { return "RRectEllipseRendererBatch"; }
1658 1659
1659 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1660 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1660 // When this is called on a batch, there is only one geometry bundle 1661 // When this is called on a batch, there is only one geometry bundle
1661 out->setKnownFourComponents(fGeoData[0].fColor); 1662 out->setKnownFourComponents(fGeoData[0].fColor);
1662 } 1663 }
1663 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1664 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
1664 out->setUnknownSingleComponent(); 1665 out->setUnknownSingleComponent();
1665 } 1666 }
1666 1667
1668 private:
1667 void initBatchTracker(const GrPipelineOptimizations& opt) override { 1669 void initBatchTracker(const GrPipelineOptimizations& opt) override {
1668 // Handle any color overrides 1670 // Handle any color overrides
1669 if (!opt.readsColor()) { 1671 if (!opt.readsColor()) {
1670 fGeoData[0].fColor = GrColor_ILLEGAL; 1672 fGeoData[0].fColor = GrColor_ILLEGAL;
1671 } 1673 }
1672 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 1674 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
1673 1675
1674 // setup batch properties 1676 // setup batch properties
1675 fBatch.fColorIgnored = !opt.readsColor(); 1677 fBatch.fColorIgnored = !opt.readsColor();
1676 fBatch.fColor = fGeoData[0].fColor; 1678 fBatch.fColor = fGeoData[0].fColor;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 1767 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
1766 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci p); 1768 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci p);
1767 verts++; 1769 verts++;
1768 } 1770 }
1769 } 1771 }
1770 helper.recordDraw(target); 1772 helper.recordDraw(target);
1771 } 1773 }
1772 1774
1773 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 1775 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
1774 1776
1775 private:
1776 RRectEllipseRendererBatch(const Geometry& geometry) { 1777 RRectEllipseRendererBatch(const Geometry& geometry) {
1777 this->initClassID<RRectEllipseRendererBatch>(); 1778 this->initClassID<RRectEllipseRendererBatch>();
1778 fGeoData.push_back(geometry); 1779 fGeoData.push_back(geometry);
1779 1780
1780 this->setBounds(geometry.fDevBounds); 1781 this->setBounds(geometry.fDevBounds);
1781 } 1782 }
1782 1783
1783 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 1784 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
1784 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); 1785 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>();
1785 1786
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 } 2037 }
2037 2038
2038 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 2039 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
2039 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2040 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2040 GrColor color = GrRandomColor(random); 2041 GrColor color = GrRandomColor(random);
2041 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2042 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2042 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2043 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2043 } 2044 }
2044 2045
2045 #endif 2046 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698