| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 /////////////////////////////////////////////////////////////////////////////// | 685 /////////////////////////////////////////////////////////////////////////////// |
| 686 | 686 |
| 687 class CircleBatch : public GrBatch { | 687 class CircleBatch : public GrBatch { |
| 688 public: | 688 public: |
| 689 struct Geometry { | 689 struct Geometry { |
| 690 GrColor fColor; | 690 GrColor fColor; |
| 691 SkMatrix fViewMatrix; | 691 SkMatrix fViewMatrix; |
| 692 SkScalar fInnerRadius; | 692 SkScalar fInnerRadius; |
| 693 SkScalar fOuterRadius; | 693 SkScalar fOuterRadius; |
| 694 bool fStroke; | 694 bool fStroke; |
| 695 SkRect fDevBounds; | 695 SkRect fBounds; |
| 696 }; | 696 }; |
| 697 | 697 |
| 698 static GrBatch* Create(const Geometry& geometry) { | 698 static GrBatch* Create(const Geometry& geometry) { |
| 699 return SkNEW_ARGS(CircleBatch, (geometry)); | 699 return SkNEW_ARGS(CircleBatch, (geometry)); |
| 700 } | 700 } |
| 701 | 701 |
| 702 const char* name() const override { return "CircleBatch"; } | 702 const char* name() const override { return "CircleBatch"; } |
| 703 | 703 |
| 704 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 704 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 705 // When this is called on a batch, there is only one geometry bundle | 705 // When this is called on a batch, there is only one geometry bundle |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 } | 768 } |
| 769 | 769 |
| 770 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); | 770 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); |
| 771 | 771 |
| 772 for (int i = 0; i < instanceCount; i++) { | 772 for (int i = 0; i < instanceCount; i++) { |
| 773 Geometry& args = fGeoData[i]; | 773 Geometry& args = fGeoData[i]; |
| 774 | 774 |
| 775 SkScalar innerRadius = args.fInnerRadius; | 775 SkScalar innerRadius = args.fInnerRadius; |
| 776 SkScalar outerRadius = args.fOuterRadius; | 776 SkScalar outerRadius = args.fOuterRadius; |
| 777 | 777 |
| 778 const SkRect& bounds = args.fDevBounds; | 778 const SkRect& bounds = args.fBounds; |
| 779 | 779 |
| 780 // The inner radius in the vertex data must be specified in normaliz
ed space. | 780 // The inner radius in the vertex data must be specified in normaliz
ed space. |
| 781 innerRadius = innerRadius / outerRadius; | 781 innerRadius = innerRadius / outerRadius; |
| 782 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); | 782 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); |
| 783 verts[0].fOffset = SkPoint::Make(-1, -1); | 783 verts[0].fOffset = SkPoint::Make(-1, -1); |
| 784 verts[0].fOuterRadius = outerRadius; | 784 verts[0].fOuterRadius = outerRadius; |
| 785 verts[0].fInnerRadius = innerRadius; | 785 verts[0].fInnerRadius = innerRadius; |
| 786 | 786 |
| 787 verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); | 787 verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); |
| 788 verts[1].fOffset = SkPoint::Make(-1, 1); | 788 verts[1].fOffset = SkPoint::Make(-1, 1); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 center.fX + outerRadius, | 923 center.fX + outerRadius, |
| 924 center.fY + outerRadius | 924 center.fY + outerRadius |
| 925 ); | 925 ); |
| 926 | 926 |
| 927 CircleBatch::Geometry geometry; | 927 CircleBatch::Geometry geometry; |
| 928 geometry.fViewMatrix = viewMatrix; | 928 geometry.fViewMatrix = viewMatrix; |
| 929 geometry.fColor = color; | 929 geometry.fColor = color; |
| 930 geometry.fInnerRadius = innerRadius; | 930 geometry.fInnerRadius = innerRadius; |
| 931 geometry.fOuterRadius = outerRadius; | 931 geometry.fOuterRadius = outerRadius; |
| 932 geometry.fStroke = isStrokeOnly && innerRadius > 0; | 932 geometry.fStroke = isStrokeOnly && innerRadius > 0; |
| 933 geometry.fDevBounds = bounds; | 933 geometry.fBounds = bounds; |
| 934 |
| 935 viewMatrix.mapRect(&bounds); |
| 934 | 936 |
| 935 SkAutoTUnref<GrBatch> batch(CircleBatch::Create(geometry)); | 937 SkAutoTUnref<GrBatch> batch(CircleBatch::Create(geometry)); |
| 936 target->drawBatch(pipelineBuilder, batch, &bounds); | 938 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 937 } | 939 } |
| 938 | 940 |
| 939 /////////////////////////////////////////////////////////////////////////////// | 941 /////////////////////////////////////////////////////////////////////////////// |
| 940 | 942 |
| 941 class EllipseBatch : public GrBatch { | 943 class EllipseBatch : public GrBatch { |
| 942 public: | 944 public: |
| 943 struct Geometry { | 945 struct Geometry { |
| 944 GrColor fColor; | 946 GrColor fColor; |
| 945 SkMatrix fViewMatrix; | 947 SkMatrix fViewMatrix; |
| 946 SkScalar fXRadius; | 948 SkScalar fXRadius; |
| 947 SkScalar fYRadius; | 949 SkScalar fYRadius; |
| 948 SkScalar fInnerXRadius; | 950 SkScalar fInnerXRadius; |
| 949 SkScalar fInnerYRadius; | 951 SkScalar fInnerYRadius; |
| 950 bool fStroke; | 952 bool fStroke; |
| 951 SkRect fDevBounds; | 953 SkRect fBounds; |
| 952 }; | 954 }; |
| 953 | 955 |
| 954 static GrBatch* Create(const Geometry& geometry) { | 956 static GrBatch* Create(const Geometry& geometry) { |
| 955 return SkNEW_ARGS(EllipseBatch, (geometry)); | 957 return SkNEW_ARGS(EllipseBatch, (geometry)); |
| 956 } | 958 } |
| 957 | 959 |
| 958 const char* name() const override { return "EllipseBatch"; } | 960 const char* name() const override { return "EllipseBatch"; } |
| 959 | 961 |
| 960 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 962 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 961 // When this is called on a batch, there is only one geometry bundle | 963 // When this is called on a batch, there is only one geometry bundle |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 | 1031 |
| 1030 SkScalar xRadius = args.fXRadius; | 1032 SkScalar xRadius = args.fXRadius; |
| 1031 SkScalar yRadius = args.fYRadius; | 1033 SkScalar yRadius = args.fYRadius; |
| 1032 | 1034 |
| 1033 // Compute the reciprocals of the radii here to save time in the sha
der | 1035 // Compute the reciprocals of the radii here to save time in the sha
der |
| 1034 SkScalar xRadRecip = SkScalarInvert(xRadius); | 1036 SkScalar xRadRecip = SkScalarInvert(xRadius); |
| 1035 SkScalar yRadRecip = SkScalarInvert(yRadius); | 1037 SkScalar yRadRecip = SkScalarInvert(yRadius); |
| 1036 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); | 1038 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); |
| 1037 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); | 1039 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); |
| 1038 | 1040 |
| 1039 const SkRect& bounds = args.fDevBounds; | 1041 const SkRect& bounds = args.fBounds; |
| 1040 | 1042 |
| 1041 // The inner radius in the vertex data must be specified in normaliz
ed space. | 1043 // The inner radius in the vertex data must be specified in normaliz
ed space. |
| 1042 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); | 1044 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); |
| 1043 verts[0].fOffset = SkPoint::Make(-xRadius, -yRadius); | 1045 verts[0].fOffset = SkPoint::Make(-xRadius, -yRadius); |
| 1044 verts[0].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 1046 verts[0].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| 1045 verts[0].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip)
; | 1047 verts[0].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip)
; |
| 1046 | 1048 |
| 1047 verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); | 1049 verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); |
| 1048 verts[1].fOffset = SkPoint::Make(-xRadius, yRadius); | 1050 verts[1].fOffset = SkPoint::Make(-xRadius, yRadius); |
| 1049 verts[1].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); | 1051 verts[1].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 ); | 1222 ); |
| 1221 | 1223 |
| 1222 EllipseBatch::Geometry geometry; | 1224 EllipseBatch::Geometry geometry; |
| 1223 geometry.fViewMatrix = viewMatrix; | 1225 geometry.fViewMatrix = viewMatrix; |
| 1224 geometry.fColor = color; | 1226 geometry.fColor = color; |
| 1225 geometry.fXRadius = xRadius; | 1227 geometry.fXRadius = xRadius; |
| 1226 geometry.fYRadius = yRadius; | 1228 geometry.fYRadius = yRadius; |
| 1227 geometry.fInnerXRadius = innerXRadius; | 1229 geometry.fInnerXRadius = innerXRadius; |
| 1228 geometry.fInnerYRadius = innerYRadius; | 1230 geometry.fInnerYRadius = innerYRadius; |
| 1229 geometry.fStroke = isStrokeOnly && innerXRadius > 0 && innerYRadius > 0; | 1231 geometry.fStroke = isStrokeOnly && innerXRadius > 0 && innerYRadius > 0; |
| 1230 geometry.fDevBounds = bounds; | 1232 geometry.fBounds = bounds; |
| 1233 |
| 1234 viewMatrix.mapRect(&bounds); |
| 1231 | 1235 |
| 1232 SkAutoTUnref<GrBatch> batch(EllipseBatch::Create(geometry)); | 1236 SkAutoTUnref<GrBatch> batch(EllipseBatch::Create(geometry)); |
| 1233 target->drawBatch(pipelineBuilder, batch, &bounds); | 1237 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 1234 | 1238 |
| 1235 return true; | 1239 return true; |
| 1236 } | 1240 } |
| 1237 | 1241 |
| 1238 ////////////////////////////////////////////////////////////////////////////////
///////////////// | 1242 ////////////////////////////////////////////////////////////////////////////////
///////////////// |
| 1239 | 1243 |
| 1240 class DIEllipseBatch : public GrBatch { | 1244 class DIEllipseBatch : public GrBatch { |
| 1241 public: | 1245 public: |
| 1242 struct Geometry { | 1246 struct Geometry { |
| 1243 GrColor fColor; | 1247 GrColor fColor; |
| 1244 SkMatrix fViewMatrix; | 1248 SkMatrix fViewMatrix; |
| 1245 SkScalar fXRadius; | 1249 SkScalar fXRadius; |
| 1246 SkScalar fYRadius; | 1250 SkScalar fYRadius; |
| 1247 SkScalar fInnerXRadius; | 1251 SkScalar fInnerXRadius; |
| 1248 SkScalar fInnerYRadius; | 1252 SkScalar fInnerYRadius; |
| 1249 SkScalar fGeoDx; | 1253 SkScalar fGeoDx; |
| 1250 SkScalar fGeoDy; | 1254 SkScalar fGeoDy; |
| 1251 DIEllipseEdgeEffect::Mode fMode; | 1255 DIEllipseEdgeEffect::Mode fMode; |
| 1252 SkRect fDevBounds; | 1256 SkRect fBounds; |
| 1253 }; | 1257 }; |
| 1254 | 1258 |
| 1255 static GrBatch* Create(const Geometry& geometry) { | 1259 static GrBatch* Create(const Geometry& geometry) { |
| 1256 return SkNEW_ARGS(DIEllipseBatch, (geometry)); | 1260 return SkNEW_ARGS(DIEllipseBatch, (geometry)); |
| 1257 } | 1261 } |
| 1258 | 1262 |
| 1259 const char* name() const override { return "DIEllipseBatch"; } | 1263 const char* name() const override { return "DIEllipseBatch"; } |
| 1260 | 1264 |
| 1261 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1265 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1262 // When this is called on a batch, there is only one geometry bundle | 1266 // When this is called on a batch, there is only one geometry bundle |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 } | 1323 } |
| 1320 | 1324 |
| 1321 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices); | 1325 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices); |
| 1322 | 1326 |
| 1323 for (int i = 0; i < instanceCount; i++) { | 1327 for (int i = 0; i < instanceCount; i++) { |
| 1324 Geometry& args = fGeoData[i]; | 1328 Geometry& args = fGeoData[i]; |
| 1325 | 1329 |
| 1326 SkScalar xRadius = args.fXRadius; | 1330 SkScalar xRadius = args.fXRadius; |
| 1327 SkScalar yRadius = args.fYRadius; | 1331 SkScalar yRadius = args.fYRadius; |
| 1328 | 1332 |
| 1329 const SkRect& bounds = args.fDevBounds; | 1333 const SkRect& bounds = args.fBounds; |
| 1330 | 1334 |
| 1331 // This adjusts the "radius" to include the half-pixel border | 1335 // This adjusts the "radius" to include the half-pixel border |
| 1332 SkScalar offsetDx = SkScalarDiv(args.fGeoDx, xRadius); | 1336 SkScalar offsetDx = SkScalarDiv(args.fGeoDx, xRadius); |
| 1333 SkScalar offsetDy = SkScalarDiv(args.fGeoDy, yRadius); | 1337 SkScalar offsetDy = SkScalarDiv(args.fGeoDy, yRadius); |
| 1334 | 1338 |
| 1335 SkScalar innerRatioX = SkScalarDiv(xRadius, args.fInnerXRadius); | 1339 SkScalar innerRatioX = SkScalarDiv(xRadius, args.fInnerXRadius); |
| 1336 SkScalar innerRatioY = SkScalarDiv(yRadius, args.fInnerYRadius); | 1340 SkScalar innerRatioY = SkScalarDiv(yRadius, args.fInnerYRadius); |
| 1337 | 1341 |
| 1338 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); | 1342 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); |
| 1339 verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offs
etDy); | 1343 verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offs
etDy); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 DIEllipseBatch::Geometry geometry; | 1505 DIEllipseBatch::Geometry geometry; |
| 1502 geometry.fViewMatrix = viewMatrix; | 1506 geometry.fViewMatrix = viewMatrix; |
| 1503 geometry.fColor = color; | 1507 geometry.fColor = color; |
| 1504 geometry.fXRadius = xRadius; | 1508 geometry.fXRadius = xRadius; |
| 1505 geometry.fYRadius = yRadius; | 1509 geometry.fYRadius = yRadius; |
| 1506 geometry.fInnerXRadius = innerXRadius; | 1510 geometry.fInnerXRadius = innerXRadius; |
| 1507 geometry.fInnerYRadius = innerYRadius; | 1511 geometry.fInnerYRadius = innerYRadius; |
| 1508 geometry.fGeoDx = geoDx; | 1512 geometry.fGeoDx = geoDx; |
| 1509 geometry.fGeoDy = geoDy; | 1513 geometry.fGeoDy = geoDy; |
| 1510 geometry.fMode = mode; | 1514 geometry.fMode = mode; |
| 1511 geometry.fDevBounds = bounds; | 1515 geometry.fBounds = bounds; |
| 1516 |
| 1517 viewMatrix.mapRect(&bounds); |
| 1512 | 1518 |
| 1513 SkAutoTUnref<GrBatch> batch(DIEllipseBatch::Create(geometry)); | 1519 SkAutoTUnref<GrBatch> batch(DIEllipseBatch::Create(geometry)); |
| 1514 target->drawBatch(pipelineBuilder, batch, &bounds); | 1520 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 1515 | 1521 |
| 1516 return true; | 1522 return true; |
| 1517 } | 1523 } |
| 1518 | 1524 |
| 1519 /////////////////////////////////////////////////////////////////////////////// | 1525 /////////////////////////////////////////////////////////////////////////////// |
| 1520 | 1526 |
| 1521 static const uint16_t gRRectIndices[] = { | 1527 static const uint16_t gRRectIndices[] = { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1635 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 1630 | 1636 |
| 1631 class RRectCircleRendererBatch : public GrBatch { | 1637 class RRectCircleRendererBatch : public GrBatch { |
| 1632 public: | 1638 public: |
| 1633 struct Geometry { | 1639 struct Geometry { |
| 1634 GrColor fColor; | 1640 GrColor fColor; |
| 1635 SkMatrix fViewMatrix; | 1641 SkMatrix fViewMatrix; |
| 1636 SkScalar fInnerRadius; | 1642 SkScalar fInnerRadius; |
| 1637 SkScalar fOuterRadius; | 1643 SkScalar fOuterRadius; |
| 1638 bool fStroke; | 1644 bool fStroke; |
| 1639 SkRect fDevBounds; | 1645 SkRect fBounds; |
| 1640 }; | 1646 }; |
| 1641 | 1647 |
| 1642 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { | 1648 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { |
| 1643 return SkNEW_ARGS(RRectCircleRendererBatch, (geometry, indexBuffer)); | 1649 return SkNEW_ARGS(RRectCircleRendererBatch, (geometry, indexBuffer)); |
| 1644 } | 1650 } |
| 1645 | 1651 |
| 1646 const char* name() const override { return "RRectCircleBatch"; } | 1652 const char* name() const override { return "RRectCircleBatch"; } |
| 1647 | 1653 |
| 1648 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1654 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1649 // When this is called on a batch, there is only one geometry bundle | 1655 // When this is called on a batch, there is only one geometry bundle |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 return; | 1718 return; |
| 1713 } | 1719 } |
| 1714 | 1720 |
| 1715 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); | 1721 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); |
| 1716 | 1722 |
| 1717 for (int i = 0; i < instanceCount; i++) { | 1723 for (int i = 0; i < instanceCount; i++) { |
| 1718 Geometry& args = fGeoData[i]; | 1724 Geometry& args = fGeoData[i]; |
| 1719 | 1725 |
| 1720 SkScalar outerRadius = args.fOuterRadius; | 1726 SkScalar outerRadius = args.fOuterRadius; |
| 1721 | 1727 |
| 1722 const SkRect& bounds = args.fDevBounds; | 1728 const SkRect& bounds = args.fBounds; |
| 1723 | 1729 |
| 1724 SkScalar yCoords[4] = { | 1730 SkScalar yCoords[4] = { |
| 1725 bounds.fTop, | 1731 bounds.fTop, |
| 1726 bounds.fTop + outerRadius, | 1732 bounds.fTop + outerRadius, |
| 1727 bounds.fBottom - outerRadius, | 1733 bounds.fBottom - outerRadius, |
| 1728 bounds.fBottom | 1734 bounds.fBottom |
| 1729 }; | 1735 }; |
| 1730 | 1736 |
| 1731 SkScalar yOuterRadii[4] = {-1, 0, 0, 1 }; | 1737 SkScalar yOuterRadii[4] = {-1, 0, 0, 1 }; |
| 1732 // The inner radius in the vertex data must be specified in normaliz
ed space. | 1738 // The inner radius in the vertex data must be specified in normaliz
ed space. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 class RRectEllipseRendererBatch : public GrBatch { | 1844 class RRectEllipseRendererBatch : public GrBatch { |
| 1839 public: | 1845 public: |
| 1840 struct Geometry { | 1846 struct Geometry { |
| 1841 GrColor fColor; | 1847 GrColor fColor; |
| 1842 SkMatrix fViewMatrix; | 1848 SkMatrix fViewMatrix; |
| 1843 SkScalar fXRadius; | 1849 SkScalar fXRadius; |
| 1844 SkScalar fYRadius; | 1850 SkScalar fYRadius; |
| 1845 SkScalar fInnerXRadius; | 1851 SkScalar fInnerXRadius; |
| 1846 SkScalar fInnerYRadius; | 1852 SkScalar fInnerYRadius; |
| 1847 bool fStroke; | 1853 bool fStroke; |
| 1848 SkRect fDevBounds; | 1854 SkRect fBounds; |
| 1849 }; | 1855 }; |
| 1850 | 1856 |
| 1851 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { | 1857 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* indexB
uffer) { |
| 1852 return SkNEW_ARGS(RRectEllipseRendererBatch, (geometry, indexBuffer)); | 1858 return SkNEW_ARGS(RRectEllipseRendererBatch, (geometry, indexBuffer)); |
| 1853 } | 1859 } |
| 1854 | 1860 |
| 1855 const char* name() const override { return "RRectEllipseRendererBatch"; } | 1861 const char* name() const override { return "RRectEllipseRendererBatch"; } |
| 1856 | 1862 |
| 1857 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 1863 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1858 // When this is called on a batch, there is only one geometry bundle | 1864 // 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... |
| 1929 // Compute the reciprocals of the radii here to save time in the sha
der | 1935 // Compute the reciprocals of the radii here to save time in the sha
der |
| 1930 SkScalar xRadRecip = SkScalarInvert(args.fXRadius); | 1936 SkScalar xRadRecip = SkScalarInvert(args.fXRadius); |
| 1931 SkScalar yRadRecip = SkScalarInvert(args.fYRadius); | 1937 SkScalar yRadRecip = SkScalarInvert(args.fYRadius); |
| 1932 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); | 1938 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); |
| 1933 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); | 1939 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); |
| 1934 | 1940 |
| 1935 // Extend the radii out half a pixel to antialias. | 1941 // Extend the radii out half a pixel to antialias. |
| 1936 SkScalar xOuterRadius = args.fXRadius + SK_ScalarHalf; | 1942 SkScalar xOuterRadius = args.fXRadius + SK_ScalarHalf; |
| 1937 SkScalar yOuterRadius = args.fYRadius + SK_ScalarHalf; | 1943 SkScalar yOuterRadius = args.fYRadius + SK_ScalarHalf; |
| 1938 | 1944 |
| 1939 const SkRect& bounds = args.fDevBounds; | 1945 const SkRect& bounds = args.fBounds; |
| 1940 | 1946 |
| 1941 SkScalar yCoords[4] = { | 1947 SkScalar yCoords[4] = { |
| 1942 bounds.fTop, | 1948 bounds.fTop, |
| 1943 bounds.fTop + yOuterRadius, | 1949 bounds.fTop + yOuterRadius, |
| 1944 bounds.fBottom - yOuterRadius, | 1950 bounds.fBottom - yOuterRadius, |
| 1945 bounds.fBottom | 1951 bounds.fBottom |
| 1946 }; | 1952 }; |
| 1947 SkScalar yOuterOffsets[4] = { | 1953 SkScalar yOuterOffsets[4] = { |
| 1948 yOuterRadius, | 1954 yOuterRadius, |
| 1949 SK_ScalarNearlyZero, // we're using inversesqrt() in shader, so
can't be exactly 0 | 1955 SK_ScalarNearlyZero, // we're using inversesqrt() in shader, so
can't be exactly 0 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2161 | 2167 |
| 2162 // Expand the rect so all the pixels will be captured. | 2168 // Expand the rect so all the pixels will be captured. |
| 2163 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); | 2169 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
| 2164 | 2170 |
| 2165 RRectCircleRendererBatch::Geometry geometry; | 2171 RRectCircleRendererBatch::Geometry geometry; |
| 2166 geometry.fViewMatrix = viewMatrix; | 2172 geometry.fViewMatrix = viewMatrix; |
| 2167 geometry.fColor = color; | 2173 geometry.fColor = color; |
| 2168 geometry.fInnerRadius = innerRadius; | 2174 geometry.fInnerRadius = innerRadius; |
| 2169 geometry.fOuterRadius = outerRadius; | 2175 geometry.fOuterRadius = outerRadius; |
| 2170 geometry.fStroke = isStrokeOnly; | 2176 geometry.fStroke = isStrokeOnly; |
| 2171 geometry.fDevBounds = bounds; | 2177 geometry.fBounds = bounds; |
| 2178 |
| 2179 viewMatrix.mapRect(&bounds); |
| 2172 | 2180 |
| 2173 SkAutoTUnref<GrBatch> batch(RRectCircleRendererBatch::Create(geometry, i
ndexBuffer)); | 2181 SkAutoTUnref<GrBatch> batch(RRectCircleRendererBatch::Create(geometry, i
ndexBuffer)); |
| 2174 target->drawBatch(pipelineBuilder, batch, &bounds); | 2182 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 2175 | 2183 |
| 2176 // otherwise we use the ellipse renderer | 2184 // otherwise we use the ellipse renderer |
| 2177 } else { | 2185 } else { |
| 2178 SkScalar innerXRadius = 0.0f; | 2186 SkScalar innerXRadius = 0.0f; |
| 2179 SkScalar innerYRadius = 0.0f; | 2187 SkScalar innerYRadius = 0.0f; |
| 2180 if (hasStroke) { | 2188 if (hasStroke) { |
| 2181 if (SkScalarNearlyZero(scaledStroke.length())) { | 2189 if (SkScalarNearlyZero(scaledStroke.length())) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); | 2221 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
| 2214 | 2222 |
| 2215 RRectEllipseRendererBatch::Geometry geometry; | 2223 RRectEllipseRendererBatch::Geometry geometry; |
| 2216 geometry.fViewMatrix = viewMatrix; | 2224 geometry.fViewMatrix = viewMatrix; |
| 2217 geometry.fColor = color; | 2225 geometry.fColor = color; |
| 2218 geometry.fXRadius = xRadius; | 2226 geometry.fXRadius = xRadius; |
| 2219 geometry.fYRadius = yRadius; | 2227 geometry.fYRadius = yRadius; |
| 2220 geometry.fInnerXRadius = innerXRadius; | 2228 geometry.fInnerXRadius = innerXRadius; |
| 2221 geometry.fInnerYRadius = innerYRadius; | 2229 geometry.fInnerYRadius = innerYRadius; |
| 2222 geometry.fStroke = isStrokeOnly; | 2230 geometry.fStroke = isStrokeOnly; |
| 2223 geometry.fDevBounds = bounds; | 2231 geometry.fBounds = bounds; |
| 2232 |
| 2233 viewMatrix.mapRect(&bounds); |
| 2224 | 2234 |
| 2225 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2235 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
| 2226 target->drawBatch(pipelineBuilder, batch, &bounds); | 2236 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 2227 } | 2237 } |
| 2228 return true; | 2238 return true; |
| 2229 } | 2239 } |
| OLD | NEW |