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

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

Issue 794843002: Revert of Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: Created 6 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 | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrProcOptInfo.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 "GrProcessor.h" 10 #include "GrProcessor.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 fInCircleEdge = &this->addVertexAttrib(GrAttribute("inCircleEdge", 137 fInCircleEdge = &this->addVertexAttrib(GrAttribute("inCircleEdge",
138 kVec4f_GrVertexAttrib Type)); 138 kVec4f_GrVertexAttrib Type));
139 fStroke = stroke; 139 fStroke = stroke;
140 } 140 }
141 141
142 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { 142 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE {
143 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>(); 143 const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>();
144 return cee.fStroke == fStroke; 144 return cee.fStroke == fStroke;
145 } 145 }
146 146
147 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE { 147 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE {
148 out->setUnknownSingleComponent(); 148 inout->mulByUnknownAlpha();
149 } 149 }
150 150
151 const GrAttribute* fInPosition; 151 const GrAttribute* fInPosition;
152 const GrAttribute* fInCircleEdge; 152 const GrAttribute* fInCircleEdge;
153 bool fStroke; 153 bool fStroke;
154 154
155 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 155 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
156 156
157 typedef GrGeometryProcessor INHERITED; 157 typedef GrGeometryProcessor INHERITED;
158 }; 158 };
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 fInEllipseRadii = &this->addVertexAttrib(GrAttribute("inEllipseRadii", 283 fInEllipseRadii = &this->addVertexAttrib(GrAttribute("inEllipseRadii",
284 kVec4f_GrVertexAttr ibType)); 284 kVec4f_GrVertexAttr ibType));
285 fStroke = stroke; 285 fStroke = stroke;
286 } 286 }
287 287
288 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { 288 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE {
289 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>(); 289 const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>();
290 return eee.fStroke == fStroke; 290 return eee.fStroke == fStroke;
291 } 291 }
292 292
293 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE { 293 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE {
294 out->setUnknownSingleComponent(); 294 inout->mulByUnknownAlpha();
295 } 295 }
296 296
297 const GrAttribute* fInPosition; 297 const GrAttribute* fInPosition;
298 const GrAttribute* fInEllipseOffset; 298 const GrAttribute* fInEllipseOffset;
299 const GrAttribute* fInEllipseRadii; 299 const GrAttribute* fInEllipseRadii;
300 bool fStroke; 300 bool fStroke;
301 301
302 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 302 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
303 303
304 typedef GrGeometryProcessor INHERITED; 304 typedef GrGeometryProcessor INHERITED;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 fInEllipseOffsets1 = &this->addVertexAttrib(GrAttribute("inEllipseOffset s1", 448 fInEllipseOffsets1 = &this->addVertexAttrib(GrAttribute("inEllipseOffset s1",
449 kVec2f_GrVertexA ttribType)); 449 kVec2f_GrVertexA ttribType));
450 fMode = mode; 450 fMode = mode;
451 } 451 }
452 452
453 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { 453 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE {
454 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>(); 454 const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>();
455 return eee.fMode == fMode; 455 return eee.fMode == fMode;
456 } 456 }
457 457
458 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE { 458 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE {
459 out->setUnknownSingleComponent(); 459 inout->mulByUnknownAlpha();
460 } 460 }
461 461
462 const GrAttribute* fInPosition; 462 const GrAttribute* fInPosition;
463 const GrAttribute* fInEllipseOffsets0; 463 const GrAttribute* fInEllipseOffsets0;
464 const GrAttribute* fInEllipseOffsets1; 464 const GrAttribute* fInEllipseOffsets1;
465 Mode fMode; 465 Mode fMode;
466 466
467 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; 467 GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
468 468
469 typedef GrGeometryProcessor INHERITED; 469 typedef GrGeometryProcessor INHERITED;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } else { 555 } else {
556 halfWidth = SkScalarHalf(strokeWidth); 556 halfWidth = SkScalarHalf(strokeWidth);
557 } 557 }
558 558
559 outerRadius += halfWidth; 559 outerRadius += halfWidth;
560 if (isStrokeOnly) { 560 if (isStrokeOnly) {
561 innerRadius = radius - halfWidth; 561 innerRadius = radius - halfWidth;
562 } 562 }
563 } 563 }
564 564
565 SkAutoTUnref<GrGeometryProcessor> gp( 565 GrGeometryProcessor* gp = CircleEdgeEffect::Create(color, isStrokeOnly && in nerRadius > 0);
566 CircleEdgeEffect::Create(color, isStrokeOnly && innerRadius > 0)); 566 drawState->setGeometryProcessor(gp)->unref();
567 567
568 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0); 568 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
569 SkASSERT(gp->getVertexStride() == sizeof(CircleVertex)); 569 SkASSERT(gp->getVertexStride() == sizeof(CircleVertex));
570 if (!geo.succeeded()) { 570 if (!geo.succeeded()) {
571 SkDebugf("Failed to get space for vertices!\n"); 571 SkDebugf("Failed to get space for vertices!\n");
572 return; 572 return;
573 } 573 }
574 574
575 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); 575 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
576 576
(...skipping 25 matching lines...) Expand all
602 verts[2].fOffset = SkPoint::Make(outerRadius, outerRadius); 602 verts[2].fOffset = SkPoint::Make(outerRadius, outerRadius);
603 verts[2].fOuterRadius = outerRadius; 603 verts[2].fOuterRadius = outerRadius;
604 verts[2].fInnerRadius = innerRadius; 604 verts[2].fInnerRadius = innerRadius;
605 605
606 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 606 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
607 verts[3].fOffset = SkPoint::Make(outerRadius, -outerRadius); 607 verts[3].fOffset = SkPoint::Make(outerRadius, -outerRadius);
608 verts[3].fOuterRadius = outerRadius; 608 verts[3].fOuterRadius = outerRadius;
609 verts[3].fInnerRadius = innerRadius; 609 verts[3].fInnerRadius = innerRadius;
610 610
611 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); 611 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
612 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4 , 6, &bounds); 612 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
613 target->resetIndexSource(); 613 target->resetIndexSource();
614 } 614 }
615 615
616 /////////////////////////////////////////////////////////////////////////////// 616 ///////////////////////////////////////////////////////////////////////////////
617 617
618 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, 618 bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
619 GrDrawState* drawState, 619 GrDrawState* drawState,
620 GrColor color, 620 GrColor color,
621 const GrContext* context, 621 const GrContext* context,
622 bool useCoverageAA, 622 bool useCoverageAA,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 682
683 xRadius += scaledStroke.fX; 683 xRadius += scaledStroke.fX;
684 yRadius += scaledStroke.fY; 684 yRadius += scaledStroke.fY;
685 } 685 }
686 686
687 GrDrawState::AutoViewMatrixRestore avmr; 687 GrDrawState::AutoViewMatrixRestore avmr;
688 if (!avmr.setIdentity(drawState)) { 688 if (!avmr.setIdentity(drawState)) {
689 return false; 689 return false;
690 } 690 }
691 691
692 SkAutoTUnref<GrGeometryProcessor> gp( 692 GrGeometryProcessor* gp = EllipseEdgeEffect::Create(color,
693 EllipseEdgeEffect::Create(color, isStrokeOnly && innerXRadius > 0 && innerYRadius > 0)); 693 isStrokeOnly &&
694 innerXRadius > 0 && inne rYRadius > 0);
695
696 drawState->setGeometryProcessor(gp)->unref();
694 697
695 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0); 698 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
696 SkASSERT(gp->getVertexStride() == sizeof(EllipseVertex)); 699 SkASSERT(gp->getVertexStride() == sizeof(EllipseVertex));
697 if (!geo.succeeded()) { 700 if (!geo.succeeded()) {
698 SkDebugf("Failed to get space for vertices!\n"); 701 SkDebugf("Failed to get space for vertices!\n");
699 return false; 702 return false;
700 } 703 }
701 704
702 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 705 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
703 706
(...skipping 30 matching lines...) Expand all
734 verts[2].fOffset = SkPoint::Make(xRadius, yRadius); 737 verts[2].fOffset = SkPoint::Make(xRadius, yRadius);
735 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 738 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
736 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); 739 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
737 740
738 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 741 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
739 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius); 742 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius);
740 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 743 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
741 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); 744 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
742 745
743 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); 746 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
744 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4 , 6, &bounds); 747 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
745 target->resetIndexSource(); 748 target->resetIndexSource();
746 749
747 return true; 750 return true;
748 } 751 }
749 752
750 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, 753 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
751 GrDrawState* drawState, 754 GrDrawState* drawState,
752 GrColor color, 755 GrColor color,
753 const GrContext* context, 756 const GrContext* context,
754 bool useCoverageAA, 757 bool useCoverageAA,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 xRadius += strokeWidth; 802 xRadius += strokeWidth;
800 yRadius += strokeWidth; 803 yRadius += strokeWidth;
801 } 804 }
802 if (DIEllipseEdgeEffect::kStroke == mode) { 805 if (DIEllipseEdgeEffect::kStroke == mode) {
803 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke : 806 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke :
804 DIEllipseEdgeEffect::kFi ll; 807 DIEllipseEdgeEffect::kFi ll;
805 } 808 }
806 SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius); 809 SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius);
807 SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius); 810 SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius);
808 811
809 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(color, mode )); 812 GrGeometryProcessor* gp = DIEllipseEdgeEffect::Create(color, mode);
813
814 drawState->setGeometryProcessor(gp)->unref();
810 815
811 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0); 816 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
812 SkASSERT(gp->getVertexStride() == sizeof(DIEllipseVertex)); 817 SkASSERT(gp->getVertexStride() == sizeof(DIEllipseVertex));
813 if (!geo.succeeded()) { 818 if (!geo.succeeded()) {
814 SkDebugf("Failed to get space for vertices!\n"); 819 SkDebugf("Failed to get space for vertices!\n");
815 return false; 820 return false;
816 } 821 }
817 822
818 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices()); 823 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices());
819 824
(...skipping 25 matching lines...) Expand all
845 850
846 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 851 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
847 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy); 852 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy);
848 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY + offsetDy); 853 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY + offsetDy);
849 854
850 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 855 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
851 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy); 856 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy);
852 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy); 857 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy);
853 858
854 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); 859 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
855 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4 , 6, &bounds); 860 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
856 target->resetIndexSource(); 861 target->resetIndexSource();
857 862
858 return true; 863 return true;
859 } 864 }
860 865
861 /////////////////////////////////////////////////////////////////////////////// 866 ///////////////////////////////////////////////////////////////////////////////
862 867
863 static const uint16_t gRRectIndices[] = { 868 static const uint16_t gRRectIndices[] = {
864 // corners 869 // corners
865 0, 1, 5, 0, 5, 4, 870 0, 1, 5, 0, 5, 4,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 1070
1066 if (isStrokeOnly) { 1071 if (isStrokeOnly) {
1067 innerRadius = xRadius - halfWidth; 1072 innerRadius = xRadius - halfWidth;
1068 } 1073 }
1069 outerRadius += halfWidth; 1074 outerRadius += halfWidth;
1070 bounds.outset(halfWidth, halfWidth); 1075 bounds.outset(halfWidth, halfWidth);
1071 } 1076 }
1072 1077
1073 isStrokeOnly = (isStrokeOnly && innerRadius >= 0); 1078 isStrokeOnly = (isStrokeOnly && innerRadius >= 0);
1074 1079
1075 SkAutoTUnref<GrGeometryProcessor> effect(CircleEdgeEffect::Create(color, isStrokeOnly)); 1080 GrGeometryProcessor* effect = CircleEdgeEffect::Create(color, isStrokeOn ly);
1081 drawState->setGeometryProcessor(effect)->unref();
1076 1082
1077 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0); 1083 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0);
1078 SkASSERT(effect->getVertexStride() == sizeof(CircleVertex)); 1084 SkASSERT(effect->getVertexStride() == sizeof(CircleVertex));
1079 if (!geo.succeeded()) { 1085 if (!geo.succeeded()) {
1080 SkDebugf("Failed to get space for vertices!\n"); 1086 SkDebugf("Failed to get space for vertices!\n");
1081 return false; 1087 return false;
1082 } 1088 }
1083 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); 1089 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
1084 1090
1085 // The radii are outset for two reasons. First, it allows the shader to simply perform 1091 // The radii are outset for two reasons. First, it allows the shader to simply perform
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 verts->fOffset = SkPoint::Make(outerRadius, yOuterRadii[i]); 1133 verts->fOffset = SkPoint::Make(outerRadius, yOuterRadii[i]);
1128 verts->fOuterRadius = outerRadius; 1134 verts->fOuterRadius = outerRadius;
1129 verts->fInnerRadius = innerRadius; 1135 verts->fInnerRadius = innerRadius;
1130 verts++; 1136 verts++;
1131 } 1137 }
1132 1138
1133 // drop out the middle quad if we're stroked 1139 // drop out the middle quad if we're stroked
1134 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1140 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1135 SK_ARRAY_COUNT(gRRectIndices); 1141 SK_ARRAY_COUNT(gRRectIndices);
1136 target->setIndexSourceToBuffer(indexBuffer); 1142 target->setIndexSourceToBuffer(indexBuffer);
1137 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy pe, 1, 16, indexCnt, 1143 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 1 6, indexCnt,
1138 &bounds); 1144 &bounds);
1139 1145
1140 // otherwise we use the ellipse renderer 1146 // otherwise we use the ellipse renderer
1141 } else { 1147 } else {
1142 SkScalar innerXRadius = 0.0f; 1148 SkScalar innerXRadius = 0.0f;
1143 SkScalar innerYRadius = 0.0f; 1149 SkScalar innerYRadius = 0.0f;
1144 if (hasStroke) { 1150 if (hasStroke) {
1145 if (SkScalarNearlyZero(scaledStroke.length())) { 1151 if (SkScalarNearlyZero(scaledStroke.length())) {
1146 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); 1152 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf);
1147 } else { 1153 } else {
(...skipping 18 matching lines...) Expand all
1166 innerYRadius = yRadius - scaledStroke.fY; 1172 innerYRadius = yRadius - scaledStroke.fY;
1167 } 1173 }
1168 1174
1169 xRadius += scaledStroke.fX; 1175 xRadius += scaledStroke.fX;
1170 yRadius += scaledStroke.fY; 1176 yRadius += scaledStroke.fY;
1171 bounds.outset(scaledStroke.fX, scaledStroke.fY); 1177 bounds.outset(scaledStroke.fX, scaledStroke.fY);
1172 } 1178 }
1173 1179
1174 isStrokeOnly = (isStrokeOnly && innerXRadius >= 0 && innerYRadius >= 0); 1180 isStrokeOnly = (isStrokeOnly && innerXRadius >= 0 && innerYRadius >= 0);
1175 1181
1176 SkAutoTUnref<GrGeometryProcessor> effect(EllipseEdgeEffect::Create(color , isStrokeOnly)); 1182 GrGeometryProcessor* effect = EllipseEdgeEffect::Create(color, isStrokeO nly);
1183 drawState->setGeometryProcessor(effect)->unref();
1177 1184
1178 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0); 1185 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0);
1179 SkASSERT(effect->getVertexStride() == sizeof(EllipseVertex)); 1186 SkASSERT(effect->getVertexStride() == sizeof(EllipseVertex));
1180 if (!geo.succeeded()) { 1187 if (!geo.succeeded()) {
1181 SkDebugf("Failed to get space for vertices!\n"); 1188 SkDebugf("Failed to get space for vertices!\n");
1182 return false; 1189 return false;
1183 } 1190 }
1184 1191
1185 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 1192 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
1186 1193
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]); 1240 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]);
1234 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 1241 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
1235 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); 1242 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
1236 verts++; 1243 verts++;
1237 } 1244 }
1238 1245
1239 // drop out the middle quad if we're stroked 1246 // drop out the middle quad if we're stroked
1240 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1247 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1241 SK_ARRAY_COUNT(gRRectIndices); 1248 SK_ARRAY_COUNT(gRRectIndices);
1242 target->setIndexSourceToBuffer(indexBuffer); 1249 target->setIndexSourceToBuffer(indexBuffer);
1243 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy pe, 1, 16, indexCnt, 1250 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 1 6, indexCnt,
1244 &bounds); 1251 &bounds);
1245 } 1252 }
1246 1253
1247 target->resetIndexSource(); 1254 target->resetIndexSource();
1248 return true; 1255 return true;
1249 } 1256 }
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrProcOptInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698