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

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

Issue 511593004: Make setVertexAttribs in GrDrawState take a stride parameter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Release Fix Created 6 years, 3 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/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrRODrawState.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 "gl/builders/GrGLProgramBuilder.h" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrOvalRenderer.h" 9 #include "GrOvalRenderer.h"
10 10
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY()); 512 SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY());
513 vm.mapPoints(&center, 1); 513 vm.mapPoints(&center, 1);
514 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); 514 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width()));
515 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); 515 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth());
516 516
517 GrDrawState::AutoViewMatrixRestore avmr; 517 GrDrawState::AutoViewMatrixRestore avmr;
518 if (!avmr.setIdentity(drawState)) { 518 if (!avmr.setIdentity(drawState)) {
519 return; 519 return;
520 } 520 }
521 521
522 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert exAttribs)); 522 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert exAttribs),
523 SkASSERT(sizeof(CircleVertex) == drawState->getVertexSize()); 523 sizeof(CircleVertex));
524 524
525 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); 525 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
526 if (!geo.succeeded()) { 526 if (!geo.succeeded()) {
527 GrPrintf("Failed to get space for vertices!\n"); 527 GrPrintf("Failed to get space for vertices!\n");
528 return; 528 return;
529 } 529 }
530 530
531 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); 531 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
532 532
533 SkStrokeRec::Style style = stroke.getStyle(); 533 SkStrokeRec::Style style = stroke.getStyle();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 673
674 xRadius += scaledStroke.fX; 674 xRadius += scaledStroke.fX;
675 yRadius += scaledStroke.fY; 675 yRadius += scaledStroke.fY;
676 } 676 }
677 677
678 GrDrawState::AutoViewMatrixRestore avmr; 678 GrDrawState::AutoViewMatrixRestore avmr;
679 if (!avmr.setIdentity(drawState)) { 679 if (!avmr.setIdentity(drawState)) {
680 return false; 680 return false;
681 } 681 }
682 682
683 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe rtexAttribs)); 683 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe rtexAttribs),
684 SkASSERT(sizeof(EllipseVertex) == drawState->getVertexSize()); 684 sizeof(EllipseVertex));
685 685
686 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); 686 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
687 if (!geo.succeeded()) { 687 if (!geo.succeeded()) {
688 GrPrintf("Failed to get space for vertices!\n"); 688 GrPrintf("Failed to get space for vertices!\n");
689 return false; 689 return false;
690 } 690 }
691 691
692 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); 692 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
693 693
694 GrEffect* effect = EllipseEdgeEffect::Create(isStrokeOnly && 694 GrEffect* effect = EllipseEdgeEffect::Create(isStrokeOnly &&
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 xRadius += strokeWidth; 792 xRadius += strokeWidth;
793 yRadius += strokeWidth; 793 yRadius += strokeWidth;
794 } 794 }
795 if (DIEllipseEdgeEffect::kStroke == mode) { 795 if (DIEllipseEdgeEffect::kStroke == mode) {
796 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke : 796 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke :
797 DIEllipseEdgeEffect::kFi ll; 797 DIEllipseEdgeEffect::kFi ll;
798 } 798 }
799 SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius); 799 SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius);
800 SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius); 800 SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius);
801 801
802 drawState->setVertexAttribs<gDIEllipseVertexAttribs>(SK_ARRAY_COUNT(gDIEllip seVertexAttribs)); 802 drawState->setVertexAttribs<gDIEllipseVertexAttribs>(SK_ARRAY_COUNT(gDIEllip seVertexAttribs),
803 SkASSERT(sizeof(DIEllipseVertex) == drawState->getVertexSize()); 803 sizeof(DIEllipseVertex) );
804 804
805 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); 805 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
806 if (!geo.succeeded()) { 806 if (!geo.succeeded()) {
807 GrPrintf("Failed to get space for vertices!\n"); 807 GrPrintf("Failed to get space for vertices!\n");
808 return false; 808 return false;
809 } 809 }
810 810
811 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices()); 811 DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices());
812 812
813 GrEffect* effect = DIEllipseEdgeEffect::Create(mode); 813 GrEffect* effect = DIEllipseEdgeEffect::Create(mode);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 } 1025 }
1026 1026
1027 GrIndexBuffer* indexBuffer = this->rRectIndexBuffer(context->getGpu()); 1027 GrIndexBuffer* indexBuffer = this->rRectIndexBuffer(context->getGpu());
1028 if (NULL == indexBuffer) { 1028 if (NULL == indexBuffer) {
1029 GrPrintf("Failed to create index buffer!\n"); 1029 GrPrintf("Failed to create index buffer!\n");
1030 return false; 1030 return false;
1031 } 1031 }
1032 1032
1033 // if the corners are circles, use the circle renderer 1033 // if the corners are circles, use the circle renderer
1034 if ((!hasStroke || scaledStroke.fX == scaledStroke.fY) && xRadius == yRadius ) { 1034 if ((!hasStroke || scaledStroke.fX == scaledStroke.fY) && xRadius == yRadius ) {
1035 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircle VertexAttribs)); 1035 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircle VertexAttribs),
1036 SkASSERT(sizeof(CircleVertex) == drawState->getVertexSize()); 1036 sizeof(CircleVertex));
1037 1037
1038 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); 1038 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0);
1039 if (!geo.succeeded()) { 1039 if (!geo.succeeded()) {
1040 GrPrintf("Failed to get space for vertices!\n"); 1040 GrPrintf("Failed to get space for vertices!\n");
1041 return false; 1041 return false;
1042 } 1042 }
1043 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); 1043 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices());
1044 1044
1045 SkScalar innerRadius = 0.0f; 1045 SkScalar innerRadius = 0.0f;
1046 SkScalar outerRadius = xRadius; 1046 SkScalar outerRadius = xRadius;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 } 1114 }
1115 1115
1116 // drop out the middle quad if we're stroked 1116 // drop out the middle quad if we're stroked
1117 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1117 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1118 SK_ARRAY_COUNT(gRRectIndices); 1118 SK_ARRAY_COUNT(gRRectIndices);
1119 target->setIndexSourceToBuffer(indexBuffer); 1119 target->setIndexSourceToBuffer(indexBuffer);
1120 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds); 1120 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds);
1121 1121
1122 // otherwise we use the ellipse renderer 1122 // otherwise we use the ellipse renderer
1123 } else { 1123 } else {
1124 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllip seVertexAttribs)); 1124 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllip seVertexAttribs),
1125 SkASSERT(sizeof(EllipseVertex) == drawState->getVertexSize()); 1125 sizeof(EllipseVertex) );
1126 1126
1127 SkScalar innerXRadius = 0.0f; 1127 SkScalar innerXRadius = 0.0f;
1128 SkScalar innerYRadius = 0.0f; 1128 SkScalar innerYRadius = 0.0f;
1129 if (hasStroke) { 1129 if (hasStroke) {
1130 if (SkScalarNearlyZero(scaledStroke.length())) { 1130 if (SkScalarNearlyZero(scaledStroke.length())) {
1131 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); 1131 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf);
1132 } else { 1132 } else {
1133 scaledStroke.scale(SK_ScalarHalf); 1133 scaledStroke.scale(SK_ScalarHalf);
1134 } 1134 }
1135 1135
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 1225
1226 // drop out the middle quad if we're stroked 1226 // drop out the middle quad if we're stroked
1227 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : 1227 int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
1228 SK_ARRAY_COUNT(gRRectIndices); 1228 SK_ARRAY_COUNT(gRRectIndices);
1229 target->setIndexSourceToBuffer(indexBuffer); 1229 target->setIndexSourceToBuffer(indexBuffer);
1230 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds); 1230 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds);
1231 } 1231 }
1232 1232
1233 return true; 1233 return true;
1234 } 1234 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrRODrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698