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 "SkBuffer.h" | 8 #include "SkBuffer.h" |
9 #include "SkOnce.h" | 9 #include "SkOnce.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 fPts = srcPts; | 670 fPts = srcPts; |
671 return (uint8_t) verb; | 671 return (uint8_t) verb; |
672 } | 672 } |
673 | 673 |
674 uint8_t SkPathRef::Iter::peek() const { | 674 uint8_t SkPathRef::Iter::peek() const { |
675 const uint8_t* next = fVerbs - 1; | 675 const uint8_t* next = fVerbs - 1; |
676 return next <= fVerbStop ? (uint8_t) SkPath::kDone_Verb : *next; | 676 return next <= fVerbStop ? (uint8_t) SkPath::kDone_Verb : *next; |
677 } | 677 } |
678 | 678 |
679 #ifdef SK_DEBUG | 679 #ifdef SK_DEBUG |
| 680 |
| 681 #include "SkNx.h" |
| 682 |
680 void SkPathRef::validate() const { | 683 void SkPathRef::validate() const { |
681 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); | 684 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); |
682 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPo
ints) >= 0); | 685 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPo
ints) >= 0); |
683 SkASSERT((nullptr == fPoints) == (nullptr == fVerbs)); | 686 SkASSERT((nullptr == fPoints) == (nullptr == fVerbs)); |
684 SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace)); | 687 SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace)); |
685 SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace)); | 688 SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace)); |
686 SkASSERT(!(nullptr == fPoints && fPointCnt)); | 689 SkASSERT(!(nullptr == fPoints && fPointCnt)); |
687 SkASSERT(!(nullptr == fVerbs && fVerbCnt)); | 690 SkASSERT(!(nullptr == fVerbs && fVerbCnt)); |
688 SkASSERT(this->currSize() == | 691 SkASSERT(this->currSize() == |
689 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVe
rbCnt); | 692 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVe
rbCnt); |
690 | 693 |
691 if (fIsOval || fIsRRect) { | 694 if (fIsOval || fIsRRect) { |
692 // Currently we don't allow both of these to be set, even though ovals a
re round rects. | 695 // Currently we don't allow both of these to be set, even though ovals a
re round rects. |
693 SkASSERT(fIsOval != fIsRRect); | 696 SkASSERT(fIsOval != fIsRRect); |
694 if (fIsOval) { | 697 if (fIsOval) { |
695 SkASSERT(fRRectOrOvalStartIdx < 4); | 698 SkASSERT(fRRectOrOvalStartIdx < 4); |
696 } else { | 699 } else { |
697 SkASSERT(fRRectOrOvalStartIdx < 8); | 700 SkASSERT(fRRectOrOvalStartIdx < 8); |
698 } | 701 } |
699 } | 702 } |
700 | 703 |
701 if (!fBoundsIsDirty && !fBounds.isEmpty()) { | 704 if (!fBoundsIsDirty && !fBounds.isEmpty()) { |
702 bool isFinite = true; | 705 bool isFinite = true; |
| 706 Sk2s leftTop = Sk2s(fBounds.fLeft, fBounds.fTop); |
| 707 Sk2s rightBot = Sk2s(fBounds.fRight, fBounds.fBottom); |
703 for (int i = 0; i < fPointCnt; ++i) { | 708 for (int i = 0; i < fPointCnt; ++i) { |
| 709 Sk2s point = Sk2s(fPoints[i].fX, fPoints[i].fY); |
704 #ifdef SK_DEBUG | 710 #ifdef SK_DEBUG |
705 if (fPoints[i].isFinite() && | 711 if (fPoints[i].isFinite() && |
706 (fPoints[i].fX < fBounds.fLeft || fPoints[i].fX > fBounds.fRight
|| | 712 ((point < leftTop).anyTrue() || (point > rightBot).anyTrue())) { |
707 fPoints[i].fY < fBounds.fTop || fPoints[i].fY > fBounds.fBottom
)) { | |
708 SkDebugf("bounds: %f %f %f %f\n", | 713 SkDebugf("bounds: %f %f %f %f\n", |
709 fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fB
ottom); | 714 fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fB
ottom); |
710 for (int j = 0; j < fPointCnt; ++j) { | 715 for (int j = 0; j < fPointCnt; ++j) { |
711 if (i == j) { | 716 if (i == j) { |
712 SkDebugf("*"); | 717 SkDebugf("*"); |
713 } | 718 } |
714 SkDebugf("%f %f\n", fPoints[j].fX, fPoints[j].fY); | 719 SkDebugf("%f %f\n", fPoints[j].fX, fPoints[j].fY); |
715 } | 720 } |
716 } | 721 } |
717 #endif | 722 #endif |
718 | 723 |
719 SkASSERT(!fPoints[i].isFinite() || | 724 SkASSERT(!fPoints[i].isFinite() || |
720 » » (fPoints[i].fX >= fBounds.fLeft && fPoints[i].fX <= fBounds
.fRight && | 725 (!(point < leftTop).anyTrue() && !(point > rightBot).anyTrue
())); |
721 » » fPoints[i].fY >= fBounds.fTop && fPoints[i].fY <= fBounds.
fBottom)); | |
722 if (!fPoints[i].isFinite()) { | 726 if (!fPoints[i].isFinite()) { |
723 isFinite = false; | 727 isFinite = false; |
724 } | 728 } |
725 } | 729 } |
726 SkASSERT(SkToBool(fIsFinite) == isFinite); | 730 SkASSERT(SkToBool(fIsFinite) == isFinite); |
727 } | 731 } |
728 | 732 |
729 #ifdef SK_DEBUG_PATH | 733 #ifdef SK_DEBUG_PATH |
730 uint32_t mask = 0; | 734 uint32_t mask = 0; |
731 for (int i = 0; i < fVerbCnt; ++i) { | 735 for (int i = 0; i < fVerbCnt; ++i) { |
(...skipping 19 matching lines...) Expand all Loading... |
751 break; | 755 break; |
752 default: | 756 default: |
753 SkDEBUGFAIL("Unknown Verb"); | 757 SkDEBUGFAIL("Unknown Verb"); |
754 break; | 758 break; |
755 } | 759 } |
756 } | 760 } |
757 SkASSERT(mask == fSegmentMask); | 761 SkASSERT(mask == fSegmentMask); |
758 #endif // SK_DEBUG_PATH | 762 #endif // SK_DEBUG_PATH |
759 } | 763 } |
760 #endif | 764 #endif |
OLD | NEW |