OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 | 9 |
10 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 | 742 |
743 SkPathRef::Editor ed(&fPathRef); | 743 SkPathRef::Editor ed(&fPathRef); |
744 ed.growForVerb(kLine_Verb)->set(x, y); | 744 ed.growForVerb(kLine_Verb)->set(x, y); |
745 fSegmentMask |= kLine_SegmentMask; | 745 fSegmentMask |= kLine_SegmentMask; |
746 | 746 |
747 GEN_ID_INC; | 747 GEN_ID_INC; |
748 DIRTY_AFTER_EDIT; | 748 DIRTY_AFTER_EDIT; |
749 } | 749 } |
750 | 750 |
751 void SkPath::rLineTo(SkScalar x, SkScalar y) { | 751 void SkPath::rLineTo(SkScalar x, SkScalar y) { |
| 752 this->injectMoveToIfNeeded(); // This can change the result of this->getLas
tPt(). |
752 SkPoint pt; | 753 SkPoint pt; |
753 this->getLastPt(&pt); | 754 this->getLastPt(&pt); |
754 this->lineTo(pt.fX + x, pt.fY + y); | 755 this->lineTo(pt.fX + x, pt.fY + y); |
755 } | 756 } |
756 | 757 |
757 void SkPath::quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { | 758 void SkPath::quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { |
758 SkDEBUGCODE(this->validate();) | 759 SkDEBUGCODE(this->validate();) |
759 | 760 |
760 this->injectMoveToIfNeeded(); | 761 this->injectMoveToIfNeeded(); |
761 | 762 |
762 SkPathRef::Editor ed(&fPathRef); | 763 SkPathRef::Editor ed(&fPathRef); |
763 SkPoint* pts = ed.growForVerb(kQuad_Verb); | 764 SkPoint* pts = ed.growForVerb(kQuad_Verb); |
764 pts[0].set(x1, y1); | 765 pts[0].set(x1, y1); |
765 pts[1].set(x2, y2); | 766 pts[1].set(x2, y2); |
766 fSegmentMask |= kQuad_SegmentMask; | 767 fSegmentMask |= kQuad_SegmentMask; |
767 | 768 |
768 GEN_ID_INC; | 769 GEN_ID_INC; |
769 DIRTY_AFTER_EDIT; | 770 DIRTY_AFTER_EDIT; |
770 } | 771 } |
771 | 772 |
772 void SkPath::rQuadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { | 773 void SkPath::rQuadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { |
| 774 this->injectMoveToIfNeeded(); // This can change the result of this->getLas
tPt(). |
773 SkPoint pt; | 775 SkPoint pt; |
774 this->getLastPt(&pt); | 776 this->getLastPt(&pt); |
775 this->quadTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2); | 777 this->quadTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2); |
776 } | 778 } |
777 | 779 |
778 void SkPath::conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, | 780 void SkPath::conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, |
779 SkScalar w) { | 781 SkScalar w) { |
780 // check for <= 0 or NaN with this test | 782 // check for <= 0 or NaN with this test |
781 if (!(w > 0)) { | 783 if (!(w > 0)) { |
782 this->lineTo(x2, y2); | 784 this->lineTo(x2, y2); |
(...skipping 13 matching lines...) Expand all Loading... |
796 pts[1].set(x2, y2); | 798 pts[1].set(x2, y2); |
797 fSegmentMask |= kConic_SegmentMask; | 799 fSegmentMask |= kConic_SegmentMask; |
798 | 800 |
799 GEN_ID_INC; | 801 GEN_ID_INC; |
800 DIRTY_AFTER_EDIT; | 802 DIRTY_AFTER_EDIT; |
801 } | 803 } |
802 } | 804 } |
803 | 805 |
804 void SkPath::rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, | 806 void SkPath::rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, |
805 SkScalar w) { | 807 SkScalar w) { |
| 808 this->injectMoveToIfNeeded(); // This can change the result of this->getLas
tPt(). |
806 SkPoint pt; | 809 SkPoint pt; |
807 this->getLastPt(&pt); | 810 this->getLastPt(&pt); |
808 this->conicTo(pt.fX + dx1, pt.fY + dy1, pt.fX + dx2, pt.fY + dy2, w); | 811 this->conicTo(pt.fX + dx1, pt.fY + dy1, pt.fX + dx2, pt.fY + dy2, w); |
809 } | 812 } |
810 | 813 |
811 void SkPath::cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, | 814 void SkPath::cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, |
812 SkScalar x3, SkScalar y3) { | 815 SkScalar x3, SkScalar y3) { |
813 SkDEBUGCODE(this->validate();) | 816 SkDEBUGCODE(this->validate();) |
814 | 817 |
815 this->injectMoveToIfNeeded(); | 818 this->injectMoveToIfNeeded(); |
816 | 819 |
817 SkPathRef::Editor ed(&fPathRef); | 820 SkPathRef::Editor ed(&fPathRef); |
818 SkPoint* pts = ed.growForVerb(kCubic_Verb); | 821 SkPoint* pts = ed.growForVerb(kCubic_Verb); |
819 pts[0].set(x1, y1); | 822 pts[0].set(x1, y1); |
820 pts[1].set(x2, y2); | 823 pts[1].set(x2, y2); |
821 pts[2].set(x3, y3); | 824 pts[2].set(x3, y3); |
822 fSegmentMask |= kCubic_SegmentMask; | 825 fSegmentMask |= kCubic_SegmentMask; |
823 | 826 |
824 GEN_ID_INC; | 827 GEN_ID_INC; |
825 DIRTY_AFTER_EDIT; | 828 DIRTY_AFTER_EDIT; |
826 } | 829 } |
827 | 830 |
828 void SkPath::rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, | 831 void SkPath::rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, |
829 SkScalar x3, SkScalar y3) { | 832 SkScalar x3, SkScalar y3) { |
| 833 this->injectMoveToIfNeeded(); // This can change the result of this->getLas
tPt(). |
830 SkPoint pt; | 834 SkPoint pt; |
831 this->getLastPt(&pt); | 835 this->getLastPt(&pt); |
832 this->cubicTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2, | 836 this->cubicTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2, |
833 pt.fX + x3, pt.fY + y3); | 837 pt.fX + x3, pt.fY + y3); |
834 } | 838 } |
835 | 839 |
836 void SkPath::close() { | 840 void SkPath::close() { |
837 SkDEBUGCODE(this->validate();) | 841 SkDEBUGCODE(this->validate();) |
838 | 842 |
839 int count = fPathRef->countVerbs(); | 843 int count = fPathRef->countVerbs(); |
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3000 switch (this->getFillType()) { | 3004 switch (this->getFillType()) { |
3001 case SkPath::kEvenOdd_FillType: | 3005 case SkPath::kEvenOdd_FillType: |
3002 case SkPath::kInverseEvenOdd_FillType: | 3006 case SkPath::kInverseEvenOdd_FillType: |
3003 w &= 1; | 3007 w &= 1; |
3004 break; | 3008 break; |
3005 default: | 3009 default: |
3006 break; | 3010 break; |
3007 } | 3011 } |
3008 return SkToBool(w); | 3012 return SkToBool(w); |
3009 } | 3013 } |
OLD | NEW |