Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: src/gpu/GrOvalRenderer.cpp

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrInOrderCommandBuilder.cpp ('k') | src/gpu/GrReorderCommandBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrBatchTarget.h" 10 #include "GrBatchFlushState.h"
11 #include "GrBatchTest.h" 11 #include "GrBatchTest.h"
12 #include "GrDrawTarget.h" 12 #include "GrDrawTarget.h"
13 #include "GrGeometryProcessor.h" 13 #include "GrGeometryProcessor.h"
14 #include "GrInvariantOutput.h" 14 #include "GrInvariantOutput.h"
15 #include "GrPipelineBuilder.h" 15 #include "GrPipelineBuilder.h"
16 #include "GrProcessor.h" 16 #include "GrProcessor.h"
17 #include "GrResourceProvider.h" 17 #include "GrResourceProvider.h"
18 #include "GrVertexBuffer.h" 18 #include "GrVertexBuffer.h"
19 #include "SkRRect.h" 19 #include "SkRRect.h"
20 #include "SkStrokeRec.h" 20 #include "SkStrokeRec.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 659 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
660 660
661 // setup batch properties 661 // setup batch properties
662 fBatch.fColorIgnored = !opt.readsColor(); 662 fBatch.fColorIgnored = !opt.readsColor();
663 fBatch.fColor = fGeoData[0].fColor; 663 fBatch.fColor = fGeoData[0].fColor;
664 fBatch.fStroke = fGeoData[0].fStroke; 664 fBatch.fStroke = fGeoData[0].fStroke;
665 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 665 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
666 fBatch.fCoverageIgnored = !opt.readsCoverage(); 666 fBatch.fCoverageIgnored = !opt.readsCoverage();
667 } 667 }
668 668
669 void generateGeometry(GrBatchTarget* batchTarget) override { 669 void onPrepareDraws(Target* target) override {
670 SkMatrix invert; 670 SkMatrix invert;
671 if (!this->viewMatrix().invert(&invert)) { 671 if (!this->viewMatrix().invert(&invert)) {
672 return; 672 return;
673 } 673 }
674 674
675 // Setup geometry processor 675 // Setup geometry processor
676 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(), 676 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(),
677 this->stro ke(), 677 this->stro ke(),
678 invert, 678 invert,
679 this->uses LocalCoords())); 679 this->uses LocalCoords()));
680 680
681 batchTarget->initDraw(gp, this->pipeline()); 681 target->initDraw(gp, this->pipeline());
682 682
683 int instanceCount = fGeoData.count(); 683 int instanceCount = fGeoData.count();
684 size_t vertexStride = gp->getVertexStride(); 684 size_t vertexStride = gp->getVertexStride();
685 SkASSERT(vertexStride == sizeof(CircleVertex)); 685 SkASSERT(vertexStride == sizeof(CircleVertex));
686 QuadHelper helper; 686 QuadHelper helper;
687 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(batchT arget, vertexStride, 687 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target , vertexStride,
688 instan ceCount)); 688 instan ceCount));
689 if (!verts) { 689 if (!verts) {
690 return; 690 return;
691 } 691 }
692 692
693 for (int i = 0; i < instanceCount; i++) { 693 for (int i = 0; i < instanceCount; i++) {
694 Geometry& geom = fGeoData[i]; 694 Geometry& geom = fGeoData[i];
695 695
696 SkScalar innerRadius = geom.fInnerRadius; 696 SkScalar innerRadius = geom.fInnerRadius;
697 SkScalar outerRadius = geom.fOuterRadius; 697 SkScalar outerRadius = geom.fOuterRadius;
(...skipping 17 matching lines...) Expand all
715 verts[2].fOuterRadius = outerRadius; 715 verts[2].fOuterRadius = outerRadius;
716 verts[2].fInnerRadius = innerRadius; 716 verts[2].fInnerRadius = innerRadius;
717 717
718 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 718 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
719 verts[3].fOffset = SkPoint::Make(1, -1); 719 verts[3].fOffset = SkPoint::Make(1, -1);
720 verts[3].fOuterRadius = outerRadius; 720 verts[3].fOuterRadius = outerRadius;
721 verts[3].fInnerRadius = innerRadius; 721 verts[3].fInnerRadius = innerRadius;
722 722
723 verts += kVerticesPerQuad; 723 verts += kVerticesPerQuad;
724 } 724 }
725 helper.issueDraw(batchTarget); 725 helper.recordDraw(target);
726 } 726 }
727 727
728 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 728 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
729 729
730 private: 730 private:
731 CircleBatch(const Geometry& geometry) { 731 CircleBatch(const Geometry& geometry) {
732 this->initClassID<CircleBatch>(); 732 this->initClassID<CircleBatch>();
733 fGeoData.push_back(geometry); 733 fGeoData.push_back(geometry);
734 734
735 this->setBounds(geometry.fDevBounds); 735 this->setBounds(geometry.fDevBounds);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 877 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
878 878
879 // setup batch properties 879 // setup batch properties
880 fBatch.fColorIgnored = !opt.readsColor(); 880 fBatch.fColorIgnored = !opt.readsColor();
881 fBatch.fColor = fGeoData[0].fColor; 881 fBatch.fColor = fGeoData[0].fColor;
882 fBatch.fStroke = fGeoData[0].fStroke; 882 fBatch.fStroke = fGeoData[0].fStroke;
883 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 883 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
884 fBatch.fCoverageIgnored = !opt.readsCoverage(); 884 fBatch.fCoverageIgnored = !opt.readsCoverage();
885 } 885 }
886 886
887 void generateGeometry(GrBatchTarget* batchTarget) override { 887 void onPrepareDraws(Target* target) override {
888 SkMatrix invert; 888 SkMatrix invert;
889 if (!this->viewMatrix().invert(&invert)) { 889 if (!this->viewMatrix().invert(&invert)) {
890 return; 890 return;
891 } 891 }
892 892
893 // Setup geometry processor 893 // Setup geometry processor
894 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(), 894 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(),
895 this->str oke(), 895 this->str oke(),
896 invert, 896 invert,
897 this->use sLocalCoords())); 897 this->use sLocalCoords()));
898 898
899 batchTarget->initDraw(gp, this->pipeline()); 899 target->initDraw(gp, this->pipeline());
900 900
901 int instanceCount = fGeoData.count(); 901 int instanceCount = fGeoData.count();
902 QuadHelper helper; 902 QuadHelper helper;
903 size_t vertexStride = gp->getVertexStride(); 903 size_t vertexStride = gp->getVertexStride();
904 SkASSERT(vertexStride == sizeof(EllipseVertex)); 904 SkASSERT(vertexStride == sizeof(EllipseVertex));
905 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( 905 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(
906 helper.init(batchTarget, vertexStride, instanceCount)); 906 helper.init(target, vertexStride, instanceCount));
907 if (!verts) { 907 if (!verts) {
908 return; 908 return;
909 } 909 }
910 910
911 for (int i = 0; i < instanceCount; i++) { 911 for (int i = 0; i < instanceCount; i++) {
912 Geometry& geom = fGeoData[i]; 912 Geometry& geom = fGeoData[i];
913 913
914 SkScalar xRadius = geom.fXRadius; 914 SkScalar xRadius = geom.fXRadius;
915 SkScalar yRadius = geom.fYRadius; 915 SkScalar yRadius = geom.fYRadius;
916 916
(...skipping 21 matching lines...) Expand all
938 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 938 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
939 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip) ; 939 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip) ;
940 940
941 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 941 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
942 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius); 942 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius);
943 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 943 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
944 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip) ; 944 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip) ;
945 945
946 verts += kVerticesPerQuad; 946 verts += kVerticesPerQuad;
947 } 947 }
948 helper.issueDraw(batchTarget); 948 helper.recordDraw(target);
949 } 949 }
950 950
951 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 951 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
952 952
953 private: 953 private:
954 EllipseBatch(const Geometry& geometry) { 954 EllipseBatch(const Geometry& geometry) {
955 this->initClassID<EllipseBatch>(); 955 this->initClassID<EllipseBatch>();
956 fGeoData.push_back(geometry); 956 fGeoData.push_back(geometry);
957 957
958 this->setBounds(geometry.fDevBounds); 958 this->setBounds(geometry.fDevBounds);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 1145 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
1146 1146
1147 // setup batch properties 1147 // setup batch properties
1148 fBatch.fColorIgnored = !opt.readsColor(); 1148 fBatch.fColorIgnored = !opt.readsColor();
1149 fBatch.fColor = fGeoData[0].fColor; 1149 fBatch.fColor = fGeoData[0].fColor;
1150 fBatch.fMode = fGeoData[0].fMode; 1150 fBatch.fMode = fGeoData[0].fMode;
1151 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 1151 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
1152 fBatch.fCoverageIgnored = !opt.readsCoverage(); 1152 fBatch.fCoverageIgnored = !opt.readsCoverage();
1153 } 1153 }
1154 1154
1155 void generateGeometry(GrBatchTarget* batchTarget) override { 1155 void onPrepareDraws(Target* target) override {
1156 // Setup geometry processor 1156 // Setup geometry processor
1157 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c olor(), 1157 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c olor(),
1158 this->v iewMatrix(), 1158 this->v iewMatrix(),
1159 this->m ode(), 1159 this->m ode(),
1160 this->u sesLocalCoords())); 1160 this->u sesLocalCoords()));
1161 1161
1162 batchTarget->initDraw(gp, this->pipeline()); 1162 target->initDraw(gp, this->pipeline());
1163 1163
1164 int instanceCount = fGeoData.count(); 1164 int instanceCount = fGeoData.count();
1165 size_t vertexStride = gp->getVertexStride(); 1165 size_t vertexStride = gp->getVertexStride();
1166 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); 1166 SkASSERT(vertexStride == sizeof(DIEllipseVertex));
1167 QuadHelper helper; 1167 QuadHelper helper;
1168 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>( 1168 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(
1169 helper.init(batchTarget, vertexStride, instanceCount)); 1169 helper.init(target, vertexStride, instanceCount));
1170 if (!verts) { 1170 if (!verts) {
1171 return; 1171 return;
1172 } 1172 }
1173 1173
1174 for (int i = 0; i < instanceCount; i++) { 1174 for (int i = 0; i < instanceCount; i++) {
1175 Geometry& geom = fGeoData[i]; 1175 Geometry& geom = fGeoData[i];
1176 1176
1177 SkScalar xRadius = geom.fXRadius; 1177 SkScalar xRadius = geom.fXRadius;
1178 SkScalar yRadius = geom.fYRadius; 1178 SkScalar yRadius = geom.fYRadius;
1179 1179
(...skipping 17 matching lines...) Expand all
1197 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 1197 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
1198 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offset Dy); 1198 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offset Dy);
1199 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerR atioY + offsetDy); 1199 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerR atioY + offsetDy);
1200 1200
1201 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 1201 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
1202 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse tDy); 1202 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offse tDy);
1203 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner RatioY - offsetDy); 1203 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -inner RatioY - offsetDy);
1204 1204
1205 verts += kVerticesPerQuad; 1205 verts += kVerticesPerQuad;
1206 } 1206 }
1207 helper.issueDraw(batchTarget); 1207 helper.recordDraw(target);
1208 } 1208 }
1209 1209
1210 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 1210 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
1211 1211
1212 private: 1212 private:
1213 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) { 1213 DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) {
1214 this->initClassID<DIEllipseBatch>(); 1214 this->initClassID<DIEllipseBatch>();
1215 fGeoData.push_back(geometry); 1215 fGeoData.push_back(geometry);
1216 1216
1217 this->setBounds(bounds); 1217 this->setBounds(bounds);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 1496 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
1497 1497
1498 // setup batch properties 1498 // setup batch properties
1499 fBatch.fColorIgnored = !opt.readsColor(); 1499 fBatch.fColorIgnored = !opt.readsColor();
1500 fBatch.fColor = fGeoData[0].fColor; 1500 fBatch.fColor = fGeoData[0].fColor;
1501 fBatch.fStroke = fGeoData[0].fStroke; 1501 fBatch.fStroke = fGeoData[0].fStroke;
1502 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 1502 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
1503 fBatch.fCoverageIgnored = !opt.readsCoverage(); 1503 fBatch.fCoverageIgnored = !opt.readsCoverage();
1504 } 1504 }
1505 1505
1506 void generateGeometry(GrBatchTarget* batchTarget) override { 1506 void onPrepareDraws(Target* target) override {
1507 // reset to device coordinates 1507 // reset to device coordinates
1508 SkMatrix invert; 1508 SkMatrix invert;
1509 if (!this->viewMatrix().invert(&invert)) { 1509 if (!this->viewMatrix().invert(&invert)) {
1510 SkDebugf("Failed to invert\n"); 1510 SkDebugf("Failed to invert\n");
1511 return; 1511 return;
1512 } 1512 }
1513 1513
1514 // Setup geometry processor 1514 // Setup geometry processor
1515 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(), 1515 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(),
1516 this->stro ke(), 1516 this->stro ke(),
1517 invert, 1517 invert,
1518 this->uses LocalCoords())); 1518 this->uses LocalCoords()));
1519 1519
1520 batchTarget->initDraw(gp, this->pipeline()); 1520 target->initDraw(gp, this->pipeline());
1521 1521
1522 int instanceCount = fGeoData.count(); 1522 int instanceCount = fGeoData.count();
1523 size_t vertexStride = gp->getVertexStride(); 1523 size_t vertexStride = gp->getVertexStride();
1524 SkASSERT(vertexStride == sizeof(CircleVertex)); 1524 SkASSERT(vertexStride == sizeof(CircleVertex));
1525 1525
1526 // drop out the middle quad if we're stroked 1526 // drop out the middle quad if we're stroked
1527 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi cesPerRRect; 1527 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi cesPerRRect;
1528 SkAutoTUnref<const GrIndexBuffer> indexBuffer( 1528 SkAutoTUnref<const GrIndexBuffer> indexBuffer(
1529 ref_rrect_index_buffer(this->stroke(), batchTarget->resourceProvider ())); 1529 ref_rrect_index_buffer(this->stroke(), target->resourceProvider()));
1530 1530
1531 InstancedHelper helper; 1531 InstancedHelper helper;
1532 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(batchT arget, 1532 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target ,
1533 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec t, 1533 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec t,
1534 indicesPerInstance, instanceCount)); 1534 indicesPerInstance, instanceCount));
1535 if (!verts || !indexBuffer) { 1535 if (!verts || !indexBuffer) {
1536 SkDebugf("Could not allocate vertices\n"); 1536 SkDebugf("Could not allocate vertices\n");
1537 return; 1537 return;
1538 } 1538 }
1539 1539
1540 for (int i = 0; i < instanceCount; i++) { 1540 for (int i = 0; i < instanceCount; i++) {
1541 Geometry& args = fGeoData[i]; 1541 Geometry& args = fGeoData[i];
1542 1542
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 verts++; 1574 verts++;
1575 1575
1576 verts->fPos = SkPoint::Make(bounds.fRight, yCoords[i]); 1576 verts->fPos = SkPoint::Make(bounds.fRight, yCoords[i]);
1577 verts->fOffset = SkPoint::Make(1, yOuterRadii[i]); 1577 verts->fOffset = SkPoint::Make(1, yOuterRadii[i]);
1578 verts->fOuterRadius = outerRadius; 1578 verts->fOuterRadius = outerRadius;
1579 verts->fInnerRadius = innerRadius; 1579 verts->fInnerRadius = innerRadius;
1580 verts++; 1580 verts++;
1581 } 1581 }
1582 } 1582 }
1583 1583
1584 helper.issueDraw(batchTarget); 1584 helper.recordDraw(target);
1585 } 1585 }
1586 1586
1587 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 1587 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
1588 1588
1589 private: 1589 private:
1590 RRectCircleRendererBatch(const Geometry& geometry) { 1590 RRectCircleRendererBatch(const Geometry& geometry) {
1591 this->initClassID<RRectCircleRendererBatch>(); 1591 this->initClassID<RRectCircleRendererBatch>();
1592 fGeoData.push_back(geometry); 1592 fGeoData.push_back(geometry);
1593 1593
1594 this->setBounds(geometry.fDevBounds); 1594 this->setBounds(geometry.fDevBounds);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 opt.getOverrideColorIfSet(&fGeoData[0].fColor); 1672 opt.getOverrideColorIfSet(&fGeoData[0].fColor);
1673 1673
1674 // setup batch properties 1674 // setup batch properties
1675 fBatch.fColorIgnored = !opt.readsColor(); 1675 fBatch.fColorIgnored = !opt.readsColor();
1676 fBatch.fColor = fGeoData[0].fColor; 1676 fBatch.fColor = fGeoData[0].fColor;
1677 fBatch.fStroke = fGeoData[0].fStroke; 1677 fBatch.fStroke = fGeoData[0].fStroke;
1678 fBatch.fUsesLocalCoords = opt.readsLocalCoords(); 1678 fBatch.fUsesLocalCoords = opt.readsLocalCoords();
1679 fBatch.fCoverageIgnored = !opt.readsCoverage(); 1679 fBatch.fCoverageIgnored = !opt.readsCoverage();
1680 } 1680 }
1681 1681
1682 void generateGeometry(GrBatchTarget* batchTarget) override { 1682 void onPrepareDraws(Target* target) override {
1683 // reset to device coordinates 1683 // reset to device coordinates
1684 SkMatrix invert; 1684 SkMatrix invert;
1685 if (!this->viewMatrix().invert(&invert)) { 1685 if (!this->viewMatrix().invert(&invert)) {
1686 SkDebugf("Failed to invert\n"); 1686 SkDebugf("Failed to invert\n");
1687 return; 1687 return;
1688 } 1688 }
1689 1689
1690 // Setup geometry processor 1690 // Setup geometry processor
1691 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(), 1691 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(),
1692 this->str oke(), 1692 this->str oke(),
1693 invert, 1693 invert,
1694 this->use sLocalCoords())); 1694 this->use sLocalCoords()));
1695 1695
1696 batchTarget->initDraw(gp, this->pipeline()); 1696 target->initDraw(gp, this->pipeline());
1697 1697
1698 int instanceCount = fGeoData.count(); 1698 int instanceCount = fGeoData.count();
1699 size_t vertexStride = gp->getVertexStride(); 1699 size_t vertexStride = gp->getVertexStride();
1700 SkASSERT(vertexStride == sizeof(EllipseVertex)); 1700 SkASSERT(vertexStride == sizeof(EllipseVertex));
1701 1701
1702 // drop out the middle quad if we're stroked 1702 // drop out the middle quad if we're stroked
1703 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi cesPerRRect; 1703 int indicesPerInstance = this->stroke() ? kIndicesPerStrokeRRect : kIndi cesPerRRect;
1704 SkAutoTUnref<const GrIndexBuffer> indexBuffer( 1704 SkAutoTUnref<const GrIndexBuffer> indexBuffer(
1705 ref_rrect_index_buffer(this->stroke(), batchTarget->resourceProvider ())); 1705 ref_rrect_index_buffer(this->stroke(), target->resourceProvider()));
1706 1706
1707 InstancedHelper helper; 1707 InstancedHelper helper;
1708 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( 1708 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(
1709 helper.init(batchTarget, kTriangles_GrPrimitiveType, vertexStride, i ndexBuffer, 1709 helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexB uffer,
1710 kVertsPerRRect, indicesPerInstance, instanceCount)); 1710 kVertsPerRRect, indicesPerInstance, instanceCount));
1711 if (!verts || !indexBuffer) { 1711 if (!verts || !indexBuffer) {
1712 SkDebugf("Could not allocate vertices\n"); 1712 SkDebugf("Could not allocate vertices\n");
1713 return; 1713 return;
1714 } 1714 }
1715 1715
1716 for (int i = 0; i < instanceCount; i++) { 1716 for (int i = 0; i < instanceCount; i++) {
1717 Geometry& args = fGeoData[i]; 1717 Geometry& args = fGeoData[i];
1718 1718
1719 // Compute the reciprocals of the radii here to save time in the sha der 1719 // Compute the reciprocals of the radii here to save time in the sha der
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci p); 1760 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci p);
1761 verts++; 1761 verts++;
1762 1762
1763 verts->fPos = SkPoint::Make(bounds.fRight, yCoords[i]); 1763 verts->fPos = SkPoint::Make(bounds.fRight, yCoords[i]);
1764 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]); 1764 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]);
1765 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 1765 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
1766 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci p); 1766 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadReci p);
1767 verts++; 1767 verts++;
1768 } 1768 }
1769 } 1769 }
1770 helper.issueDraw(batchTarget); 1770 helper.recordDraw(target);
1771 } 1771 }
1772 1772
1773 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 1773 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
1774 1774
1775 private: 1775 private:
1776 RRectEllipseRendererBatch(const Geometry& geometry) { 1776 RRectEllipseRendererBatch(const Geometry& geometry) {
1777 this->initClassID<RRectEllipseRendererBatch>(); 1777 this->initClassID<RRectEllipseRendererBatch>();
1778 fGeoData.push_back(geometry); 1778 fGeoData.push_back(geometry);
1779 1779
1780 this->setBounds(geometry.fDevBounds); 1780 this->setBounds(geometry.fDevBounds);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 } 2036 }
2037 2037
2038 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 2038 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
2039 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2039 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2040 GrColor color = GrRandomColor(random); 2040 GrColor color = GrRandomColor(random);
2041 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2041 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2042 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2042 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2043 } 2043 }
2044 2044
2045 #endif 2045 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderCommandBuilder.cpp ('k') | src/gpu/GrReorderCommandBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698