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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 GrEffectRef* QuadEdgeEffect::TestCreate(SkRandom* random, | 598 GrEffectRef* QuadEdgeEffect::TestCreate(SkRandom* random, |
599 GrContext*, | 599 GrContext*, |
600 const GrDrawTargetCaps& caps, | 600 const GrDrawTargetCaps& caps, |
601 GrTexture*[]) { | 601 GrTexture*[]) { |
602 // Doesn't work without derivative instructions. | 602 // Doesn't work without derivative instructions. |
603 return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL; | 603 return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL; |
604 } | 604 } |
605 | 605 |
606 /////////////////////////////////////////////////////////////////////////////// | 606 /////////////////////////////////////////////////////////////////////////////// |
607 | 607 |
608 bool GrAAConvexPathRenderer::canDrawPath(const SkPath& path, | 608 bool GrAAConvexPathRenderer::canDrawPath(const SkStrokeRec& stroke, |
609 const SkStrokeRec& stroke, | |
610 const GrDrawTarget* target, | 609 const GrDrawTarget* target, |
611 bool antiAlias) const { | 610 bool antiAlias) const { |
612 return (target->caps()->shaderDerivativeSupport() && antiAlias && | 611 return (target->caps()->shaderDerivativeSupport() && antiAlias && |
613 stroke.isFillStyle() && !path.isInverseFillType() && path.isConvex()
); | 612 stroke.isFillStyle() && !this->path().isInverseFillType() && this->p
ath().isConvex()); |
614 } | 613 } |
615 | 614 |
616 namespace { | 615 namespace { |
617 | 616 |
618 // position + edge | 617 // position + edge |
619 extern const GrVertexAttrib gPathAttribs[] = { | 618 extern const GrVertexAttrib gPathAttribs[] = { |
620 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | 619 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, |
621 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} | 620 {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} |
622 }; | 621 }; |
623 | 622 |
624 }; | 623 }; |
625 | 624 |
626 bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, | 625 bool GrAAConvexPathRenderer::onDrawPath(const SkStrokeRec&, |
627 const SkStrokeRec&, | |
628 GrDrawTarget* target, | 626 GrDrawTarget* target, |
629 bool antiAlias) { | 627 bool antiAlias) { |
630 | 628 |
631 const SkPath* path = &origPath; | 629 const SkPath* path = &this->path(); |
632 if (path->isEmpty()) { | 630 if (path->isEmpty()) { |
633 return true; | 631 return true; |
634 } | 632 } |
635 | 633 |
636 SkMatrix viewMatrix = target->getDrawState().getViewMatrix(); | 634 SkMatrix viewMatrix = target->getDrawState().getViewMatrix(); |
637 GrDrawTarget::AutoStateRestore asr; | 635 GrDrawTarget::AutoStateRestore asr; |
638 if (!asr.setIdentity(target, GrDrawTarget::kPreserve_ASRInit)) { | 636 if (!asr.setIdentity(target, GrDrawTarget::kPreserve_ASRInit)) { |
639 return false; | 637 return false; |
640 } | 638 } |
641 GrDrawState* drawState = target->drawState(); | 639 GrDrawState* drawState = target->drawState(); |
642 | 640 |
643 // We use the fact that SkPath::transform path does subdivision based on | 641 // We use the fact that SkPath::transform path does subdivision based on |
644 // perspective. Otherwise, we apply the view matrix when copying to the | 642 // perspective. Otherwise, we apply the view matrix when copying to the |
645 // segment representation. | 643 // segment representation. |
646 SkPath tmpPath; | 644 SkPath tmpPath; |
647 if (viewMatrix.hasPerspective()) { | 645 if (viewMatrix.hasPerspective()) { |
648 origPath.transform(viewMatrix, &tmpPath); | 646 this->path().transform(viewMatrix, &tmpPath); |
649 path = &tmpPath; | 647 path = &tmpPath; |
650 viewMatrix = SkMatrix::I(); | 648 viewMatrix = SkMatrix::I(); |
651 } | 649 } |
652 | 650 |
653 QuadVertex *verts; | 651 QuadVertex *verts; |
654 uint16_t* idxs; | 652 uint16_t* idxs; |
655 | 653 |
656 int vCount; | 654 int vCount; |
657 int iCount; | 655 int iCount; |
658 enum { | 656 enum { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 vOffset, // start vertex | 706 vOffset, // start vertex |
709 0, // start index | 707 0, // start index |
710 draw.fVertexCnt, | 708 draw.fVertexCnt, |
711 draw.fIndexCnt, | 709 draw.fIndexCnt, |
712 &devBounds); | 710 &devBounds); |
713 vOffset += draw.fVertexCnt; | 711 vOffset += draw.fVertexCnt; |
714 } | 712 } |
715 | 713 |
716 return true; | 714 return true; |
717 } | 715 } |
OLD | NEW |