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