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

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

Issue 920423003: Stop lieing about GrBatch color for Rects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 5 years, 10 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/GrDrawTarget.cpp ('k') | src/gpu/GrTestBatch.h » ('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 "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 704
705 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { 705 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
706 // When this is called on a batch, there is only one geometry bundle 706 // When this is called on a batch, there is only one geometry bundle
707 out->setKnownFourComponents(fGeoData[0].fColor); 707 out->setKnownFourComponents(fGeoData[0].fColor);
708 } 708 }
709 709
710 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E { 710 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E {
711 out->setUnknownSingleComponent(); 711 out->setUnknownSingleComponent();
712 } 712 }
713 713
714 void initBatchOpt(const GrBatchOpt& batchOpt) {
715 fBatchOpt = batchOpt;
716 }
717
718 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { 714 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
719 // Handle any color overrides 715 // Handle any color overrides
720 if (init.fColorIgnored) { 716 if (init.fColorIgnored) {
721 fGeoData[0].fColor = GrColor_ILLEGAL; 717 fGeoData[0].fColor = GrColor_ILLEGAL;
722 } else if (GrColor_ILLEGAL != init.fOverrideColor) { 718 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
723 fGeoData[0].fColor = init.fOverrideColor; 719 fGeoData[0].fColor = init.fOverrideColor;
724 } 720 }
725 721
726 // setup batch properties 722 // setup batch properties
727 fBatch.fColorIgnored = init.fColorIgnored; 723 fBatch.fColorIgnored = init.fColorIgnored;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 GrColor fColor; 862 GrColor fColor;
867 bool fStroke; 863 bool fStroke;
868 bool fUsesLocalCoords; 864 bool fUsesLocalCoords;
869 bool fColorIgnored; 865 bool fColorIgnored;
870 bool fCoverageIgnored; 866 bool fCoverageIgnored;
871 }; 867 };
872 868
873 static const int kVertsPerCircle = 4; 869 static const int kVertsPerCircle = 4;
874 static const int kIndicesPerCircle = 6; 870 static const int kIndicesPerCircle = 6;
875 871
876 GrBatchOpt fBatchOpt;
877 BatchTracker fBatch; 872 BatchTracker fBatch;
878 SkSTArray<1, Geometry, true> fGeoData; 873 SkSTArray<1, Geometry, true> fGeoData;
879 }; 874 };
880 875
881 void GrOvalRenderer::drawCircle(GrDrawTarget* target, 876 void GrOvalRenderer::drawCircle(GrDrawTarget* target,
882 GrPipelineBuilder* pipelineBuilder, 877 GrPipelineBuilder* pipelineBuilder,
883 GrColor color, 878 GrColor color,
884 const SkMatrix& viewMatrix, 879 const SkMatrix& viewMatrix,
885 bool useCoverageAA, 880 bool useCoverageAA,
886 const SkRect& circle, 881 const SkRect& circle,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 const char* name() const SK_OVERRIDE { return "EllipseBatch"; } 954 const char* name() const SK_OVERRIDE { return "EllipseBatch"; }
960 955
961 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { 956 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
962 // When this is called on a batch, there is only one geometry bundle 957 // When this is called on a batch, there is only one geometry bundle
963 out->setKnownFourComponents(fGeoData[0].fColor); 958 out->setKnownFourComponents(fGeoData[0].fColor);
964 } 959 }
965 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E { 960 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E {
966 out->setUnknownSingleComponent(); 961 out->setUnknownSingleComponent();
967 } 962 }
968 963
969 void initBatchOpt(const GrBatchOpt& batchOpt) {
970 fBatchOpt = batchOpt;
971 }
972
973 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { 964 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
974 // Handle any color overrides 965 // Handle any color overrides
975 if (init.fColorIgnored) { 966 if (init.fColorIgnored) {
976 fGeoData[0].fColor = GrColor_ILLEGAL; 967 fGeoData[0].fColor = GrColor_ILLEGAL;
977 } else if (GrColor_ILLEGAL != init.fOverrideColor) { 968 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
978 fGeoData[0].fColor = init.fOverrideColor; 969 fGeoData[0].fColor = init.fOverrideColor;
979 } 970 }
980 971
981 // setup batch properties 972 // setup batch properties
982 fBatch.fColorIgnored = init.fColorIgnored; 973 fBatch.fColorIgnored = init.fColorIgnored;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 GrColor fColor; 1117 GrColor fColor;
1127 bool fStroke; 1118 bool fStroke;
1128 bool fUsesLocalCoords; 1119 bool fUsesLocalCoords;
1129 bool fColorIgnored; 1120 bool fColorIgnored;
1130 bool fCoverageIgnored; 1121 bool fCoverageIgnored;
1131 }; 1122 };
1132 1123
1133 static const int kVertsPerEllipse = 4; 1124 static const int kVertsPerEllipse = 4;
1134 static const int kIndicesPerEllipse = 6; 1125 static const int kIndicesPerEllipse = 6;
1135 1126
1136 GrBatchOpt fBatchOpt;
1137 BatchTracker fBatch; 1127 BatchTracker fBatch;
1138 SkSTArray<1, Geometry, true> fGeoData; 1128 SkSTArray<1, Geometry, true> fGeoData;
1139 }; 1129 };
1140 1130
1141 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, 1131 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
1142 GrPipelineBuilder* pipelineBuilder, 1132 GrPipelineBuilder* pipelineBuilder,
1143 GrColor color, 1133 GrColor color,
1144 const SkMatrix& viewMatrix, 1134 const SkMatrix& viewMatrix,
1145 bool useCoverageAA, 1135 bool useCoverageAA,
1146 const SkRect& ellipse, 1136 const SkRect& ellipse,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 const char* name() const SK_OVERRIDE { return "DIEllipseBatch"; } 1250 const char* name() const SK_OVERRIDE { return "DIEllipseBatch"; }
1261 1251
1262 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { 1252 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
1263 // When this is called on a batch, there is only one geometry bundle 1253 // When this is called on a batch, there is only one geometry bundle
1264 out->setKnownFourComponents(fGeoData[0].fColor); 1254 out->setKnownFourComponents(fGeoData[0].fColor);
1265 } 1255 }
1266 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E { 1256 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E {
1267 out->setUnknownSingleComponent(); 1257 out->setUnknownSingleComponent();
1268 } 1258 }
1269 1259
1270 void initBatchOpt(const GrBatchOpt& batchOpt) {
1271 fBatchOpt = batchOpt;
1272 }
1273
1274 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { 1260 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
1275 // Handle any color overrides 1261 // Handle any color overrides
1276 if (init.fColorIgnored) { 1262 if (init.fColorIgnored) {
1277 fGeoData[0].fColor = GrColor_ILLEGAL; 1263 fGeoData[0].fColor = GrColor_ILLEGAL;
1278 } else if (GrColor_ILLEGAL != init.fOverrideColor) { 1264 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
1279 fGeoData[0].fColor = init.fOverrideColor; 1265 fGeoData[0].fColor = init.fOverrideColor;
1280 } 1266 }
1281 1267
1282 // setup batch properties 1268 // setup batch properties
1283 fBatch.fColorIgnored = init.fColorIgnored; 1269 fBatch.fColorIgnored = init.fColorIgnored;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 GrColor fColor; 1404 GrColor fColor;
1419 DIEllipseEdgeEffect::Mode fMode; 1405 DIEllipseEdgeEffect::Mode fMode;
1420 bool fUsesLocalCoords; 1406 bool fUsesLocalCoords;
1421 bool fColorIgnored; 1407 bool fColorIgnored;
1422 bool fCoverageIgnored; 1408 bool fCoverageIgnored;
1423 }; 1409 };
1424 1410
1425 static const int kVertsPerEllipse = 4; 1411 static const int kVertsPerEllipse = 4;
1426 static const int kIndicesPerEllipse = 6; 1412 static const int kIndicesPerEllipse = 6;
1427 1413
1428 GrBatchOpt fBatchOpt;
1429 BatchTracker fBatch; 1414 BatchTracker fBatch;
1430 SkSTArray<1, Geometry, true> fGeoData; 1415 SkSTArray<1, Geometry, true> fGeoData;
1431 }; 1416 };
1432 1417
1433 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, 1418 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
1434 GrPipelineBuilder* pipelineBuilder, 1419 GrPipelineBuilder* pipelineBuilder,
1435 GrColor color, 1420 GrColor color,
1436 const SkMatrix& viewMatrix, 1421 const SkMatrix& viewMatrix,
1437 bool useCoverageAA, 1422 bool useCoverageAA,
1438 const SkRect& ellipse, 1423 const SkRect& ellipse,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 const char* name() const SK_OVERRIDE { return "RRectCircleBatch"; } 1633 const char* name() const SK_OVERRIDE { return "RRectCircleBatch"; }
1649 1634
1650 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { 1635 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
1651 // When this is called on a batch, there is only one geometry bundle 1636 // When this is called on a batch, there is only one geometry bundle
1652 out->setKnownFourComponents(fGeoData[0].fColor); 1637 out->setKnownFourComponents(fGeoData[0].fColor);
1653 } 1638 }
1654 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E { 1639 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E {
1655 out->setUnknownSingleComponent(); 1640 out->setUnknownSingleComponent();
1656 } 1641 }
1657 1642
1658 void initBatchOpt(const GrBatchOpt& batchOpt) {
1659 fBatchOpt = batchOpt;
1660 }
1661
1662 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { 1643 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
1663 // Handle any color overrides 1644 // Handle any color overrides
1664 if (init.fColorIgnored) { 1645 if (init.fColorIgnored) {
1665 fGeoData[0].fColor = GrColor_ILLEGAL; 1646 fGeoData[0].fColor = GrColor_ILLEGAL;
1666 } else if (GrColor_ILLEGAL != init.fOverrideColor) { 1647 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
1667 fGeoData[0].fColor = init.fOverrideColor; 1648 fGeoData[0].fColor = init.fOverrideColor;
1668 } 1649 }
1669 1650
1670 // setup batch properties 1651 // setup batch properties
1671 fBatch.fColorIgnored = init.fColorIgnored; 1652 fBatch.fColorIgnored = init.fColorIgnored;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 bool stroke() const { return fBatch.fStroke; } 1805 bool stroke() const { return fBatch.fStroke; }
1825 1806
1826 struct BatchTracker { 1807 struct BatchTracker {
1827 GrColor fColor; 1808 GrColor fColor;
1828 bool fStroke; 1809 bool fStroke;
1829 bool fUsesLocalCoords; 1810 bool fUsesLocalCoords;
1830 bool fColorIgnored; 1811 bool fColorIgnored;
1831 bool fCoverageIgnored; 1812 bool fCoverageIgnored;
1832 }; 1813 };
1833 1814
1834 GrBatchOpt fBatchOpt;
1835 BatchTracker fBatch; 1815 BatchTracker fBatch;
1836 SkSTArray<1, Geometry, true> fGeoData; 1816 SkSTArray<1, Geometry, true> fGeoData;
1837 const GrIndexBuffer* fIndexBuffer; 1817 const GrIndexBuffer* fIndexBuffer;
1838 }; 1818 };
1839 1819
1840 class RRectEllipseRendererBatch : public GrBatch { 1820 class RRectEllipseRendererBatch : public GrBatch {
1841 public: 1821 public:
1842 struct Geometry { 1822 struct Geometry {
1843 GrColor fColor; 1823 GrColor fColor;
1844 SkMatrix fViewMatrix; 1824 SkMatrix fViewMatrix;
(...skipping 12 matching lines...) Expand all
1857 const char* name() const SK_OVERRIDE { return "RRectEllipseRendererBatch"; } 1837 const char* name() const SK_OVERRIDE { return "RRectEllipseRendererBatch"; }
1858 1838
1859 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE { 1839 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
1860 // When this is called on a batch, there is only one geometry bundle 1840 // When this is called on a batch, there is only one geometry bundle
1861 out->setKnownFourComponents(fGeoData[0].fColor); 1841 out->setKnownFourComponents(fGeoData[0].fColor);
1862 } 1842 }
1863 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E { 1843 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E {
1864 out->setUnknownSingleComponent(); 1844 out->setUnknownSingleComponent();
1865 } 1845 }
1866 1846
1867 void initBatchOpt(const GrBatchOpt& batchOpt) {
1868 fBatchOpt = batchOpt;
1869 }
1870
1871 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE { 1847 void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
1872 // Handle any color overrides 1848 // Handle any color overrides
1873 if (init.fColorIgnored) { 1849 if (init.fColorIgnored) {
1874 fGeoData[0].fColor = GrColor_ILLEGAL; 1850 fGeoData[0].fColor = GrColor_ILLEGAL;
1875 } else if (GrColor_ILLEGAL != init.fOverrideColor) { 1851 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
1876 fGeoData[0].fColor = init.fOverrideColor; 1852 fGeoData[0].fColor = init.fOverrideColor;
1877 } 1853 }
1878 1854
1879 // setup batch properties 1855 // setup batch properties
1880 fBatch.fColorIgnored = init.fColorIgnored; 1856 fBatch.fColorIgnored = init.fColorIgnored;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 bool stroke() const { return fBatch.fStroke; } 2019 bool stroke() const { return fBatch.fStroke; }
2044 2020
2045 struct BatchTracker { 2021 struct BatchTracker {
2046 GrColor fColor; 2022 GrColor fColor;
2047 bool fStroke; 2023 bool fStroke;
2048 bool fUsesLocalCoords; 2024 bool fUsesLocalCoords;
2049 bool fColorIgnored; 2025 bool fColorIgnored;
2050 bool fCoverageIgnored; 2026 bool fCoverageIgnored;
2051 }; 2027 };
2052 2028
2053 GrBatchOpt fBatchOpt;
2054 BatchTracker fBatch; 2029 BatchTracker fBatch;
2055 SkSTArray<1, Geometry, true> fGeoData; 2030 SkSTArray<1, Geometry, true> fGeoData;
2056 const GrIndexBuffer* fIndexBuffer; 2031 const GrIndexBuffer* fIndexBuffer;
2057 }; 2032 };
2058 2033
2059 bool GrOvalRenderer::drawRRect(GrDrawTarget* target, 2034 bool GrOvalRenderer::drawRRect(GrDrawTarget* target,
2060 GrPipelineBuilder* pipelineBuilder, 2035 GrPipelineBuilder* pipelineBuilder,
2061 GrColor color, 2036 GrColor color,
2062 const SkMatrix& viewMatrix, 2037 const SkMatrix& viewMatrix,
2063 bool useAA, 2038 bool useAA,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 geometry.fInnerXRadius = innerXRadius; 2198 geometry.fInnerXRadius = innerXRadius;
2224 geometry.fInnerYRadius = innerYRadius; 2199 geometry.fInnerYRadius = innerYRadius;
2225 geometry.fStroke = isStrokeOnly; 2200 geometry.fStroke = isStrokeOnly;
2226 geometry.fDevBounds = bounds; 2201 geometry.fDevBounds = bounds;
2227 2202
2228 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry, indexBuffer)); 2203 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry, indexBuffer));
2229 target->drawBatch(pipelineBuilder, batch, &bounds); 2204 target->drawBatch(pipelineBuilder, batch, &bounds);
2230 } 2205 }
2231 return true; 2206 return true;
2232 } 2207 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrTestBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698