| 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 SkASSERT(vertexStride == sizeof(CircleVertex)); | 755 SkASSERT(vertexStride == sizeof(CircleVertex)); |
| 756 | 756 |
| 757 const GrVertexBuffer* vertexBuffer; | 757 const GrVertexBuffer* vertexBuffer; |
| 758 int firstVertex; | 758 int firstVertex; |
| 759 | 759 |
| 760 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 760 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 761 vertexCount, | 761 vertexCount, |
| 762 &vertexBuffer, | 762 &vertexBuffer, |
| 763 &firstVertex); | 763 &firstVertex); |
| 764 | 764 |
| 765 if (!vertices || !batchTarget->quadIndexBuffer()) { |
| 766 SkDebugf("Could not allocate buffers\n"); |
| 767 return; |
| 768 } |
| 769 |
| 765 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); | 770 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); |
| 766 | 771 |
| 767 for (int i = 0; i < instanceCount; i++) { | 772 for (int i = 0; i < instanceCount; i++) { |
| 768 Geometry& args = fGeoData[i]; | 773 Geometry& args = fGeoData[i]; |
| 769 | 774 |
| 770 SkScalar innerRadius = args.fInnerRadius; | 775 SkScalar innerRadius = args.fInnerRadius; |
| 771 SkScalar outerRadius = args.fOuterRadius; | 776 SkScalar outerRadius = args.fOuterRadius; |
| 772 | 777 |
| 773 const SkRect& bounds = args.fDevBounds; | 778 const SkRect& bounds = args.fDevBounds; |
| 774 | 779 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 1010 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
| 1006 | 1011 |
| 1007 const GrVertexBuffer* vertexBuffer; | 1012 const GrVertexBuffer* vertexBuffer; |
| 1008 int firstVertex; | 1013 int firstVertex; |
| 1009 | 1014 |
| 1010 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 1015 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 1011 vertexCount, | 1016 vertexCount, |
| 1012 &vertexBuffer, | 1017 &vertexBuffer, |
| 1013 &firstVertex); | 1018 &firstVertex); |
| 1014 | 1019 |
| 1020 if (!vertices || !batchTarget->quadIndexBuffer()) { |
| 1021 SkDebugf("Could not allocate buffers\n"); |
| 1022 return; |
| 1023 } |
| 1024 |
| 1015 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices); | 1025 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices); |
| 1016 | 1026 |
| 1017 for (int i = 0; i < instanceCount; i++) { | 1027 for (int i = 0; i < instanceCount; i++) { |
| 1018 Geometry& args = fGeoData[i]; | 1028 Geometry& args = fGeoData[i]; |
| 1019 | 1029 |
| 1020 SkScalar xRadius = args.fXRadius; | 1030 SkScalar xRadius = args.fXRadius; |
| 1021 SkScalar yRadius = args.fYRadius; | 1031 SkScalar yRadius = args.fYRadius; |
| 1022 | 1032 |
| 1023 // Compute the reciprocals of the radii here to save time in the sha
der | 1033 // Compute the reciprocals of the radii here to save time in the sha
der |
| 1024 SkScalar xRadRecip = SkScalarInvert(xRadius); | 1034 SkScalar xRadRecip = SkScalarInvert(xRadius); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); | 1306 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); |
| 1297 | 1307 |
| 1298 const GrVertexBuffer* vertexBuffer; | 1308 const GrVertexBuffer* vertexBuffer; |
| 1299 int firstVertex; | 1309 int firstVertex; |
| 1300 | 1310 |
| 1301 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 1311 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 1302 vertexCount, | 1312 vertexCount, |
| 1303 &vertexBuffer, | 1313 &vertexBuffer, |
| 1304 &firstVertex); | 1314 &firstVertex); |
| 1305 | 1315 |
| 1316 if (!vertices || !batchTarget->quadIndexBuffer()) { |
| 1317 SkDebugf("Could not allocate buffers\n"); |
| 1318 return; |
| 1319 } |
| 1320 |
| 1306 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices); | 1321 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices); |
| 1307 | 1322 |
| 1308 for (int i = 0; i < instanceCount; i++) { | 1323 for (int i = 0; i < instanceCount; i++) { |
| 1309 Geometry& args = fGeoData[i]; | 1324 Geometry& args = fGeoData[i]; |
| 1310 | 1325 |
| 1311 SkScalar xRadius = args.fXRadius; | 1326 SkScalar xRadius = args.fXRadius; |
| 1312 SkScalar yRadius = args.fYRadius; | 1327 SkScalar yRadius = args.fYRadius; |
| 1313 | 1328 |
| 1314 const SkRect& bounds = args.fDevBounds; | 1329 const SkRect& bounds = args.fDevBounds; |
| 1315 | 1330 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 SkASSERT(vertexStride == sizeof(CircleVertex)); | 1700 SkASSERT(vertexStride == sizeof(CircleVertex)); |
| 1686 | 1701 |
| 1687 const GrVertexBuffer* vertexBuffer; | 1702 const GrVertexBuffer* vertexBuffer; |
| 1688 int firstVertex; | 1703 int firstVertex; |
| 1689 | 1704 |
| 1690 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 1705 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 1691 vertexCount, | 1706 vertexCount, |
| 1692 &vertexBuffer, | 1707 &vertexBuffer, |
| 1693 &firstVertex); | 1708 &firstVertex); |
| 1694 | 1709 |
| 1710 if (!vertices) { |
| 1711 SkDebugf("Could not allocate vertices\n"); |
| 1712 return; |
| 1713 } |
| 1714 |
| 1695 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); | 1715 CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices); |
| 1696 | 1716 |
| 1697 for (int i = 0; i < instanceCount; i++) { | 1717 for (int i = 0; i < instanceCount; i++) { |
| 1698 Geometry& args = fGeoData[i]; | 1718 Geometry& args = fGeoData[i]; |
| 1699 | 1719 |
| 1700 SkScalar outerRadius = args.fOuterRadius; | 1720 SkScalar outerRadius = args.fOuterRadius; |
| 1701 | 1721 |
| 1702 const SkRect& bounds = args.fDevBounds; | 1722 const SkRect& bounds = args.fDevBounds; |
| 1703 | 1723 |
| 1704 SkScalar yCoords[4] = { | 1724 SkScalar yCoords[4] = { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 1909 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
| 1890 | 1910 |
| 1891 const GrVertexBuffer* vertexBuffer; | 1911 const GrVertexBuffer* vertexBuffer; |
| 1892 int firstVertex; | 1912 int firstVertex; |
| 1893 | 1913 |
| 1894 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 1914 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 1895 vertexCount, | 1915 vertexCount, |
| 1896 &vertexBuffer, | 1916 &vertexBuffer, |
| 1897 &firstVertex); | 1917 &firstVertex); |
| 1898 | 1918 |
| 1919 if (!vertices) { |
| 1920 SkDebugf("Could not allocate vertices\n"); |
| 1921 return; |
| 1922 } |
| 1923 |
| 1899 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices); | 1924 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices); |
| 1900 | 1925 |
| 1901 for (int i = 0; i < instanceCount; i++) { | 1926 for (int i = 0; i < instanceCount; i++) { |
| 1902 Geometry& args = fGeoData[i]; | 1927 Geometry& args = fGeoData[i]; |
| 1903 | 1928 |
| 1904 // Compute the reciprocals of the radii here to save time in the sha
der | 1929 // Compute the reciprocals of the radii here to save time in the sha
der |
| 1905 SkScalar xRadRecip = SkScalarInvert(args.fXRadius); | 1930 SkScalar xRadRecip = SkScalarInvert(args.fXRadius); |
| 1906 SkScalar yRadRecip = SkScalarInvert(args.fYRadius); | 1931 SkScalar yRadRecip = SkScalarInvert(args.fYRadius); |
| 1907 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); | 1932 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); |
| 1908 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); | 1933 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 geometry.fInnerXRadius = innerXRadius; | 2220 geometry.fInnerXRadius = innerXRadius; |
| 2196 geometry.fInnerYRadius = innerYRadius; | 2221 geometry.fInnerYRadius = innerYRadius; |
| 2197 geometry.fStroke = isStrokeOnly; | 2222 geometry.fStroke = isStrokeOnly; |
| 2198 geometry.fDevBounds = bounds; | 2223 geometry.fDevBounds = bounds; |
| 2199 | 2224 |
| 2200 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2225 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
| 2201 target->drawBatch(pipelineBuilder, batch, &bounds); | 2226 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 2202 } | 2227 } |
| 2203 return true; | 2228 return true; |
| 2204 } | 2229 } |
| OLD | NEW |