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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 instanceCount -= drawInfo.instanceCount(); | 829 instanceCount -= drawInfo.instanceCount(); |
830 } | 830 } |
831 } | 831 } |
832 | 832 |
833 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 833 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
834 | 834 |
835 private: | 835 private: |
836 CircleBatch(const Geometry& geometry) { | 836 CircleBatch(const Geometry& geometry) { |
837 this->initClassID<CircleBatch>(); | 837 this->initClassID<CircleBatch>(); |
838 fGeoData.push_back(geometry); | 838 fGeoData.push_back(geometry); |
| 839 |
| 840 this->setBounds(geometry.fDevBounds); |
839 } | 841 } |
840 | 842 |
841 bool onCombineIfPossible(GrBatch* t) override { | 843 bool onCombineIfPossible(GrBatch* t) override { |
842 CircleBatch* that = t->cast<CircleBatch>(); | 844 CircleBatch* that = t->cast<CircleBatch>(); |
843 | 845 |
844 // TODO use vertex color to avoid breaking batches | 846 // TODO use vertex color to avoid breaking batches |
845 if (this->color() != that->color()) { | 847 if (this->color() != that->color()) { |
846 return false; | 848 return false; |
847 } | 849 } |
848 | 850 |
849 if (this->stroke() != that->stroke()) { | 851 if (this->stroke() != that->stroke()) { |
850 return false; | 852 return false; |
851 } | 853 } |
852 | 854 |
853 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 855 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
854 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 856 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
855 return false; | 857 return false; |
856 } | 858 } |
857 | 859 |
858 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 860 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 861 this->joinBounds(that->bounds()); |
859 return true; | 862 return true; |
860 } | 863 } |
861 | 864 |
862 GrColor color() const { return fBatch.fColor; } | 865 GrColor color() const { return fBatch.fColor; } |
863 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 866 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
864 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 867 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
865 bool stroke() const { return fBatch.fStroke; } | 868 bool stroke() const { return fBatch.fStroke; } |
866 | 869 |
867 struct BatchTracker { | 870 struct BatchTracker { |
868 GrColor fColor; | 871 GrColor fColor; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 void GrOvalRenderer::drawCircle(GrDrawTarget* target, | 938 void GrOvalRenderer::drawCircle(GrDrawTarget* target, |
936 GrPipelineBuilder* pipelineBuilder, | 939 GrPipelineBuilder* pipelineBuilder, |
937 GrColor color, | 940 GrColor color, |
938 const SkMatrix& viewMatrix, | 941 const SkMatrix& viewMatrix, |
939 bool useCoverageAA, | 942 bool useCoverageAA, |
940 const SkRect& circle, | 943 const SkRect& circle, |
941 const SkStrokeRec& stroke) { | 944 const SkStrokeRec& stroke) { |
942 SkRect bounds; | 945 SkRect bounds; |
943 SkAutoTUnref<GrBatch> batch(create_circle_batch(color, viewMatrix, useCovera
geAA, circle, | 946 SkAutoTUnref<GrBatch> batch(create_circle_batch(color, viewMatrix, useCovera
geAA, circle, |
944 stroke, &bounds)); | 947 stroke, &bounds)); |
945 target->drawBatch(pipelineBuilder, batch, &bounds); | 948 target->drawBatch(pipelineBuilder, batch); |
946 } | 949 } |
947 | 950 |
948 /////////////////////////////////////////////////////////////////////////////// | 951 /////////////////////////////////////////////////////////////////////////////// |
949 | 952 |
950 class EllipseBatch : public GrBatch { | 953 class EllipseBatch : public GrBatch { |
951 public: | 954 public: |
952 struct Geometry { | 955 struct Geometry { |
953 GrColor fColor; | 956 GrColor fColor; |
954 SkMatrix fViewMatrix; | 957 SkMatrix fViewMatrix; |
955 SkScalar fXRadius; | 958 SkScalar fXRadius; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 instanceCount -= drawInfo.instanceCount(); | 1099 instanceCount -= drawInfo.instanceCount(); |
1097 } | 1100 } |
1098 } | 1101 } |
1099 | 1102 |
1100 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1103 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
1101 | 1104 |
1102 private: | 1105 private: |
1103 EllipseBatch(const Geometry& geometry) { | 1106 EllipseBatch(const Geometry& geometry) { |
1104 this->initClassID<EllipseBatch>(); | 1107 this->initClassID<EllipseBatch>(); |
1105 fGeoData.push_back(geometry); | 1108 fGeoData.push_back(geometry); |
| 1109 |
| 1110 this->setBounds(geometry.fDevBounds); |
1106 } | 1111 } |
1107 | 1112 |
1108 bool onCombineIfPossible(GrBatch* t) override { | 1113 bool onCombineIfPossible(GrBatch* t) override { |
1109 EllipseBatch* that = t->cast<EllipseBatch>(); | 1114 EllipseBatch* that = t->cast<EllipseBatch>(); |
1110 | 1115 |
1111 // TODO use vertex color to avoid breaking batches | 1116 // TODO use vertex color to avoid breaking batches |
1112 if (this->color() != that->color()) { | 1117 if (this->color() != that->color()) { |
1113 return false; | 1118 return false; |
1114 } | 1119 } |
1115 | 1120 |
1116 if (this->stroke() != that->stroke()) { | 1121 if (this->stroke() != that->stroke()) { |
1117 return false; | 1122 return false; |
1118 } | 1123 } |
1119 | 1124 |
1120 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 1125 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
1121 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 1126 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
1122 return false; | 1127 return false; |
1123 } | 1128 } |
1124 | 1129 |
1125 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 1130 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 1131 this->joinBounds(that->bounds()); |
1126 return true; | 1132 return true; |
1127 } | 1133 } |
1128 | 1134 |
1129 GrColor color() const { return fBatch.fColor; } | 1135 GrColor color() const { return fBatch.fColor; } |
1130 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 1136 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
1131 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 1137 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
1132 bool stroke() const { return fBatch.fStroke; } | 1138 bool stroke() const { return fBatch.fStroke; } |
1133 | 1139 |
1134 struct BatchTracker { | 1140 struct BatchTracker { |
1135 GrColor fColor; | 1141 GrColor fColor; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 bool useCoverageAA, | 1249 bool useCoverageAA, |
1244 const SkRect& ellipse, | 1250 const SkRect& ellipse, |
1245 const SkStrokeRec& stroke) { | 1251 const SkStrokeRec& stroke) { |
1246 SkRect bounds; | 1252 SkRect bounds; |
1247 SkAutoTUnref<GrBatch> batch(create_ellipse_batch(color, viewMatrix, useCover
ageAA, ellipse, | 1253 SkAutoTUnref<GrBatch> batch(create_ellipse_batch(color, viewMatrix, useCover
ageAA, ellipse, |
1248 stroke, &bounds)); | 1254 stroke, &bounds)); |
1249 if (!batch) { | 1255 if (!batch) { |
1250 return false; | 1256 return false; |
1251 } | 1257 } |
1252 | 1258 |
1253 target->drawBatch(pipelineBuilder, batch, &bounds); | 1259 target->drawBatch(pipelineBuilder, batch); |
1254 return true; | 1260 return true; |
1255 } | 1261 } |
1256 | 1262 |
1257 ////////////////////////////////////////////////////////////////////////////////
///////////////// | 1263 ////////////////////////////////////////////////////////////////////////////////
///////////////// |
1258 | 1264 |
1259 class DIEllipseBatch : public GrBatch { | 1265 class DIEllipseBatch : public GrBatch { |
1260 public: | 1266 public: |
1261 struct Geometry { | 1267 struct Geometry { |
1262 GrColor fColor; | 1268 GrColor fColor; |
1263 SkMatrix fViewMatrix; | 1269 SkMatrix fViewMatrix; |
1264 SkScalar fXRadius; | 1270 SkScalar fXRadius; |
1265 SkScalar fYRadius; | 1271 SkScalar fYRadius; |
1266 SkScalar fInnerXRadius; | 1272 SkScalar fInnerXRadius; |
1267 SkScalar fInnerYRadius; | 1273 SkScalar fInnerYRadius; |
1268 SkScalar fGeoDx; | 1274 SkScalar fGeoDx; |
1269 SkScalar fGeoDy; | 1275 SkScalar fGeoDy; |
1270 DIEllipseEdgeEffect::Mode fMode; | 1276 DIEllipseEdgeEffect::Mode fMode; |
1271 SkRect fBounds; | 1277 SkRect fBounds; |
1272 }; | 1278 }; |
1273 | 1279 |
1274 static GrBatch* Create(const Geometry& geometry) { | 1280 static GrBatch* Create(const Geometry& geometry, const SkRect& bounds) { |
1275 return SkNEW_ARGS(DIEllipseBatch, (geometry)); | 1281 return SkNEW_ARGS(DIEllipseBatch, (geometry, bounds)); |
1276 } | 1282 } |
1277 | 1283 |
1278 const char* name() const override { return "DIEllipseBatch"; } | 1284 const char* name() const override { return "DIEllipseBatch"; } |
1279 | 1285 |
1280 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1286 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
1281 // When this is called on a batch, there is only one geometry bundle | 1287 // When this is called on a batch, there is only one geometry bundle |
1282 out->setKnownFourComponents(fGeoData[0].fColor); | 1288 out->setKnownFourComponents(fGeoData[0].fColor); |
1283 } | 1289 } |
1284 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 1290 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
1285 out->setUnknownSingleComponent(); | 1291 out->setUnknownSingleComponent(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 batchTarget->draw(drawInfo); | 1401 batchTarget->draw(drawInfo); |
1396 | 1402 |
1397 drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCoun
t()); | 1403 drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCoun
t()); |
1398 instanceCount -= drawInfo.instanceCount(); | 1404 instanceCount -= drawInfo.instanceCount(); |
1399 } | 1405 } |
1400 } | 1406 } |
1401 | 1407 |
1402 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1408 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
1403 | 1409 |
1404 private: | 1410 private: |
1405 DIEllipseBatch(const Geometry& geometry) { | 1411 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) { |
1406 this->initClassID<DIEllipseBatch>(); | 1412 this->initClassID<DIEllipseBatch>(); |
1407 fGeoData.push_back(geometry); | 1413 fGeoData.push_back(geometry); |
| 1414 |
| 1415 this->setBounds(bounds); |
1408 } | 1416 } |
1409 | 1417 |
1410 bool onCombineIfPossible(GrBatch* t) override { | 1418 bool onCombineIfPossible(GrBatch* t) override { |
1411 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); | 1419 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); |
1412 | 1420 |
1413 // TODO use vertex color to avoid breaking batches | 1421 // TODO use vertex color to avoid breaking batches |
1414 if (this->color() != that->color()) { | 1422 if (this->color() != that->color()) { |
1415 return false; | 1423 return false; |
1416 } | 1424 } |
1417 | 1425 |
1418 if (this->mode() != that->mode()) { | 1426 if (this->mode() != that->mode()) { |
1419 return false; | 1427 return false; |
1420 } | 1428 } |
1421 | 1429 |
1422 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 1430 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
1423 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 1431 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
1424 return false; | 1432 return false; |
1425 } | 1433 } |
1426 | 1434 |
1427 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 1435 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 1436 this->joinBounds(that->bounds()); |
1428 return true; | 1437 return true; |
1429 } | 1438 } |
1430 | 1439 |
1431 GrColor color() const { return fBatch.fColor; } | 1440 GrColor color() const { return fBatch.fColor; } |
1432 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 1441 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
1433 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 1442 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
1434 DIEllipseEdgeEffect::Mode mode() const { return fBatch.fMode; } | 1443 DIEllipseEdgeEffect::Mode mode() const { return fBatch.fMode; } |
1435 | 1444 |
1436 struct BatchTracker { | 1445 struct BatchTracker { |
1437 GrColor fColor; | 1446 GrColor fColor; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 geometry.fXRadius = xRadius; | 1527 geometry.fXRadius = xRadius; |
1519 geometry.fYRadius = yRadius; | 1528 geometry.fYRadius = yRadius; |
1520 geometry.fInnerXRadius = innerXRadius; | 1529 geometry.fInnerXRadius = innerXRadius; |
1521 geometry.fInnerYRadius = innerYRadius; | 1530 geometry.fInnerYRadius = innerYRadius; |
1522 geometry.fGeoDx = geoDx; | 1531 geometry.fGeoDx = geoDx; |
1523 geometry.fGeoDy = geoDy; | 1532 geometry.fGeoDy = geoDy; |
1524 geometry.fMode = mode; | 1533 geometry.fMode = mode; |
1525 geometry.fBounds = *bounds; | 1534 geometry.fBounds = *bounds; |
1526 | 1535 |
1527 viewMatrix.mapRect(bounds); | 1536 viewMatrix.mapRect(bounds); |
1528 return DIEllipseBatch::Create(geometry); | 1537 return DIEllipseBatch::Create(geometry, *bounds); |
1529 } | 1538 } |
1530 | 1539 |
1531 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, | 1540 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, |
1532 GrPipelineBuilder* pipelineBuilder, | 1541 GrPipelineBuilder* pipelineBuilder, |
1533 GrColor color, | 1542 GrColor color, |
1534 const SkMatrix& viewMatrix, | 1543 const SkMatrix& viewMatrix, |
1535 bool useCoverageAA, | 1544 bool useCoverageAA, |
1536 const SkRect& ellipse, | 1545 const SkRect& ellipse, |
1537 const SkStrokeRec& stroke) { | 1546 const SkStrokeRec& stroke) { |
1538 SkRect bounds; | 1547 SkRect bounds; |
1539 SkAutoTUnref<GrBatch> batch(create_diellipse_batch(color, viewMatrix, useCov
erageAA, ellipse, | 1548 SkAutoTUnref<GrBatch> batch(create_diellipse_batch(color, viewMatrix, useCov
erageAA, ellipse, |
1540 stroke, &bounds)); | 1549 stroke, &bounds)); |
1541 if (!batch) { | 1550 if (!batch) { |
1542 return false; | 1551 return false; |
1543 } | 1552 } |
1544 target->drawBatch(pipelineBuilder, batch, &bounds); | 1553 target->drawBatch(pipelineBuilder, batch); |
1545 return true; | 1554 return true; |
1546 } | 1555 } |
1547 | 1556 |
1548 /////////////////////////////////////////////////////////////////////////////// | 1557 /////////////////////////////////////////////////////////////////////////////// |
1549 | 1558 |
1550 static const uint16_t gRRectIndices[] = { | 1559 static const uint16_t gRRectIndices[] = { |
1551 // corners | 1560 // corners |
1552 0, 1, 5, 0, 5, 4, | 1561 0, 1, 5, 0, 5, 4, |
1553 2, 3, 7, 2, 7, 6, | 1562 2, 3, 7, 2, 7, 6, |
1554 8, 9, 13, 8, 13, 12, | 1563 8, 9, 13, 8, 13, 12, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 } | 1805 } |
1797 } | 1806 } |
1798 | 1807 |
1799 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1808 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
1800 | 1809 |
1801 private: | 1810 private: |
1802 RRectCircleRendererBatch(const Geometry& geometry, const GrIndexBuffer* inde
xBuffer) | 1811 RRectCircleRendererBatch(const Geometry& geometry, const GrIndexBuffer* inde
xBuffer) |
1803 : fIndexBuffer(indexBuffer) { | 1812 : fIndexBuffer(indexBuffer) { |
1804 this->initClassID<RRectCircleRendererBatch>(); | 1813 this->initClassID<RRectCircleRendererBatch>(); |
1805 fGeoData.push_back(geometry); | 1814 fGeoData.push_back(geometry); |
| 1815 |
| 1816 this->setBounds(geometry.fDevBounds); |
1806 } | 1817 } |
1807 | 1818 |
1808 bool onCombineIfPossible(GrBatch* t) override { | 1819 bool onCombineIfPossible(GrBatch* t) override { |
1809 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); | 1820 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); |
1810 | 1821 |
1811 // TODO use vertex color to avoid breaking batches | 1822 // TODO use vertex color to avoid breaking batches |
1812 if (this->color() != that->color()) { | 1823 if (this->color() != that->color()) { |
1813 return false; | 1824 return false; |
1814 } | 1825 } |
1815 | 1826 |
1816 if (this->stroke() != that->stroke()) { | 1827 if (this->stroke() != that->stroke()) { |
1817 return false; | 1828 return false; |
1818 } | 1829 } |
1819 | 1830 |
1820 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 1831 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
1821 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 1832 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
1822 return false; | 1833 return false; |
1823 } | 1834 } |
1824 | 1835 |
1825 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 1836 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 1837 this->joinBounds(that->bounds()); |
1826 return true; | 1838 return true; |
1827 } | 1839 } |
1828 | 1840 |
1829 GrColor color() const { return fBatch.fColor; } | 1841 GrColor color() const { return fBatch.fColor; } |
1830 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 1842 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
1831 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 1843 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
1832 bool stroke() const { return fBatch.fStroke; } | 1844 bool stroke() const { return fBatch.fStroke; } |
1833 | 1845 |
1834 struct BatchTracker { | 1846 struct BatchTracker { |
1835 GrColor fColor; | 1847 GrColor fColor; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 } | 2027 } |
2016 } | 2028 } |
2017 | 2029 |
2018 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 2030 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
2019 | 2031 |
2020 private: | 2032 private: |
2021 RRectEllipseRendererBatch(const Geometry& geometry, const GrIndexBuffer* ind
exBuffer) | 2033 RRectEllipseRendererBatch(const Geometry& geometry, const GrIndexBuffer* ind
exBuffer) |
2022 : fIndexBuffer(indexBuffer) { | 2034 : fIndexBuffer(indexBuffer) { |
2023 this->initClassID<RRectEllipseRendererBatch>(); | 2035 this->initClassID<RRectEllipseRendererBatch>(); |
2024 fGeoData.push_back(geometry); | 2036 fGeoData.push_back(geometry); |
| 2037 |
| 2038 this->setBounds(geometry.fDevBounds); |
2025 } | 2039 } |
2026 | 2040 |
2027 bool onCombineIfPossible(GrBatch* t) override { | 2041 bool onCombineIfPossible(GrBatch* t) override { |
2028 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); | 2042 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); |
2029 | 2043 |
2030 // TODO use vertex color to avoid breaking batches | 2044 // TODO use vertex color to avoid breaking batches |
2031 if (this->color() != that->color()) { | 2045 if (this->color() != that->color()) { |
2032 return false; | 2046 return false; |
2033 } | 2047 } |
2034 | 2048 |
2035 if (this->stroke() != that->stroke()) { | 2049 if (this->stroke() != that->stroke()) { |
2036 return false; | 2050 return false; |
2037 } | 2051 } |
2038 | 2052 |
2039 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 2053 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
2040 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 2054 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
2041 return false; | 2055 return false; |
2042 } | 2056 } |
2043 | 2057 |
2044 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 2058 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 2059 this->joinBounds(that->bounds()); |
2045 return true; | 2060 return true; |
2046 } | 2061 } |
2047 | 2062 |
2048 GrColor color() const { return fBatch.fColor; } | 2063 GrColor color() const { return fBatch.fColor; } |
2049 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } | 2064 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } |
2050 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } | 2065 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } |
2051 bool stroke() const { return fBatch.fStroke; } | 2066 bool stroke() const { return fBatch.fStroke; } |
2052 | 2067 |
2053 struct BatchTracker { | 2068 struct BatchTracker { |
2054 GrColor fColor; | 2069 GrColor fColor; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 } | 2287 } |
2273 | 2288 |
2274 SkRect bounds; | 2289 SkRect bounds; |
2275 SkAutoTUnref<GrBatch> batch(create_rrect_batch(color, viewMatrix, rrect, str
oke, &bounds, | 2290 SkAutoTUnref<GrBatch> batch(create_rrect_batch(color, viewMatrix, rrect, str
oke, &bounds, |
2276 &fStrokeRRectIndexBuffer, &fR
RectIndexBuffer, | 2291 &fStrokeRRectIndexBuffer, &fR
RectIndexBuffer, |
2277 fGpu)); | 2292 fGpu)); |
2278 if (!batch) { | 2293 if (!batch) { |
2279 return false; | 2294 return false; |
2280 } | 2295 } |
2281 | 2296 |
2282 target->drawBatch(pipelineBuilder, batch, &bounds); | 2297 target->drawBatch(pipelineBuilder, batch); |
2283 return true; | 2298 return true; |
2284 } | 2299 } |
2285 | 2300 |
2286 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 2301 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
2287 | 2302 |
2288 #ifdef GR_TEST_UTILS | 2303 #ifdef GR_TEST_UTILS |
2289 | 2304 |
2290 static SkStrokeRec random_strokerec(SkRandom* random) { | 2305 static SkStrokeRec random_strokerec(SkRandom* random) { |
2291 SkStrokeRec::InitStyle style = | 2306 SkStrokeRec::InitStyle style = |
2292 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); | 2307 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2348 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
2334 | 2349 |
2335 static GrIndexBuffer* gStrokeRRectIndexBuffer; | 2350 static GrIndexBuffer* gStrokeRRectIndexBuffer; |
2336 static GrIndexBuffer* gRRectIndexBuffer; | 2351 static GrIndexBuffer* gRRectIndexBuffer; |
2337 SkRect bounds; | 2352 SkRect bounds; |
2338 return create_rrect_batch(color, viewMatrix, rrect, random_strokerec(random)
, &bounds, | 2353 return create_rrect_batch(color, viewMatrix, rrect, random_strokerec(random)
, &bounds, |
2339 &gStrokeRRectIndexBuffer, &gRRectIndexBuffer, cont
ext->getGpu()); | 2354 &gStrokeRRectIndexBuffer, &gRRectIndexBuffer, cont
ext->getGpu()); |
2340 } | 2355 } |
2341 | 2356 |
2342 #endif | 2357 #endif |
OLD | NEW |