| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return false; | 599 return false; |
| 600 } | 600 } |
| 601 | 601 |
| 602 return true; | 602 return true; |
| 603 } | 603 } |
| 604 | 604 |
| 605 /////////////////////////////////////////////////////////////////////////////// | 605 /////////////////////////////////////////////////////////////////////////////// |
| 606 | 606 |
| 607 class CircleBatch : public GrVertexBatch { | 607 class CircleBatch : public GrVertexBatch { |
| 608 public: | 608 public: |
| 609 DEFINE_BATCH_CLASS_ID | |
| 610 | |
| 611 struct Geometry { | 609 struct Geometry { |
| 610 GrColor fColor; |
| 612 SkMatrix fViewMatrix; | 611 SkMatrix fViewMatrix; |
| 613 SkRect fDevBounds; | |
| 614 SkScalar fInnerRadius; | 612 SkScalar fInnerRadius; |
| 615 SkScalar fOuterRadius; | 613 SkScalar fOuterRadius; |
| 616 GrColor fColor; | |
| 617 bool fStroke; | 614 bool fStroke; |
| 615 SkRect fDevBounds; |
| 618 }; | 616 }; |
| 619 | 617 |
| 620 static GrDrawBatch* Create(const Geometry& geometry) { return new CircleBatc
h(geometry); } | 618 static GrDrawBatch* Create(const Geometry& geometry) { return new CircleBatc
h(geometry); } |
| 621 | 619 |
| 622 const char* name() const override { return "CircleBatch"; } | 620 const char* name() const override { return "CircleBatch"; } |
| 623 | 621 |
| 624 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 622 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 625 // When this is called on a batch, there is only one geometry bundle | 623 // When this is called on a batch, there is only one geometry bundle |
| 626 out->setKnownFourComponents(fGeoData[0].fColor); | 624 out->setKnownFourComponents(fGeoData[0].fColor); |
| 627 } | 625 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 verts[3].fOuterRadius = outerRadius; | 698 verts[3].fOuterRadius = outerRadius; |
| 701 verts[3].fInnerRadius = innerRadius; | 699 verts[3].fInnerRadius = innerRadius; |
| 702 | 700 |
| 703 verts += kVerticesPerQuad; | 701 verts += kVerticesPerQuad; |
| 704 } | 702 } |
| 705 helper.recordDraw(target); | 703 helper.recordDraw(target); |
| 706 } | 704 } |
| 707 | 705 |
| 708 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 706 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 709 | 707 |
| 710 CircleBatch(const Geometry& geometry) : INHERITED(ClassID()) { | 708 CircleBatch(const Geometry& geometry) { |
| 709 this->initClassID<CircleBatch>(); |
| 711 fGeoData.push_back(geometry); | 710 fGeoData.push_back(geometry); |
| 712 | 711 |
| 713 this->setBounds(geometry.fDevBounds); | 712 this->setBounds(geometry.fDevBounds); |
| 714 } | 713 } |
| 715 | 714 |
| 716 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 715 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 717 CircleBatch* that = t->cast<CircleBatch>(); | 716 CircleBatch* that = t->cast<CircleBatch>(); |
| 718 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 717 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 719 that->bounds(), caps)) { | 718 that->bounds(), caps)) { |
| 720 return false; | 719 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 747 struct BatchTracker { | 746 struct BatchTracker { |
| 748 GrColor fColor; | 747 GrColor fColor; |
| 749 bool fStroke; | 748 bool fStroke; |
| 750 bool fUsesLocalCoords; | 749 bool fUsesLocalCoords; |
| 751 bool fColorIgnored; | 750 bool fColorIgnored; |
| 752 bool fCoverageIgnored; | 751 bool fCoverageIgnored; |
| 753 }; | 752 }; |
| 754 | 753 |
| 755 BatchTracker fBatch; | 754 BatchTracker fBatch; |
| 756 SkSTArray<1, Geometry, true> fGeoData; | 755 SkSTArray<1, Geometry, true> fGeoData; |
| 757 | |
| 758 typedef GrVertexBatch INHERITED; | |
| 759 }; | 756 }; |
| 760 | 757 |
| 761 static GrDrawBatch* create_circle_batch(GrColor color, | 758 static GrDrawBatch* create_circle_batch(GrColor color, |
| 762 const SkMatrix& viewMatrix, | 759 const SkMatrix& viewMatrix, |
| 763 bool useCoverageAA, | 760 bool useCoverageAA, |
| 764 const SkRect& circle, | 761 const SkRect& circle, |
| 765 const SkStrokeRec& stroke) { | 762 const SkStrokeRec& stroke) { |
| 766 SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY()); | 763 SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY()); |
| 767 viewMatrix.mapPoints(¢er, 1); | 764 viewMatrix.mapPoints(¢er, 1); |
| 768 SkScalar radius = viewMatrix.mapRadius(SkScalarHalf(circle.width())); | 765 SkScalar radius = viewMatrix.mapRadius(SkScalarHalf(circle.width())); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 const SkStrokeRec& stroke) { | 814 const SkStrokeRec& stroke) { |
| 818 SkAutoTUnref<GrDrawBatch> batch(create_circle_batch(color, viewMatrix, useCo
verageAA, circle, | 815 SkAutoTUnref<GrDrawBatch> batch(create_circle_batch(color, viewMatrix, useCo
verageAA, circle, |
| 819 stroke)); | 816 stroke)); |
| 820 target->drawBatch(pipelineBuilder, batch); | 817 target->drawBatch(pipelineBuilder, batch); |
| 821 } | 818 } |
| 822 | 819 |
| 823 /////////////////////////////////////////////////////////////////////////////// | 820 /////////////////////////////////////////////////////////////////////////////// |
| 824 | 821 |
| 825 class EllipseBatch : public GrVertexBatch { | 822 class EllipseBatch : public GrVertexBatch { |
| 826 public: | 823 public: |
| 827 DEFINE_BATCH_CLASS_ID | |
| 828 | |
| 829 struct Geometry { | 824 struct Geometry { |
| 825 GrColor fColor; |
| 830 SkMatrix fViewMatrix; | 826 SkMatrix fViewMatrix; |
| 831 SkRect fDevBounds; | |
| 832 SkScalar fXRadius; | 827 SkScalar fXRadius; |
| 833 SkScalar fYRadius; | 828 SkScalar fYRadius; |
| 834 SkScalar fInnerXRadius; | 829 SkScalar fInnerXRadius; |
| 835 SkScalar fInnerYRadius; | 830 SkScalar fInnerYRadius; |
| 836 GrColor fColor; | |
| 837 bool fStroke; | 831 bool fStroke; |
| 832 SkRect fDevBounds; |
| 838 }; | 833 }; |
| 839 | 834 |
| 840 static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBat
ch(geometry); } | 835 static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBat
ch(geometry); } |
| 841 | 836 |
| 842 const char* name() const override { return "EllipseBatch"; } | 837 const char* name() const override { return "EllipseBatch"; } |
| 843 | 838 |
| 844 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 839 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 845 // When this is called on a batch, there is only one geometry bundle | 840 // When this is called on a batch, there is only one geometry bundle |
| 846 out->setKnownFourComponents(fGeoData[0].fColor); | 841 out->setKnownFourComponents(fGeoData[0].fColor); |
| 847 } | 842 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 919 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| 925 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip)
; | 920 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip)
; |
| 926 | 921 |
| 927 verts += kVerticesPerQuad; | 922 verts += kVerticesPerQuad; |
| 928 } | 923 } |
| 929 helper.recordDraw(target); | 924 helper.recordDraw(target); |
| 930 } | 925 } |
| 931 | 926 |
| 932 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 927 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 933 | 928 |
| 934 EllipseBatch(const Geometry& geometry) : INHERITED(ClassID()) { | 929 EllipseBatch(const Geometry& geometry) { |
| 930 this->initClassID<EllipseBatch>(); |
| 935 fGeoData.push_back(geometry); | 931 fGeoData.push_back(geometry); |
| 936 | 932 |
| 937 this->setBounds(geometry.fDevBounds); | 933 this->setBounds(geometry.fDevBounds); |
| 938 } | 934 } |
| 939 | 935 |
| 940 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 936 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 941 EllipseBatch* that = t->cast<EllipseBatch>(); | 937 EllipseBatch* that = t->cast<EllipseBatch>(); |
| 942 | 938 |
| 943 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 939 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 944 that->bounds(), caps)) { | 940 that->bounds(), caps)) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 972 struct BatchTracker { | 968 struct BatchTracker { |
| 973 GrColor fColor; | 969 GrColor fColor; |
| 974 bool fStroke; | 970 bool fStroke; |
| 975 bool fUsesLocalCoords; | 971 bool fUsesLocalCoords; |
| 976 bool fColorIgnored; | 972 bool fColorIgnored; |
| 977 bool fCoverageIgnored; | 973 bool fCoverageIgnored; |
| 978 }; | 974 }; |
| 979 | 975 |
| 980 BatchTracker fBatch; | 976 BatchTracker fBatch; |
| 981 SkSTArray<1, Geometry, true> fGeoData; | 977 SkSTArray<1, Geometry, true> fGeoData; |
| 982 | |
| 983 typedef GrVertexBatch INHERITED; | |
| 984 }; | 978 }; |
| 985 | 979 |
| 986 static GrDrawBatch* create_ellipse_batch(GrColor color, | 980 static GrDrawBatch* create_ellipse_batch(GrColor color, |
| 987 const SkMatrix& viewMatrix, | 981 const SkMatrix& viewMatrix, |
| 988 bool useCoverageAA, | 982 bool useCoverageAA, |
| 989 const SkRect& ellipse, | 983 const SkRect& ellipse, |
| 990 const SkStrokeRec& stroke) { | 984 const SkStrokeRec& stroke) { |
| 991 #ifdef SK_DEBUG | 985 #ifdef SK_DEBUG |
| 992 { | 986 { |
| 993 // we should have checked for this previously | 987 // we should have checked for this previously |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 } | 1078 } |
| 1085 | 1079 |
| 1086 target->drawBatch(pipelineBuilder, batch); | 1080 target->drawBatch(pipelineBuilder, batch); |
| 1087 return true; | 1081 return true; |
| 1088 } | 1082 } |
| 1089 | 1083 |
| 1090 ////////////////////////////////////////////////////////////////////////////////
///////////////// | 1084 ////////////////////////////////////////////////////////////////////////////////
///////////////// |
| 1091 | 1085 |
| 1092 class DIEllipseBatch : public GrVertexBatch { | 1086 class DIEllipseBatch : public GrVertexBatch { |
| 1093 public: | 1087 public: |
| 1094 DEFINE_BATCH_CLASS_ID | |
| 1095 | |
| 1096 struct Geometry { | 1088 struct Geometry { |
| 1089 GrColor fColor; |
| 1097 SkMatrix fViewMatrix; | 1090 SkMatrix fViewMatrix; |
| 1098 SkRect fBounds; | |
| 1099 SkScalar fXRadius; | 1091 SkScalar fXRadius; |
| 1100 SkScalar fYRadius; | 1092 SkScalar fYRadius; |
| 1101 SkScalar fInnerXRadius; | 1093 SkScalar fInnerXRadius; |
| 1102 SkScalar fInnerYRadius; | 1094 SkScalar fInnerYRadius; |
| 1103 SkScalar fGeoDx; | 1095 SkScalar fGeoDx; |
| 1104 SkScalar fGeoDy; | 1096 SkScalar fGeoDy; |
| 1105 GrColor fColor; | |
| 1106 DIEllipseEdgeEffect::Mode fMode; | 1097 DIEllipseEdgeEffect::Mode fMode; |
| 1098 SkRect fBounds; |
| 1107 }; | 1099 }; |
| 1108 | 1100 |
| 1109 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { | 1101 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { |
| 1110 return new DIEllipseBatch(geometry, bounds); | 1102 return new DIEllipseBatch(geometry, bounds); |
| 1111 } | 1103 } |
| 1112 | 1104 |
| 1113 const char* name() const override { return "DIEllipseBatch"; } | 1105 const char* name() const override { return "DIEllipseBatch"; } |
| 1114 | 1106 |
| 1115 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1107 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1116 // When this is called on a batch, there is only one geometry bundle | 1108 // When this is called on a batch, there is only one geometry bundle |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse
tDy); | 1179 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse
tDy); |
| 1188 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner
RatioY - offsetDy); | 1180 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner
RatioY - offsetDy); |
| 1189 | 1181 |
| 1190 verts += kVerticesPerQuad; | 1182 verts += kVerticesPerQuad; |
| 1191 } | 1183 } |
| 1192 helper.recordDraw(target); | 1184 helper.recordDraw(target); |
| 1193 } | 1185 } |
| 1194 | 1186 |
| 1195 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1187 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 1196 | 1188 |
| 1197 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) : INHERITED(C
lassID()) { | 1189 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) { |
| 1190 this->initClassID<DIEllipseBatch>(); |
| 1198 fGeoData.push_back(geometry); | 1191 fGeoData.push_back(geometry); |
| 1199 | 1192 |
| 1200 this->setBounds(bounds); | 1193 this->setBounds(bounds); |
| 1201 } | 1194 } |
| 1202 | 1195 |
| 1203 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 1196 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 1204 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); | 1197 DIEllipseBatch* that = t->cast<DIEllipseBatch>(); |
| 1205 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 1198 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 1206 that->bounds(), caps)) { | 1199 that->bounds(), caps)) { |
| 1207 return false; | 1200 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1234 struct BatchTracker { | 1227 struct BatchTracker { |
| 1235 GrColor fColor; | 1228 GrColor fColor; |
| 1236 DIEllipseEdgeEffect::Mode fMode; | 1229 DIEllipseEdgeEffect::Mode fMode; |
| 1237 bool fUsesLocalCoords; | 1230 bool fUsesLocalCoords; |
| 1238 bool fColorIgnored; | 1231 bool fColorIgnored; |
| 1239 bool fCoverageIgnored; | 1232 bool fCoverageIgnored; |
| 1240 }; | 1233 }; |
| 1241 | 1234 |
| 1242 BatchTracker fBatch; | 1235 BatchTracker fBatch; |
| 1243 SkSTArray<1, Geometry, true> fGeoData; | 1236 SkSTArray<1, Geometry, true> fGeoData; |
| 1244 | |
| 1245 typedef GrVertexBatch INHERITED; | |
| 1246 }; | 1237 }; |
| 1247 | 1238 |
| 1248 static GrDrawBatch* create_diellipse_batch(GrColor color, | 1239 static GrDrawBatch* create_diellipse_batch(GrColor color, |
| 1249 const SkMatrix& viewMatrix, | 1240 const SkMatrix& viewMatrix, |
| 1250 bool useCoverageAA, | 1241 bool useCoverageAA, |
| 1251 const SkRect& ellipse, | 1242 const SkRect& ellipse, |
| 1252 const SkStrokeRec& stroke) { | 1243 const SkStrokeRec& stroke) { |
| 1253 SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); | 1244 SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); |
| 1254 SkScalar xRadius = SkScalarHalf(ellipse.width()); | 1245 SkScalar xRadius = SkScalarHalf(ellipse.width()); |
| 1255 SkScalar yRadius = SkScalarHalf(ellipse.height()); | 1246 SkScalar yRadius = SkScalarHalf(ellipse.height()); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); | 1434 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
| 1444 } | 1435 } |
| 1445 target->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), bounds, invert)
; | 1436 target->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), bounds, invert)
; |
| 1446 return true; | 1437 return true; |
| 1447 } | 1438 } |
| 1448 | 1439 |
| 1449 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1440 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 1450 | 1441 |
| 1451 class RRectCircleRendererBatch : public GrVertexBatch { | 1442 class RRectCircleRendererBatch : public GrVertexBatch { |
| 1452 public: | 1443 public: |
| 1453 DEFINE_BATCH_CLASS_ID | |
| 1454 | |
| 1455 struct Geometry { | 1444 struct Geometry { |
| 1445 GrColor fColor; |
| 1456 SkMatrix fViewMatrix; | 1446 SkMatrix fViewMatrix; |
| 1457 SkRect fDevBounds; | |
| 1458 SkScalar fInnerRadius; | 1447 SkScalar fInnerRadius; |
| 1459 SkScalar fOuterRadius; | 1448 SkScalar fOuterRadius; |
| 1460 GrColor fColor; | |
| 1461 bool fStroke; | 1449 bool fStroke; |
| 1450 SkRect fDevBounds; |
| 1462 }; | 1451 }; |
| 1463 | 1452 |
| 1464 static GrDrawBatch* Create(const Geometry& geometry) { | 1453 static GrDrawBatch* Create(const Geometry& geometry) { |
| 1465 return new RRectCircleRendererBatch(geometry); | 1454 return new RRectCircleRendererBatch(geometry); |
| 1466 } | 1455 } |
| 1467 | 1456 |
| 1468 const char* name() const override { return "RRectCircleBatch"; } | 1457 const char* name() const override { return "RRectCircleBatch"; } |
| 1469 | 1458 |
| 1470 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1459 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1471 // When this is called on a batch, there is only one geometry bundle | 1460 // When this is called on a batch, there is only one geometry bundle |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 verts->fInnerRadius = innerRadius; | 1556 verts->fInnerRadius = innerRadius; |
| 1568 verts++; | 1557 verts++; |
| 1569 } | 1558 } |
| 1570 } | 1559 } |
| 1571 | 1560 |
| 1572 helper.recordDraw(target); | 1561 helper.recordDraw(target); |
| 1573 } | 1562 } |
| 1574 | 1563 |
| 1575 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1564 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 1576 | 1565 |
| 1577 RRectCircleRendererBatch(const Geometry& geometry) : INHERITED(ClassID()) { | 1566 RRectCircleRendererBatch(const Geometry& geometry) { |
| 1567 this->initClassID<RRectCircleRendererBatch>(); |
| 1578 fGeoData.push_back(geometry); | 1568 fGeoData.push_back(geometry); |
| 1579 | 1569 |
| 1580 this->setBounds(geometry.fDevBounds); | 1570 this->setBounds(geometry.fDevBounds); |
| 1581 } | 1571 } |
| 1582 | 1572 |
| 1583 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 1573 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 1584 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); | 1574 RRectCircleRendererBatch* that = t->cast<RRectCircleRendererBatch>(); |
| 1585 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 1575 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 1586 that->bounds(), caps)) { | 1576 that->bounds(), caps)) { |
| 1587 return false; | 1577 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1614 struct BatchTracker { | 1604 struct BatchTracker { |
| 1615 GrColor fColor; | 1605 GrColor fColor; |
| 1616 bool fStroke; | 1606 bool fStroke; |
| 1617 bool fUsesLocalCoords; | 1607 bool fUsesLocalCoords; |
| 1618 bool fColorIgnored; | 1608 bool fColorIgnored; |
| 1619 bool fCoverageIgnored; | 1609 bool fCoverageIgnored; |
| 1620 }; | 1610 }; |
| 1621 | 1611 |
| 1622 BatchTracker fBatch; | 1612 BatchTracker fBatch; |
| 1623 SkSTArray<1, Geometry, true> fGeoData; | 1613 SkSTArray<1, Geometry, true> fGeoData; |
| 1624 | |
| 1625 typedef GrVertexBatch INHERITED; | |
| 1626 }; | 1614 }; |
| 1627 | 1615 |
| 1628 class RRectEllipseRendererBatch : public GrVertexBatch { | 1616 class RRectEllipseRendererBatch : public GrVertexBatch { |
| 1629 public: | 1617 public: |
| 1630 DEFINE_BATCH_CLASS_ID | |
| 1631 | |
| 1632 struct Geometry { | 1618 struct Geometry { |
| 1619 GrColor fColor; |
| 1633 SkMatrix fViewMatrix; | 1620 SkMatrix fViewMatrix; |
| 1634 SkRect fDevBounds; | |
| 1635 SkScalar fXRadius; | 1621 SkScalar fXRadius; |
| 1636 SkScalar fYRadius; | 1622 SkScalar fYRadius; |
| 1637 SkScalar fInnerXRadius; | 1623 SkScalar fInnerXRadius; |
| 1638 SkScalar fInnerYRadius; | 1624 SkScalar fInnerYRadius; |
| 1639 GrColor fColor; | |
| 1640 bool fStroke; | 1625 bool fStroke; |
| 1626 SkRect fDevBounds; |
| 1641 }; | 1627 }; |
| 1642 | 1628 |
| 1643 static GrDrawBatch* Create(const Geometry& geometry) { | 1629 static GrDrawBatch* Create(const Geometry& geometry) { |
| 1644 return new RRectEllipseRendererBatch(geometry); | 1630 return new RRectEllipseRendererBatch(geometry); |
| 1645 } | 1631 } |
| 1646 | 1632 |
| 1647 const char* name() const override { return "RRectEllipseRendererBatch"; } | 1633 const char* name() const override { return "RRectEllipseRendererBatch"; } |
| 1648 | 1634 |
| 1649 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1635 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1650 // 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 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 1742 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| 1757 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci
p); | 1743 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci
p); |
| 1758 verts++; | 1744 verts++; |
| 1759 } | 1745 } |
| 1760 } | 1746 } |
| 1761 helper.recordDraw(target); | 1747 helper.recordDraw(target); |
| 1762 } | 1748 } |
| 1763 | 1749 |
| 1764 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 1750 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 1765 | 1751 |
| 1766 RRectEllipseRendererBatch(const Geometry& geometry) : INHERITED(ClassID()) { | 1752 RRectEllipseRendererBatch(const Geometry& geometry) { |
| 1753 this->initClassID<RRectEllipseRendererBatch>(); |
| 1767 fGeoData.push_back(geometry); | 1754 fGeoData.push_back(geometry); |
| 1768 | 1755 |
| 1769 this->setBounds(geometry.fDevBounds); | 1756 this->setBounds(geometry.fDevBounds); |
| 1770 } | 1757 } |
| 1771 | 1758 |
| 1772 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 1759 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 1773 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); | 1760 RRectEllipseRendererBatch* that = t->cast<RRectEllipseRendererBatch>(); |
| 1774 | 1761 |
| 1775 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 1762 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 1776 that->bounds(), caps)) { | 1763 that->bounds(), caps)) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1804 struct BatchTracker { | 1791 struct BatchTracker { |
| 1805 GrColor fColor; | 1792 GrColor fColor; |
| 1806 bool fStroke; | 1793 bool fStroke; |
| 1807 bool fUsesLocalCoords; | 1794 bool fUsesLocalCoords; |
| 1808 bool fColorIgnored; | 1795 bool fColorIgnored; |
| 1809 bool fCoverageIgnored; | 1796 bool fCoverageIgnored; |
| 1810 }; | 1797 }; |
| 1811 | 1798 |
| 1812 BatchTracker fBatch; | 1799 BatchTracker fBatch; |
| 1813 SkSTArray<1, Geometry, true> fGeoData; | 1800 SkSTArray<1, Geometry, true> fGeoData; |
| 1814 | |
| 1815 typedef GrVertexBatch INHERITED; | |
| 1816 }; | 1801 }; |
| 1817 | 1802 |
| 1818 static GrDrawBatch* create_rrect_batch(GrColor color, | 1803 static GrDrawBatch* create_rrect_batch(GrColor color, |
| 1819 const SkMatrix& viewMatrix, | 1804 const SkMatrix& viewMatrix, |
| 1820 const SkRRect& rrect, | 1805 const SkRRect& rrect, |
| 1821 const SkStrokeRec& stroke) { | 1806 const SkStrokeRec& stroke) { |
| 1822 SkASSERT(viewMatrix.rectStaysRect()); | 1807 SkASSERT(viewMatrix.rectStaysRect()); |
| 1823 SkASSERT(rrect.isSimple()); | 1808 SkASSERT(rrect.isSimple()); |
| 1824 SkASSERT(!rrect.isOval()); | 1809 SkASSERT(!rrect.isOval()); |
| 1825 | 1810 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 } | 2012 } |
| 2028 | 2013 |
| 2029 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 2014 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
| 2030 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2015 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
| 2031 GrColor color = GrRandomColor(random); | 2016 GrColor color = GrRandomColor(random); |
| 2032 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2017 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
| 2033 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2018 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
| 2034 } | 2019 } |
| 2035 | 2020 |
| 2036 #endif | 2021 #endif |
| OLD | NEW |