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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 600 |
601 void onPrepareDraws(Target* target) const override { | 601 void onPrepareDraws(Target* target) const override { |
602 SkMatrix localMatrix; | 602 SkMatrix localMatrix; |
603 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { | 603 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { |
604 return; | 604 return; |
605 } | 605 } |
606 | 606 |
607 // Setup geometry processor | 607 // Setup geometry processor |
608 SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(fStroke
d, localMatrix)); | 608 SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(fStroke
d, localMatrix)); |
609 | 609 |
610 target->initDraw(gp, this->pipeline()); | 610 target->initDraw(gp, kTriangles_GrPrimitiveType); |
611 | 611 |
612 int instanceCount = fGeoData.count(); | 612 int instanceCount = fGeoData.count(); |
613 size_t vertexStride = gp->getVertexStride(); | 613 size_t vertexStride = gp->getVertexStride(); |
614 SkASSERT(vertexStride == sizeof(CircleVertex)); | 614 SkASSERT(vertexStride == sizeof(CircleVertex)); |
615 QuadHelper helper; | 615 QuadHelper helper; |
616 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target
, vertexStride, | 616 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target
, vertexStride, |
617 instan
ceCount)); | 617 instan
ceCount)); |
618 if (!verts) { | 618 if (!verts) { |
619 return; | 619 return; |
620 } | 620 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 786 |
787 void onPrepareDraws(Target* target) const override { | 787 void onPrepareDraws(Target* target) const override { |
788 SkMatrix localMatrix; | 788 SkMatrix localMatrix; |
789 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { | 789 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { |
790 return; | 790 return; |
791 } | 791 } |
792 | 792 |
793 // Setup geometry processor | 793 // Setup geometry processor |
794 SkAutoTUnref<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStrok
ed, localMatrix)); | 794 SkAutoTUnref<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStrok
ed, localMatrix)); |
795 | 795 |
796 target->initDraw(gp, this->pipeline()); | 796 target->initDraw(gp, kTriangles_GrPrimitiveType); |
797 | 797 |
798 int instanceCount = fGeoData.count(); | 798 int instanceCount = fGeoData.count(); |
799 QuadHelper helper; | 799 QuadHelper helper; |
800 size_t vertexStride = gp->getVertexStride(); | 800 size_t vertexStride = gp->getVertexStride(); |
801 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 801 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
802 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( | 802 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( |
803 helper.init(target, vertexStride, instanceCount)); | 803 helper.init(target, vertexStride, instanceCount)); |
804 if (!verts) { | 804 if (!verts) { |
805 return; | 805 return; |
806 } | 806 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 // Handle any overrides that affect our GP. | 1004 // Handle any overrides that affect our GP. |
1005 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 1005 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
1006 fUsesLocalCoords = overrides.readsLocalCoords(); | 1006 fUsesLocalCoords = overrides.readsLocalCoords(); |
1007 } | 1007 } |
1008 | 1008 |
1009 void onPrepareDraws(Target* target) const override { | 1009 void onPrepareDraws(Target* target) const override { |
1010 // Setup geometry processor | 1010 // Setup geometry processor |
1011 SkAutoTUnref<GrGeometryProcessor> gp(new DIEllipseGeometryProcessor(this
->viewMatrix(), | 1011 SkAutoTUnref<GrGeometryProcessor> gp(new DIEllipseGeometryProcessor(this
->viewMatrix(), |
1012 this
->style())); | 1012 this
->style())); |
1013 | 1013 |
1014 target->initDraw(gp, this->pipeline()); | 1014 target->initDraw(gp, kTriangles_GrPrimitiveType); |
1015 | 1015 |
1016 int instanceCount = fGeoData.count(); | 1016 int instanceCount = fGeoData.count(); |
1017 size_t vertexStride = gp->getVertexStride(); | 1017 size_t vertexStride = gp->getVertexStride(); |
1018 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); | 1018 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); |
1019 QuadHelper helper; | 1019 QuadHelper helper; |
1020 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>( | 1020 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>( |
1021 helper.init(target, vertexStride, instanceCount)); | 1021 helper.init(target, vertexStride, instanceCount)); |
1022 if (!verts) { | 1022 if (!verts) { |
1023 return; | 1023 return; |
1024 } | 1024 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 void onPrepareDraws(Target* target) const override { | 1271 void onPrepareDraws(Target* target) const override { |
1272 // Invert the view matrix as a local matrix (if any other processors req
uire coords). | 1272 // Invert the view matrix as a local matrix (if any other processors req
uire coords). |
1273 SkMatrix localMatrix; | 1273 SkMatrix localMatrix; |
1274 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { | 1274 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { |
1275 return; | 1275 return; |
1276 } | 1276 } |
1277 | 1277 |
1278 // Setup geometry processor | 1278 // Setup geometry processor |
1279 SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(fStroke
d, localMatrix)); | 1279 SkAutoTUnref<GrGeometryProcessor> gp(new CircleGeometryProcessor(fStroke
d, localMatrix)); |
1280 | 1280 |
1281 target->initDraw(gp, this->pipeline()); | 1281 target->initDraw(gp, kTriangles_GrPrimitiveType); |
1282 | 1282 |
1283 int instanceCount = fGeoData.count(); | 1283 int instanceCount = fGeoData.count(); |
1284 size_t vertexStride = gp->getVertexStride(); | 1284 size_t vertexStride = gp->getVertexStride(); |
1285 SkASSERT(vertexStride == sizeof(CircleVertex)); | 1285 SkASSERT(vertexStride == sizeof(CircleVertex)); |
1286 | 1286 |
1287 // drop out the middle quad if we're stroked | 1287 // drop out the middle quad if we're stroked |
1288 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; | 1288 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; |
1289 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 1289 SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
1290 ref_rrect_index_buffer(fStroked, target->resourceProvider())); | 1290 ref_rrect_index_buffer(fStroked, target->resourceProvider())); |
1291 | 1291 |
1292 InstancedHelper helper; | 1292 InstancedHelper helper; |
1293 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target
, | 1293 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target
, |
1294 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec
t, | 1294 vertexStride, indexBuffer, kVertsPerRRect, |
1295 indicesPerInstance, instanceCount)); | 1295 indicesPerInstance, instanceCount)); |
1296 if (!verts || !indexBuffer) { | 1296 if (!verts || !indexBuffer) { |
1297 SkDebugf("Could not allocate vertices\n"); | 1297 SkDebugf("Could not allocate vertices\n"); |
1298 return; | 1298 return; |
1299 } | 1299 } |
1300 | 1300 |
1301 for (int i = 0; i < instanceCount; i++) { | 1301 for (int i = 0; i < instanceCount; i++) { |
1302 const Geometry& args = fGeoData[i]; | 1302 const Geometry& args = fGeoData[i]; |
1303 | 1303 |
1304 GrColor color = args.fColor; | 1304 GrColor color = args.fColor; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 | 1419 |
1420 void onPrepareDraws(Target* target) const override { | 1420 void onPrepareDraws(Target* target) const override { |
1421 SkMatrix localMatrix; | 1421 SkMatrix localMatrix; |
1422 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { | 1422 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) { |
1423 return; | 1423 return; |
1424 } | 1424 } |
1425 | 1425 |
1426 // Setup geometry processor | 1426 // Setup geometry processor |
1427 SkAutoTUnref<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStrok
ed, localMatrix)); | 1427 SkAutoTUnref<GrGeometryProcessor> gp(new EllipseGeometryProcessor(fStrok
ed, localMatrix)); |
1428 | 1428 |
1429 target->initDraw(gp, this->pipeline()); | 1429 target->initDraw(gp, kTriangles_GrPrimitiveType); |
1430 | 1430 |
1431 int instanceCount = fGeoData.count(); | 1431 int instanceCount = fGeoData.count(); |
1432 size_t vertexStride = gp->getVertexStride(); | 1432 size_t vertexStride = gp->getVertexStride(); |
1433 SkASSERT(vertexStride == sizeof(EllipseVertex)); | 1433 SkASSERT(vertexStride == sizeof(EllipseVertex)); |
1434 | 1434 |
1435 // drop out the middle quad if we're stroked | 1435 // drop out the middle quad if we're stroked |
1436 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; | 1436 int indicesPerInstance = fStroked ? kIndicesPerStrokeRRect : kIndicesPer
RRect; |
1437 SkAutoTUnref<const GrIndexBuffer> indexBuffer( | 1437 SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
1438 ref_rrect_index_buffer(fStroked, target->resourceProvider())); | 1438 ref_rrect_index_buffer(fStroked, target->resourceProvider())); |
1439 | 1439 |
1440 InstancedHelper helper; | 1440 InstancedHelper helper; |
1441 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( | 1441 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( |
1442 helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexB
uffer, | 1442 helper.init(target, vertexStride, indexBuffer, |
1443 kVertsPerRRect, indicesPerInstance, instanceCount)); | 1443 kVertsPerRRect, indicesPerInstance, instanceCount)); |
1444 if (!verts || !indexBuffer) { | 1444 if (!verts || !indexBuffer) { |
1445 SkDebugf("Could not allocate vertices\n"); | 1445 SkDebugf("Could not allocate vertices\n"); |
1446 return; | 1446 return; |
1447 } | 1447 } |
1448 | 1448 |
1449 for (int i = 0; i < instanceCount; i++) { | 1449 for (int i = 0; i < instanceCount; i++) { |
1450 const Geometry& args = fGeoData[i]; | 1450 const Geometry& args = fGeoData[i]; |
1451 | 1451 |
1452 GrColor color = args.fColor; | 1452 GrColor color = args.fColor; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 } | 1724 } |
1725 | 1725 |
1726 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 1726 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
1727 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 1727 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
1728 GrColor color = GrRandomColor(random); | 1728 GrColor color = GrRandomColor(random); |
1729 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 1729 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
1730 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 1730 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
1731 } | 1731 } |
1732 | 1732 |
1733 #endif | 1733 #endif |
OLD | NEW |