OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 | 10 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 /////////////////////////////////////////////////////////////////////////////// | 551 /////////////////////////////////////////////////////////////////////////////// |
552 | 552 |
553 bool GrAAConvexPathRenderer::canDrawPath(const SkPath& path, | 553 bool GrAAConvexPathRenderer::canDrawPath(const SkPath& path, |
554 const SkStrokeRec& stroke, | 554 const SkStrokeRec& stroke, |
555 const GrDrawTarget* target, | 555 const GrDrawTarget* target, |
556 bool antiAlias) const { | 556 bool antiAlias) const { |
557 return (target->caps()->shaderDerivativeSupport() && antiAlias && | 557 return (target->caps()->shaderDerivativeSupport() && antiAlias && |
558 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex()
); | 558 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex()
); |
559 } | 559 } |
560 | 560 |
| 561 namespace { |
| 562 |
| 563 // position + edge |
| 564 extern const GrVertexAttrib gPathAttribs[] = { |
| 565 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, |
| 566 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} |
| 567 }; |
| 568 |
| 569 }; |
| 570 |
561 bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, | 571 bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, |
562 const SkStrokeRec&, | 572 const SkStrokeRec&, |
563 GrDrawTarget* target, | 573 GrDrawTarget* target, |
564 bool antiAlias) { | 574 bool antiAlias) { |
565 | 575 |
566 const SkPath* path = &origPath; | 576 const SkPath* path = &origPath; |
567 if (path->isEmpty()) { | 577 if (path->isEmpty()) { |
568 return true; | 578 return true; |
569 } | 579 } |
570 | 580 |
(...skipping 24 matching lines...) Expand all Loading... |
595 enum { | 605 enum { |
596 kPreallocSegmentCnt = 512 / sizeof(Segment), | 606 kPreallocSegmentCnt = 512 / sizeof(Segment), |
597 }; | 607 }; |
598 SkSTArray<kPreallocSegmentCnt, Segment, true> segments; | 608 SkSTArray<kPreallocSegmentCnt, Segment, true> segments; |
599 SkPoint fanPt; | 609 SkPoint fanPt; |
600 | 610 |
601 if (!get_segments(*path, *vm, &segments, &fanPt, &vCount, &iCount)) { | 611 if (!get_segments(*path, *vm, &segments, &fanPt, &vCount, &iCount)) { |
602 return false; | 612 return false; |
603 } | 613 } |
604 | 614 |
605 // position + edge | 615 drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs)); |
606 static const GrVertexAttrib kAttribs[] = { | |
607 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBin
ding}, | |
608 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBindi
ng} | |
609 }; | |
610 drawState->setVertexAttribs(kAttribs, SK_ARRAY_COUNT(kAttribs)); | |
611 | 616 |
612 enum { | 617 enum { |
613 // the edge effects share this stage with glyph rendering | 618 // the edge effects share this stage with glyph rendering |
614 // (kGlyphMaskStage in GrTextContext) && SW path rendering | 619 // (kGlyphMaskStage in GrTextContext) && SW path rendering |
615 // (kPathMaskStage in GrSWMaskHelper) | 620 // (kPathMaskStage in GrSWMaskHelper) |
616 kEdgeEffectStage = GrPaint::kTotalStages, | 621 kEdgeEffectStage = GrPaint::kTotalStages, |
617 }; | 622 }; |
618 static const int kEdgeAttrIndex = 1; | 623 static const int kEdgeAttrIndex = 1; |
619 GrEffectRef* quadEffect = QuadEdgeEffect::Create(); | 624 GrEffectRef* quadEffect = QuadEdgeEffect::Create(); |
620 drawState->setEffect(kEdgeEffectStage, quadEffect, kEdgeAttrIndex)->unref(); | 625 drawState->setEffect(kEdgeEffectStage, quadEffect, kEdgeAttrIndex)->unref(); |
621 | 626 |
622 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); | 627 GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount); |
623 if (!arg.succeeded()) { | 628 if (!arg.succeeded()) { |
624 return false; | 629 return false; |
625 } | 630 } |
626 GrAssert(sizeof(QuadVertex) == drawState->getVertexSize()); | 631 GrAssert(sizeof(QuadVertex) == drawState->getVertexSize()); |
627 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); | 632 verts = reinterpret_cast<QuadVertex*>(arg.vertices()); |
628 idxs = reinterpret_cast<uint16_t*>(arg.indices()); | 633 idxs = reinterpret_cast<uint16_t*>(arg.indices()); |
629 | 634 |
630 create_vertices(segments, fanPt, verts, idxs); | 635 create_vertices(segments, fanPt, verts, idxs); |
631 | 636 |
632 target->drawIndexed(kTriangles_GrPrimitiveType, | 637 target->drawIndexed(kTriangles_GrPrimitiveType, |
633 0, // start vertex | 638 0, // start vertex |
634 0, // start index | 639 0, // start index |
635 vCount, | 640 vCount, |
636 iCount); | 641 iCount); |
637 | 642 |
638 return true; | 643 return true; |
639 } | 644 } |
OLD | NEW |