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