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

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

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix 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 onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE { 147 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
148 inout->mulByUnknownAlpha(); 148 out->setUnknownSingleComponent();
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 onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE { 293 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
294 inout->mulByUnknownAlpha(); 294 out->setUnknownSingleComponent();
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 onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE { 458 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
459 inout->mulByUnknownAlpha(); 459 out->setUnknownSingleComponent();
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 GrGeometryProcessor* gp = CircleEdgeEffect::Create(color, isStrokeOnly && in nerRadius > 0); 565 SkAutoTUnref<GrGeometryProcessor> gp(
566 drawState->setGeometryProcessor(gp)->unref(); 566 CircleEdgeEffect::Create(color, isStrokeOnly && innerRadius > 0));
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, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds); 612 target->drawIndexedInstances(drawState, gp, 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 GrGeometryProcessor* gp = EllipseEdgeEffect::Create(color, 692 SkAutoTUnref<GrGeometryProcessor> gp(
693 isStrokeOnly && 693 EllipseEdgeEffect::Create(color, isStrokeOnly && innerXRadius > 0 && innerYRadius > 0));
694 innerXRadius > 0 && inne rYRadius > 0);
695
696 drawState->setGeometryProcessor(gp)->unref();
697 694
698 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0); 695 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
699 SkASSERT(gp->getVertexStride() == sizeof(EllipseVertex)); 696 SkASSERT(gp->getVertexStride() == sizeof(EllipseVertex));
700 if (!geo.succeeded()) { 697 if (!geo.succeeded()) {
701 SkDebugf("Failed to get space for vertices!\n"); 698 SkDebugf("Failed to get space for vertices!\n");
702 return false; 699 return false;
703 } 700 }
704 701
705 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 702 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
706 703
(...skipping 30 matching lines...) Expand all
737 verts[2].fOffset = SkPoint::Make(xRadius, yRadius); 734 verts[2].fOffset = SkPoint::Make(xRadius, yRadius);
738 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 735 verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
739 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); 736 verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
740 737
741 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 738 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
742 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius); 739 verts[3].fOffset = SkPoint::Make(xRadius, -yRadius);
743 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 740 verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
744 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); 741 verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
745 742
746 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); 743 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
747 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds); 744 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4 , 6, &bounds);
748 target->resetIndexSource(); 745 target->resetIndexSource();
749 746
750 return true; 747 return true;
751 } 748 }
752 749
753 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, 750 bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
754 GrDrawState* drawState, 751 GrDrawState* drawState,
755 GrColor color, 752 GrColor color,
756 const GrContext* context, 753 const GrContext* context,
757 bool useCoverageAA, 754 bool useCoverageAA,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 xRadius += strokeWidth; 799 xRadius += strokeWidth;
803 yRadius += strokeWidth; 800 yRadius += strokeWidth;
804 } 801 }
805 if (DIEllipseEdgeEffect::kStroke == mode) { 802 if (DIEllipseEdgeEffect::kStroke == mode) {
806 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke : 803 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke :
807 DIEllipseEdgeEffect::kFi ll; 804 DIEllipseEdgeEffect::kFi ll;
808 } 805 }
809 SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius); 806 SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius);
810 SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius); 807 SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius);
811 808
812 GrGeometryProcessor* gp = DIEllipseEdgeEffect::Create(color, mode); 809 SkAutoTUnref<GrGeometryProcessor> gp(DIEllipseEdgeEffect::Create(color, mode ));
813
814 drawState->setGeometryProcessor(gp)->unref();
815 810
816 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0); 811 GrDrawTarget::AutoReleaseGeometry geo(target, 4, gp->getVertexStride(), 0);
817 SkASSERT(gp->getVertexStride() == sizeof(DIEllipseVertex)); 812 SkASSERT(gp->getVertexStride() == sizeof(DIEllipseVertex));
818 if (!geo.succeeded()) { 813 if (!geo.succeeded()) {
819 SkDebugf("Failed to get space for vertices!\n"); 814 SkDebugf("Failed to get space for vertices!\n");
820 return false; 815 return false;
821 } 816 }
822 817
823 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices()); 818 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices());
824 819
(...skipping 25 matching lines...) Expand all
850 845
851 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 846 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
852 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy); 847 verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy);
853 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY + offsetDy); 848 verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY + offsetDy);
854 849
855 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); 850 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
856 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy); 851 verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy);
857 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy); 852 verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy);
858 853
859 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); 854 target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer());
860 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &bounds); 855 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, 1, 4 , 6, &bounds);
861 target->resetIndexSource(); 856 target->resetIndexSource();
862 857
863 return true; 858 return true;
864 } 859 }
865 860
866 /////////////////////////////////////////////////////////////////////////////// 861 ///////////////////////////////////////////////////////////////////////////////
867 862
868 static const uint16_t gRRectIndices[] = { 863 static const uint16_t gRRectIndices[] = {
869 // corners 864 // corners
870 0, 1, 5, 0, 5, 4, 865 0, 1, 5, 0, 5, 4,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 1065
1071 if (isStrokeOnly) { 1066 if (isStrokeOnly) {
1072 innerRadius = xRadius - halfWidth; 1067 innerRadius = xRadius - halfWidth;
1073 } 1068 }
1074 outerRadius += halfWidth; 1069 outerRadius += halfWidth;
1075 bounds.outset(halfWidth, halfWidth); 1070 bounds.outset(halfWidth, halfWidth);
1076 } 1071 }
1077 1072
1078 isStrokeOnly = (isStrokeOnly && innerRadius >= 0); 1073 isStrokeOnly = (isStrokeOnly && innerRadius >= 0);
1079 1074
1080 GrGeometryProcessor* effect = CircleEdgeEffect::Create(color, isStrokeOn ly); 1075 SkAutoTUnref<GrGeometryProcessor> effect(CircleEdgeEffect::Create(color, isStrokeOnly));
1081 drawState->setGeometryProcessor(effect)->unref();
1082 1076
1083 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0); 1077 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0);
1084 SkASSERT(effect->getVertexStride() == sizeof(CircleVertex)); 1078 SkASSERT(effect->getVertexStride() == sizeof(CircleVertex));
1085 if (!geo.succeeded()) { 1079 if (!geo.succeeded()) {
1086 SkDebugf("Failed to get space for vertices!\n"); 1080 SkDebugf("Failed to get space for vertices!\n");
1087 return false; 1081 return false;
1088 } 1082 }
1089 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); 1083 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
1090 1084
1091 // The radii are outset for two reasons. First, it allows the shader to simply perform 1085 // 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
1133 verts->fOffset = SkPoint::Make(outerRadius, yOuterRadii[i]); 1127 verts->fOffset = SkPoint::Make(outerRadius, yOuterRadii[i]);
1134 verts->fOuterRadius = outerRadius; 1128 verts->fOuterRadius = outerRadius;
1135 verts->fInnerRadius = innerRadius; 1129 verts->fInnerRadius = innerRadius;
1136 verts++; 1130 verts++;
1137 } 1131 }
1138 1132
1139 // drop out the middle quad if we're stroked 1133 // drop out the middle quad if we're stroked
1140 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1134 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1141 SK_ARRAY_COUNT(gRRectIndices); 1135 SK_ARRAY_COUNT(gRRectIndices);
1142 target->setIndexSourceToBuffer(indexBuffer); 1136 target->setIndexSourceToBuffer(indexBuffer);
1143 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 1 6, indexCnt, 1137 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy pe, 1, 16, indexCnt,
1144 &bounds); 1138 &bounds);
1145 1139
1146 // otherwise we use the ellipse renderer 1140 // otherwise we use the ellipse renderer
1147 } else { 1141 } else {
1148 SkScalar innerXRadius = 0.0f; 1142 SkScalar innerXRadius = 0.0f;
1149 SkScalar innerYRadius = 0.0f; 1143 SkScalar innerYRadius = 0.0f;
1150 if (hasStroke) { 1144 if (hasStroke) {
1151 if (SkScalarNearlyZero(scaledStroke.length())) { 1145 if (SkScalarNearlyZero(scaledStroke.length())) {
1152 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); 1146 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf);
1153 } else { 1147 } else {
(...skipping 18 matching lines...) Expand all
1172 innerYRadius = yRadius - scaledStroke.fY; 1166 innerYRadius = yRadius - scaledStroke.fY;
1173 } 1167 }
1174 1168
1175 xRadius += scaledStroke.fX; 1169 xRadius += scaledStroke.fX;
1176 yRadius += scaledStroke.fY; 1170 yRadius += scaledStroke.fY;
1177 bounds.outset(scaledStroke.fX, scaledStroke.fY); 1171 bounds.outset(scaledStroke.fX, scaledStroke.fY);
1178 } 1172 }
1179 1173
1180 isStrokeOnly = (isStrokeOnly && innerXRadius >= 0 && innerYRadius >= 0); 1174 isStrokeOnly = (isStrokeOnly && innerXRadius >= 0 && innerYRadius >= 0);
1181 1175
1182 GrGeometryProcessor* effect = EllipseEdgeEffect::Create(color, isStrokeO nly); 1176 SkAutoTUnref<GrGeometryProcessor> effect(EllipseEdgeEffect::Create(color , isStrokeOnly));
1183 drawState->setGeometryProcessor(effect)->unref();
1184 1177
1185 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0); 1178 GrDrawTarget::AutoReleaseGeometry geo(target, 16, effect->getVertexStrid e(), 0);
1186 SkASSERT(effect->getVertexStride() == sizeof(EllipseVertex)); 1179 SkASSERT(effect->getVertexStride() == sizeof(EllipseVertex));
1187 if (!geo.succeeded()) { 1180 if (!geo.succeeded()) {
1188 SkDebugf("Failed to get space for vertices!\n"); 1181 SkDebugf("Failed to get space for vertices!\n");
1189 return false; 1182 return false;
1190 } 1183 }
1191 1184
1192 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 1185 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
1193 1186
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]); 1233 verts->fOffset = SkPoint::Make(xOuterRadius, yOuterOffsets[i]);
1241 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); 1234 verts->fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
1242 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); 1235 verts->fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
1243 verts++; 1236 verts++;
1244 } 1237 }
1245 1238
1246 // drop out the middle quad if we're stroked 1239 // drop out the middle quad if we're stroked
1247 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1240 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1248 SK_ARRAY_COUNT(gRRectIndices); 1241 SK_ARRAY_COUNT(gRRectIndices);
1249 target->setIndexSourceToBuffer(indexBuffer); 1242 target->setIndexSourceToBuffer(indexBuffer);
1250 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 1 6, indexCnt, 1243 target->drawIndexedInstances(drawState, effect, kTriangles_GrPrimitiveTy pe, 1, 16, indexCnt,
1251 &bounds); 1244 &bounds);
1252 } 1245 }
1253 1246
1254 target->resetIndexSource(); 1247 target->resetIndexSource();
1255 return true; 1248 return true;
1256 } 1249 }
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