OLD | NEW |
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 "GrEffect.h" | 10 #include "GrEffect.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 vm.mapPoints(¢er, 1); | 339 vm.mapPoints(¢er, 1); |
340 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); | 340 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); |
341 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); | 341 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); |
342 | 342 |
343 GrDrawState::AutoViewMatrixRestore avmr; | 343 GrDrawState::AutoViewMatrixRestore avmr; |
344 if (!avmr.setIdentity(drawState)) { | 344 if (!avmr.setIdentity(drawState)) { |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert
exAttribs)); | 348 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert
exAttribs)); |
349 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); | 349 SkASSERT(sizeof(CircleVertex) == drawState->getVertexSize()); |
350 | 350 |
351 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 351 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
352 if (!geo.succeeded()) { | 352 if (!geo.succeeded()) { |
353 GrPrintf("Failed to get space for vertices!\n"); | 353 GrPrintf("Failed to get space for vertices!\n"); |
354 return; | 354 return; |
355 } | 355 } |
356 | 356 |
357 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); | 357 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); |
358 | 358 |
359 SkStrokeRec::Style style = stroke.getStyle(); | 359 SkStrokeRec::Style style = stroke.getStyle(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 xRadius += scaledStroke.fX; | 495 xRadius += scaledStroke.fX; |
496 yRadius += scaledStroke.fY; | 496 yRadius += scaledStroke.fY; |
497 } | 497 } |
498 | 498 |
499 GrDrawState::AutoViewMatrixRestore avmr; | 499 GrDrawState::AutoViewMatrixRestore avmr; |
500 if (!avmr.setIdentity(drawState)) { | 500 if (!avmr.setIdentity(drawState)) { |
501 return false; | 501 return false; |
502 } | 502 } |
503 | 503 |
504 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe
rtexAttribs)); | 504 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe
rtexAttribs)); |
505 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize()); | 505 SkASSERT(sizeof(EllipseVertex) == drawState->getVertexSize()); |
506 | 506 |
507 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 507 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
508 if (!geo.succeeded()) { | 508 if (!geo.succeeded()) { |
509 GrPrintf("Failed to get space for vertices!\n"); | 509 GrPrintf("Failed to get space for vertices!\n"); |
510 return false; | 510 return false; |
511 } | 511 } |
512 | 512 |
513 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); | 513 EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices()); |
514 | 514 |
515 GrEffectRef* effect = EllipseEdgeEffect::Create(isStroked); | 515 GrEffectRef* effect = EllipseEdgeEffect::Create(isStroked); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 655 |
656 GrIndexBuffer* indexBuffer = this->rRectIndexBuffer(context->getGpu()); | 656 GrIndexBuffer* indexBuffer = this->rRectIndexBuffer(context->getGpu()); |
657 if (NULL == indexBuffer) { | 657 if (NULL == indexBuffer) { |
658 GrPrintf("Failed to create index buffer!\n"); | 658 GrPrintf("Failed to create index buffer!\n"); |
659 return false; | 659 return false; |
660 } | 660 } |
661 | 661 |
662 // if the corners are circles, use the circle renderer | 662 // if the corners are circles, use the circle renderer |
663 if ((!isStroked || scaledStroke.fX == scaledStroke.fY) && xRadius == yRadius
) { | 663 if ((!isStroked || scaledStroke.fX == scaledStroke.fY) && xRadius == yRadius
) { |
664 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircle
VertexAttribs)); | 664 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircle
VertexAttribs)); |
665 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); | 665 SkASSERT(sizeof(CircleVertex) == drawState->getVertexSize()); |
666 | 666 |
667 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); | 667 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); |
668 if (!geo.succeeded()) { | 668 if (!geo.succeeded()) { |
669 GrPrintf("Failed to get space for vertices!\n"); | 669 GrPrintf("Failed to get space for vertices!\n"); |
670 return false; | 670 return false; |
671 } | 671 } |
672 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); | 672 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); |
673 | 673 |
674 SkScalar innerRadius = 0.0f; | 674 SkScalar innerRadius = 0.0f; |
675 SkScalar outerRadius = xRadius; | 675 SkScalar outerRadius = xRadius; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 } | 742 } |
743 | 743 |
744 // drop out the middle quad if we're stroked | 744 // drop out the middle quad if we're stroked |
745 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); | 745 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); |
746 target->setIndexSourceToBuffer(indexBuffer); | 746 target->setIndexSourceToBuffer(indexBuffer); |
747 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); | 747 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); |
748 | 748 |
749 // otherwise we use the ellipse renderer | 749 // otherwise we use the ellipse renderer |
750 } else { | 750 } else { |
751 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllip
seVertexAttribs)); | 751 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllip
seVertexAttribs)); |
752 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize()); | 752 SkASSERT(sizeof(EllipseVertex) == drawState->getVertexSize()); |
753 | 753 |
754 SkScalar innerXRadius = 0.0f; | 754 SkScalar innerXRadius = 0.0f; |
755 SkScalar innerYRadius = 0.0f; | 755 SkScalar innerYRadius = 0.0f; |
756 if (SkStrokeRec::kFill_Style != style) { | 756 if (SkStrokeRec::kFill_Style != style) { |
757 if (SkScalarNearlyZero(scaledStroke.length())) { | 757 if (SkScalarNearlyZero(scaledStroke.length())) { |
758 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); | 758 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf); |
759 } else { | 759 } else { |
760 scaledStroke.scale(SK_ScalarHalf); | 760 scaledStroke.scale(SK_ScalarHalf); |
761 } | 761 } |
762 | 762 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 } | 850 } |
851 | 851 |
852 // drop out the middle quad if we're stroked | 852 // drop out the middle quad if we're stroked |
853 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); | 853 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); |
854 target->setIndexSourceToBuffer(indexBuffer); | 854 target->setIndexSourceToBuffer(indexBuffer); |
855 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); | 855 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); |
856 } | 856 } |
857 | 857 |
858 return true; | 858 return true; |
859 } | 859 } |
OLD | NEW |