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

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

Issue 1483103003: Make onPrepareDraws const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 5 years 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 | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrPathUtils.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 "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 685 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
686 686
687 // setup batch properties 687 // setup batch properties
688 fBatch.fColorIgnored = !overrides.readsColor(); 688 fBatch.fColorIgnored = !overrides.readsColor();
689 fBatch.fColor = fGeoData[0].fColor; 689 fBatch.fColor = fGeoData[0].fColor;
690 fBatch.fStroke = fGeoData[0].fStroke; 690 fBatch.fStroke = fGeoData[0].fStroke;
691 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 691 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
692 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 692 fBatch.fCoverageIgnored = !overrides.readsCoverage();
693 } 693 }
694 694
695 void onPrepareDraws(Target* target) override { 695 void onPrepareDraws(Target* target) const override {
696 SkMatrix invert; 696 SkMatrix invert;
697 if (!this->viewMatrix().invert(&invert)) { 697 if (!this->viewMatrix().invert(&invert)) {
698 return; 698 return;
699 } 699 }
700 700
701 // Setup geometry processor 701 // Setup geometry processor
702 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(), 702 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(),
703 this->stro ke(), 703 this->stro ke(),
704 invert, 704 invert,
705 this->uses LocalCoords())); 705 this->uses LocalCoords()));
706 706
707 target->initDraw(gp, this->pipeline()); 707 target->initDraw(gp, this->pipeline());
708 708
709 int instanceCount = fGeoData.count(); 709 int instanceCount = fGeoData.count();
710 size_t vertexStride = gp->getVertexStride(); 710 size_t vertexStride = gp->getVertexStride();
711 SkASSERT(vertexStride == sizeof(CircleVertex)); 711 SkASSERT(vertexStride == sizeof(CircleVertex));
712 QuadHelper helper; 712 QuadHelper helper;
713 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target , vertexStride, 713 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target , vertexStride,
714 instan ceCount)); 714 instan ceCount));
715 if (!verts) { 715 if (!verts) {
716 return; 716 return;
717 } 717 }
718 718
719 for (int i = 0; i < instanceCount; i++) { 719 for (int i = 0; i < instanceCount; i++) {
720 Geometry& geom = fGeoData[i]; 720 const Geometry& geom = fGeoData[i];
721 721
722 SkScalar innerRadius = geom.fInnerRadius; 722 SkScalar innerRadius = geom.fInnerRadius;
723 SkScalar outerRadius = geom.fOuterRadius; 723 SkScalar outerRadius = geom.fOuterRadius;
724 724
725 const SkRect& bounds = geom.fDevBounds; 725 const SkRect& bounds = geom.fDevBounds;
726 726
727 // The inner radius in the vertex data must be specified in normaliz ed space. 727 // The inner radius in the vertex data must be specified in normaliz ed space.
728 innerRadius = innerRadius / outerRadius; 728 innerRadius = innerRadius / outerRadius;
729 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); 729 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop);
730 verts[0].fOffset = SkPoint::Make(-1, -1); 730 verts[0].fOffset = SkPoint::Make(-1, -1);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 905 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
906 906
907 // setup batch properties 907 // setup batch properties
908 fBatch.fColorIgnored = !overrides.readsColor(); 908 fBatch.fColorIgnored = !overrides.readsColor();
909 fBatch.fColor = fGeoData[0].fColor; 909 fBatch.fColor = fGeoData[0].fColor;
910 fBatch.fStroke = fGeoData[0].fStroke; 910 fBatch.fStroke = fGeoData[0].fStroke;
911 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 911 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
912 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 912 fBatch.fCoverageIgnored = !overrides.readsCoverage();
913 } 913 }
914 914
915 void onPrepareDraws(Target* target) override { 915 void onPrepareDraws(Target* target) const override {
916 SkMatrix invert; 916 SkMatrix invert;
917 if (!this->viewMatrix().invert(&invert)) { 917 if (!this->viewMatrix().invert(&invert)) {
918 return; 918 return;
919 } 919 }
920 920
921 // Setup geometry processor 921 // Setup geometry processor
922 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(), 922 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(),
923 this->str oke(), 923 this->str oke(),
924 invert, 924 invert,
925 this->use sLocalCoords())); 925 this->use sLocalCoords()));
926 926
927 target->initDraw(gp, this->pipeline()); 927 target->initDraw(gp, this->pipeline());
928 928
929 int instanceCount = fGeoData.count(); 929 int instanceCount = fGeoData.count();
930 QuadHelper helper; 930 QuadHelper helper;
931 size_t vertexStride = gp->getVertexStride(); 931 size_t vertexStride = gp->getVertexStride();
932 SkASSERT(vertexStride == sizeof(EllipseVertex)); 932 SkASSERT(vertexStride == sizeof(EllipseVertex));
933 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( 933 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(
934 helper.init(target, vertexStride, instanceCount)); 934 helper.init(target, vertexStride, instanceCount));
935 if (!verts) { 935 if (!verts) {
936 return; 936 return;
937 } 937 }
938 938
939 for (int i = 0; i < instanceCount; i++) { 939 for (int i = 0; i < instanceCount; i++) {
940 Geometry& geom = fGeoData[i]; 940 const Geometry& geom = fGeoData[i];
941 941
942 SkScalar xRadius = geom.fXRadius; 942 SkScalar xRadius = geom.fXRadius;
943 SkScalar yRadius = geom.fYRadius; 943 SkScalar yRadius = geom.fYRadius;
944 944
945 // Compute the reciprocals of the radii here to save time in the sha der 945 // Compute the reciprocals of the radii here to save time in the sha der
946 SkScalar xRadRecip = SkScalarInvert(xRadius); 946 SkScalar xRadRecip = SkScalarInvert(xRadius);
947 SkScalar yRadRecip = SkScalarInvert(yRadius); 947 SkScalar yRadRecip = SkScalarInvert(yRadius);
948 SkScalar xInnerRadRecip = SkScalarInvert(geom.fInnerXRadius); 948 SkScalar xInnerRadRecip = SkScalarInvert(geom.fInnerXRadius);
949 SkScalar yInnerRadRecip = SkScalarInvert(geom.fInnerYRadius); 949 SkScalar yInnerRadRecip = SkScalarInvert(geom.fInnerYRadius);
950 950
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 1178 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
1179 1179
1180 // setup batch properties 1180 // setup batch properties
1181 fBatch.fColorIgnored = !overrides.readsColor(); 1181 fBatch.fColorIgnored = !overrides.readsColor();
1182 fBatch.fColor = fGeoData[0].fColor; 1182 fBatch.fColor = fGeoData[0].fColor;
1183 fBatch.fMode = fGeoData[0].fMode; 1183 fBatch.fMode = fGeoData[0].fMode;
1184 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 1184 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
1185 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 1185 fBatch.fCoverageIgnored = !overrides.readsCoverage();
1186 } 1186 }
1187 1187
1188 void onPrepareDraws(Target* target) override { 1188 void onPrepareDraws(Target* target) const override {
1189 // Setup geometry processor 1189 // Setup geometry processor
1190 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c olor(), 1190 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(this->c olor(),
1191 this->v iewMatrix(), 1191 this->v iewMatrix(),
1192 this->m ode(), 1192 this->m ode(),
1193 this->u sesLocalCoords())); 1193 this->u sesLocalCoords()));
1194 1194
1195 target->initDraw(gp, this->pipeline()); 1195 target->initDraw(gp, this->pipeline());
1196 1196
1197 int instanceCount = fGeoData.count(); 1197 int instanceCount = fGeoData.count();
1198 size_t vertexStride = gp->getVertexStride(); 1198 size_t vertexStride = gp->getVertexStride();
1199 SkASSERT(vertexStride == sizeof(DIEllipseVertex)); 1199 SkASSERT(vertexStride == sizeof(DIEllipseVertex));
1200 QuadHelper helper; 1200 QuadHelper helper;
1201 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>( 1201 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(
1202 helper.init(target, vertexStride, instanceCount)); 1202 helper.init(target, vertexStride, instanceCount));
1203 if (!verts) { 1203 if (!verts) {
1204 return; 1204 return;
1205 } 1205 }
1206 1206
1207 for (int i = 0; i < instanceCount; i++) { 1207 for (int i = 0; i < instanceCount; i++) {
1208 Geometry& geom = fGeoData[i]; 1208 const Geometry& geom = fGeoData[i];
1209 1209
1210 SkScalar xRadius = geom.fXRadius; 1210 SkScalar xRadius = geom.fXRadius;
1211 SkScalar yRadius = geom.fYRadius; 1211 SkScalar yRadius = geom.fYRadius;
1212 1212
1213 const SkRect& bounds = geom.fBounds; 1213 const SkRect& bounds = geom.fBounds;
1214 1214
1215 // This adjusts the "radius" to include the half-pixel border 1215 // This adjusts the "radius" to include the half-pixel border
1216 SkScalar offsetDx = geom.fGeoDx / xRadius; 1216 SkScalar offsetDx = geom.fGeoDx / xRadius;
1217 SkScalar offsetDy = geom.fGeoDy / yRadius; 1217 SkScalar offsetDy = geom.fGeoDy / yRadius;
1218 1218
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 1533 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
1534 1534
1535 // setup batch properties 1535 // setup batch properties
1536 fBatch.fColorIgnored = !overrides.readsColor(); 1536 fBatch.fColorIgnored = !overrides.readsColor();
1537 fBatch.fColor = fGeoData[0].fColor; 1537 fBatch.fColor = fGeoData[0].fColor;
1538 fBatch.fStroke = fGeoData[0].fStroke; 1538 fBatch.fStroke = fGeoData[0].fStroke;
1539 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 1539 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
1540 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 1540 fBatch.fCoverageIgnored = !overrides.readsCoverage();
1541 } 1541 }
1542 1542
1543 void onPrepareDraws(Target* target) override { 1543 void onPrepareDraws(Target* target) const override {
1544 // reset to device coordinates 1544 // reset to device coordinates
1545 SkMatrix invert; 1545 SkMatrix invert;
1546 if (!this->viewMatrix().invert(&invert)) { 1546 if (!this->viewMatrix().invert(&invert)) {
1547 SkDebugf("Failed to invert\n"); 1547 SkDebugf("Failed to invert\n");
1548 return; 1548 return;
1549 } 1549 }
1550 1550
1551 // Setup geometry processor 1551 // Setup geometry processor
1552 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(), 1552 SkAutoTUnref<GrGeometryProcessor> gp(CircleEdgeEffect::Create(this->colo r(),
1553 this->stro ke(), 1553 this->stro ke(),
(...skipping 14 matching lines...) Expand all
1568 InstancedHelper helper; 1568 InstancedHelper helper;
1569 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target , 1569 CircleVertex* verts = reinterpret_cast<CircleVertex*>(helper.init(target ,
1570 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec t, 1570 kTriangles_GrPrimitiveType, vertexStride, indexBuffer, kVertsPerRRec t,
1571 indicesPerInstance, instanceCount)); 1571 indicesPerInstance, instanceCount));
1572 if (!verts || !indexBuffer) { 1572 if (!verts || !indexBuffer) {
1573 SkDebugf("Could not allocate vertices\n"); 1573 SkDebugf("Could not allocate vertices\n");
1574 return; 1574 return;
1575 } 1575 }
1576 1576
1577 for (int i = 0; i < instanceCount; i++) { 1577 for (int i = 0; i < instanceCount; i++) {
1578 Geometry& args = fGeoData[i]; 1578 const Geometry& args = fGeoData[i];
1579 1579
1580 SkScalar outerRadius = args.fOuterRadius; 1580 SkScalar outerRadius = args.fOuterRadius;
1581 1581
1582 const SkRect& bounds = args.fDevBounds; 1582 const SkRect& bounds = args.fDevBounds;
1583 1583
1584 SkScalar yCoords[4] = { 1584 SkScalar yCoords[4] = {
1585 bounds.fTop, 1585 bounds.fTop,
1586 bounds.fTop + outerRadius, 1586 bounds.fTop + outerRadius,
1587 bounds.fBottom - outerRadius, 1587 bounds.fBottom - outerRadius,
1588 bounds.fBottom 1588 bounds.fBottom
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); 1713 overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
1714 1714
1715 // setup batch properties 1715 // setup batch properties
1716 fBatch.fColorIgnored = !overrides.readsColor(); 1716 fBatch.fColorIgnored = !overrides.readsColor();
1717 fBatch.fColor = fGeoData[0].fColor; 1717 fBatch.fColor = fGeoData[0].fColor;
1718 fBatch.fStroke = fGeoData[0].fStroke; 1718 fBatch.fStroke = fGeoData[0].fStroke;
1719 fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); 1719 fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
1720 fBatch.fCoverageIgnored = !overrides.readsCoverage(); 1720 fBatch.fCoverageIgnored = !overrides.readsCoverage();
1721 } 1721 }
1722 1722
1723 void onPrepareDraws(Target* target) override { 1723 void onPrepareDraws(Target* target) const override {
1724 // reset to device coordinates 1724 // reset to device coordinates
1725 SkMatrix invert; 1725 SkMatrix invert;
1726 if (!this->viewMatrix().invert(&invert)) { 1726 if (!this->viewMatrix().invert(&invert)) {
1727 SkDebugf("Failed to invert\n"); 1727 SkDebugf("Failed to invert\n");
1728 return; 1728 return;
1729 } 1729 }
1730 1730
1731 // Setup geometry processor 1731 // Setup geometry processor
1732 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(), 1732 SkAutoTUnref<GrGeometryProcessor> gp(EllipseEdgeEffect::Create(this->col or(),
1733 this->str oke(), 1733 this->str oke(),
(...skipping 14 matching lines...) Expand all
1748 InstancedHelper helper; 1748 InstancedHelper helper;
1749 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>( 1749 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(
1750 helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexB uffer, 1750 helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexB uffer,
1751 kVertsPerRRect, indicesPerInstance, instanceCount)); 1751 kVertsPerRRect, indicesPerInstance, instanceCount));
1752 if (!verts || !indexBuffer) { 1752 if (!verts || !indexBuffer) {
1753 SkDebugf("Could not allocate vertices\n"); 1753 SkDebugf("Could not allocate vertices\n");
1754 return; 1754 return;
1755 } 1755 }
1756 1756
1757 for (int i = 0; i < instanceCount; i++) { 1757 for (int i = 0; i < instanceCount; i++) {
1758 Geometry& args = fGeoData[i]; 1758 const Geometry& args = fGeoData[i];
1759 1759
1760 // Compute the reciprocals of the radii here to save time in the sha der 1760 // Compute the reciprocals of the radii here to save time in the sha der
1761 SkScalar xRadRecip = SkScalarInvert(args.fXRadius); 1761 SkScalar xRadRecip = SkScalarInvert(args.fXRadius);
1762 SkScalar yRadRecip = SkScalarInvert(args.fYRadius); 1762 SkScalar yRadRecip = SkScalarInvert(args.fYRadius);
1763 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius); 1763 SkScalar xInnerRadRecip = SkScalarInvert(args.fInnerXRadius);
1764 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius); 1764 SkScalar yInnerRadRecip = SkScalarInvert(args.fInnerYRadius);
1765 1765
1766 // Extend the radii out half a pixel to antialias. 1766 // Extend the radii out half a pixel to antialias.
1767 SkScalar xOuterRadius = args.fXRadius + SK_ScalarHalf; 1767 SkScalar xOuterRadius = args.fXRadius + SK_ScalarHalf;
1768 SkScalar yOuterRadius = args.fYRadius + SK_ScalarHalf; 1768 SkScalar yOuterRadius = args.fYRadius + SK_ScalarHalf;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 } 2077 }
2078 2078
2079 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 2079 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
2080 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2080 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2081 GrColor color = GrRandomColor(random); 2081 GrColor color = GrRandomColor(random);
2082 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2082 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2083 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2083 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2084 } 2084 }
2085 2085
2086 #endif 2086 #endif
OLDNEW
« no previous file with comments | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrPathUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698