| 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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 657 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 658 | 658 |
| 659 // setup batch properties | 659 // setup batch properties |
| 660 fBatch.fColorIgnored = !init.readsColor(); | 660 fBatch.fColorIgnored = !init.readsColor(); |
| 661 fBatch.fColor = fGeoData[0].fColor; | 661 fBatch.fColor = fGeoData[0].fColor; |
| 662 fBatch.fStroke = fGeoData[0].fStroke; | 662 fBatch.fStroke = fGeoData[0].fStroke; |
| 663 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 663 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
| 664 fBatch.fCoverageIgnored = !init.readsCoverage(); | 664 fBatch.fCoverageIgnored = !init.readsCoverage(); |
| 665 } | 665 } |
| 666 | 666 |
| 667 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 667 void generateGeometry(GrBatchTarget* batchTarget) override { |
| 668 SkMatrix invert; | 668 SkMatrix invert; |
| 669 if (!this->viewMatrix().invert(&invert)) { | 669 if (!this->viewMatrix().invert(&invert)) { |
| 670 return; | 670 return; |
| 671 } | 671 } |
| 672 | 672 |
| 673 // Setup geometry processor | 673 // Setup geometry processor |
| 674 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), | 674 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), |
| 675 this->stro
ke(), | 675 this->stro
ke(), |
| 676 invert, | 676 invert, |
| 677 this->uses
LocalCoords())); | 677 this->uses
LocalCoords())); |
| 678 | 678 |
| 679 batchTarget->initDraw(gp, pipeline); | 679 batchTarget->initDraw(gp, this->pipeline()); |
| 680 | 680 |
| 681 int instanceCount = fGeoData.count(); | 681 int instanceCount = fGeoData.count(); |
| 682 size_t vertexStride = gp->getVertexStride(); | 682 size_t vertexStride = gp->getVertexStride(); |
| 683 SkASSERT(vertexStride == sizeof(CircleVertex)); | 683 SkASSERT(vertexStride == sizeof(CircleVertex)); |
| 684 QuadHelper helper; | 684 QuadHelper helper; |
| 685 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(batchT
arget, vertexStride, | 685 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(batchT
arget, vertexStride, |
| 686 instan
ceCount)); | 686 instan
ceCount)); |
| 687 if (!verts) { | 687 if (!verts) { |
| 688 return; | 688 return; |
| 689 } | 689 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 875 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 876 | 876 |
| 877 // setup batch properties | 877 // setup batch properties |
| 878 fBatch.fColorIgnored = !init.readsColor(); | 878 fBatch.fColorIgnored = !init.readsColor(); |
| 879 fBatch.fColor = fGeoData[0].fColor; | 879 fBatch.fColor = fGeoData[0].fColor; |
| 880 fBatch.fStroke = fGeoData[0].fStroke; | 880 fBatch.fStroke = fGeoData[0].fStroke; |
| 881 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 881 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
| 882 fBatch.fCoverageIgnored = !init.readsCoverage(); | 882 fBatch.fCoverageIgnored = !init.readsCoverage(); |
| 883 } | 883 } |
| 884 | 884 |
| 885 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 885 void generateGeometry(GrBatchTarget* batchTarget) override { |
| 886 SkMatrix invert; | 886 SkMatrix invert; |
| 887 if (!this->viewMatrix().invert(&invert)) { | 887 if (!this->viewMatrix().invert(&invert)) { |
| 888 return; | 888 return; |
| 889 } | 889 } |
| 890 | 890 |
| 891 // Setup geometry processor | 891 // Setup geometry processor |
| 892 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 892 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
| 893 this->str
oke(), | 893 this->str
oke(), |
| 894 invert, | 894 invert, |
| 895 this->use
sLocalCoords())); | 895 this->use
sLocalCoords())); |
| 896 | 896 |
| 897 batchTarget->initDraw(gp, pipeline); | 897 batchTarget->initDraw(gp, this->pipeline()); |
| 898 | 898 |
| 899 int instanceCount = fGeoData.count(); | 899 int instanceCount = fGeoData.count(); |
| 900 QuadHelper helper; | 900 QuadHelper helper; |
| 901 size_t vertexStride = gp->getVertexStride(); | 901 size_t vertexStride = gp->getVertexStride(); |
| 902 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 902 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
| 903 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( | 903 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( |
| 904 helper.init(batchTarget, vertexStride, instanceCount)); | 904 helper.init(batchTarget, vertexStride, instanceCount)); |
| 905 if (!verts) { | 905 if (!verts) { |
| 906 return; | 906 return; |
| 907 } | 907 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 1142 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 1143 | 1143 |
| 1144 // setup batch properties | 1144 // setup batch properties |
| 1145 fBatch.fColorIgnored = !init.readsColor(); | 1145 fBatch.fColorIgnored = !init.readsColor(); |
| 1146 fBatch.fColor = fGeoData[0].fColor; | 1146 fBatch.fColor = fGeoData[0].fColor; |
| 1147 fBatch.fMode = fGeoData[0].fMode; | 1147 fBatch.fMode = fGeoData[0].fMode; |
| 1148 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 1148 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
| 1149 fBatch.fCoverageIgnored = !init.readsCoverage(); | 1149 fBatch.fCoverageIgnored = !init.readsCoverage(); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1152 void generateGeometry(GrBatchTarget* batchTarget) override { |
| 1153 // Setup geometry processor | 1153 // Setup geometry processor |
| 1154 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), | 1154 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c
olor(), |
| 1155 this->v
iewMatrix(), | 1155 this->v
iewMatrix(), |
| 1156 this->m
ode(), | 1156 this->m
ode(), |
| 1157 this->u
sesLocalCoords())); | 1157 this->u
sesLocalCoords())); |
| 1158 | 1158 |
| 1159 batchTarget->initDraw(gp, pipeline); | 1159 batchTarget->initDraw(gp, this->pipeline()); |
| 1160 | 1160 |
| 1161 int instanceCount = fGeoData.count(); | 1161 int instanceCount = fGeoData.count(); |
| 1162 size_t vertexStride = gp->getVertexStride(); | 1162 size_t vertexStride = gp->getVertexStride(); |
| 1163 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); | 1163 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); |
| 1164 QuadHelper helper; | 1164 QuadHelper helper; |
| 1165 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>( | 1165 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>( |
| 1166 helper.init(batchTarget, vertexStride, instanceCount)); | 1166 helper.init(batchTarget, vertexStride, instanceCount)); |
| 1167 if (!verts) { | 1167 if (!verts) { |
| 1168 return; | 1168 return; |
| 1169 } | 1169 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 1493 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 1494 | 1494 |
| 1495 // setup batch properties | 1495 // setup batch properties |
| 1496 fBatch.fColorIgnored = !init.readsColor(); | 1496 fBatch.fColorIgnored = !init.readsColor(); |
| 1497 fBatch.fColor = fGeoData[0].fColor; | 1497 fBatch.fColor = fGeoData[0].fColor; |
| 1498 fBatch.fStroke = fGeoData[0].fStroke; | 1498 fBatch.fStroke = fGeoData[0].fStroke; |
| 1499 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 1499 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
| 1500 fBatch.fCoverageIgnored = !init.readsCoverage(); | 1500 fBatch.fCoverageIgnored = !init.readsCoverage(); |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1503 void generateGeometry(GrBatchTarget* batchTarget) override { |
| 1504 // reset to device coordinates | 1504 // reset to device coordinates |
| 1505 SkMatrix invert; | 1505 SkMatrix invert; |
| 1506 if (!this->viewMatrix().invert(&invert)) { | 1506 if (!this->viewMatrix().invert(&invert)) { |
| 1507 SkDebugf("Failed to invert\n"); | 1507 SkDebugf("Failed to invert\n"); |
| 1508 return; | 1508 return; |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 // Setup geometry processor | 1511 // Setup geometry processor |
| 1512 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), | 1512 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo
r(), |
| 1513 this->stro
ke(), | 1513 this->stro
ke(), |
| 1514 invert, | 1514 invert, |
| 1515 this->uses
LocalCoords())); | 1515 this->uses
LocalCoords())); |
| 1516 | 1516 |
| 1517 batchTarget->initDraw(gp, pipeline); | 1517 batchTarget->initDraw(gp, this->pipeline()); |
| 1518 | 1518 |
| 1519 int instanceCount = fGeoData.count(); | 1519 int instanceCount = fGeoData.count(); |
| 1520 size_t vertexStride = gp->getVertexStride(); | 1520 size_t vertexStride = gp->getVertexStride(); |
| 1521 SkASSERT(vertexStride == sizeof(CircleVertex)); | 1521 SkASSERT(vertexStride == sizeof(CircleVertex)); |
| 1522 | 1522 |
| 1523 // drop out the middle quad if we're stroked | 1523 // drop out the middle quad if we're stroked |
| 1524 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi
cesPerRRect; | 1524 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi
cesPerRRect; |
| 1525 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 1525 SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
| 1526 ref_rrect_index_buffer(this->stroke(), batchTarget->resourceProvider
())); | 1526 ref_rrect_index_buffer(this->stroke(), batchTarget->resourceProvider
())); |
| 1527 | 1527 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 init.getOverrideColorIfSet(&fGeoData[0].fColor); | 1669 init.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 1670 | 1670 |
| 1671 // setup batch properties | 1671 // setup batch properties |
| 1672 fBatch.fColorIgnored = !init.readsColor(); | 1672 fBatch.fColorIgnored = !init.readsColor(); |
| 1673 fBatch.fColor = fGeoData[0].fColor; | 1673 fBatch.fColor = fGeoData[0].fColor; |
| 1674 fBatch.fStroke = fGeoData[0].fStroke; | 1674 fBatch.fStroke = fGeoData[0].fStroke; |
| 1675 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 1675 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
| 1676 fBatch.fCoverageIgnored = !init.readsCoverage(); | 1676 fBatch.fCoverageIgnored = !init.readsCoverage(); |
| 1677 } | 1677 } |
| 1678 | 1678 |
| 1679 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline
) override { | 1679 void generateGeometry(GrBatchTarget* batchTarget) override { |
| 1680 // reset to device coordinates | 1680 // reset to device coordinates |
| 1681 SkMatrix invert; | 1681 SkMatrix invert; |
| 1682 if (!this->viewMatrix().invert(&invert)) { | 1682 if (!this->viewMatrix().invert(&invert)) { |
| 1683 SkDebugf("Failed to invert\n"); | 1683 SkDebugf("Failed to invert\n"); |
| 1684 return; | 1684 return; |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 // Setup geometry processor | 1687 // Setup geometry processor |
| 1688 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), | 1688 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col
or(), |
| 1689 this->str
oke(), | 1689 this->str
oke(), |
| 1690 invert, | 1690 invert, |
| 1691 this->use
sLocalCoords())); | 1691 this->use
sLocalCoords())); |
| 1692 | 1692 |
| 1693 batchTarget->initDraw(gp, pipeline); | 1693 batchTarget->initDraw(gp, this->pipeline()); |
| 1694 | 1694 |
| 1695 int instanceCount = fGeoData.count(); | 1695 int instanceCount = fGeoData.count(); |
| 1696 size_t vertexStride = gp->getVertexStride(); | 1696 size_t vertexStride = gp->getVertexStride(); |
| 1697 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 1697 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
| 1698 | 1698 |
| 1699 // drop out the middle quad if we're stroked | 1699 // drop out the middle quad if we're stroked |
| 1700 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi
cesPerRRect; | 1700 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi
cesPerRRect; |
| 1701 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 1701 SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
| 1702 ref_rrect_index_buffer(this->stroke(), batchTarget->resourceProvider
())); | 1702 ref_rrect_index_buffer(this->stroke(), batchTarget->resourceProvider
())); |
| 1703 | 1703 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 BATCH_TEST_DEFINE(RRectBatch) { | 2034 BATCH_TEST_DEFINE(RRectBatch) { |
| 2035 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 2035 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
| 2036 GrColor color = GrRandomColor(random); | 2036 GrColor color = GrRandomColor(random); |
| 2037 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 2037 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
| 2038 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 2038 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
| 2039 } | 2039 } |
| 2040 | 2040 |
| 2041 #endif | 2041 #endif |
| OLD | NEW |