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 #ifndef SkMatrix_DEFINED | 10 #ifndef SkMatrix_DEFINED |
11 #define SkMatrix_DEFINED | 11 #define SkMatrix_DEFINED |
12 | 12 |
13 #include "SkDynamicAnnotations.h" | |
14 #include "SkRect.h" | 13 #include "SkRect.h" |
15 | 14 |
16 class SkString; | 15 class SkString; |
17 | 16 |
18 // TODO: can we remove these 3 (need to check chrome/android) | 17 // TODO: can we remove these 3 (need to check chrome/android) |
19 typedef SkScalar SkPersp; | 18 typedef SkScalar SkPersp; |
20 #define SkScalarToPersp(x) (x) | 19 #define SkScalarToPersp(x) (x) |
21 #define SkPerspToScalar(x) (x) | 20 #define SkPerspToScalar(x) (x) |
22 | 21 |
23 /** \class SkMatrix | 22 /** \class SkMatrix |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 kPerspective_Mask, | 636 kPerspective_Mask, |
638 | 637 |
639 kAllMasks = kTranslate_Mask | | 638 kAllMasks = kTranslate_Mask | |
640 kScale_Mask | | 639 kScale_Mask | |
641 kAffine_Mask | | 640 kAffine_Mask | |
642 kPerspective_Mask | | 641 kPerspective_Mask | |
643 kRectStaysRect_Mask | 642 kRectStaysRect_Mask |
644 }; | 643 }; |
645 | 644 |
646 SkScalar fMat[9]; | 645 SkScalar fMat[9]; |
647 mutable SkTRacy<uint32_t> fTypeMask; | 646 mutable uint32_t fTypeMask; |
648 | 647 |
649 uint8_t computeTypeMask() const; | 648 uint8_t computeTypeMask() const; |
650 uint8_t computePerspectiveTypeMask() const; | 649 uint8_t computePerspectiveTypeMask() const; |
651 | 650 |
652 void setTypeMask(int mask) { | 651 void setTypeMask(int mask) { |
653 // allow kUnknown or a valid mask | 652 // allow kUnknown or a valid mask |
654 SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask || | 653 SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask || |
655 ((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask) | 654 ((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask) |
656 == (kUnknown_Mask | kOnlyPerspectiveValid_Mask)); | 655 == (kUnknown_Mask | kOnlyPerspectiveValid_Mask)); |
657 fTypeMask = SkToU8(mask); | 656 fTypeMask = SkToU8(mask); |
658 } | 657 } |
659 | 658 |
660 void orTypeMask(int mask) { | 659 void orTypeMask(int mask) { |
661 SkASSERT((mask & kORableMasks) == mask); | 660 SkASSERT((mask & kORableMasks) == mask); |
662 fTypeMask = SkToU8(fTypeMask | mask); | 661 fTypeMask = SkToU8(fTypeMask | mask); |
663 } | 662 } |
664 | 663 |
665 void clearTypeMask(int mask) { | 664 void clearTypeMask(int mask) { |
666 // only allow a valid mask | 665 // only allow a valid mask |
667 SkASSERT((mask & kAllMasks) == mask); | 666 SkASSERT((mask & kAllMasks) == mask); |
668 fTypeMask = fTypeMask & ~mask; | 667 fTypeMask &= ~mask; |
669 } | 668 } |
670 | 669 |
671 TypeMask getPerspectiveTypeMaskOnly() const { | 670 TypeMask getPerspectiveTypeMaskOnly() const { |
672 if ((fTypeMask & kUnknown_Mask) && | 671 if ((fTypeMask & kUnknown_Mask) && |
673 !(fTypeMask & kOnlyPerspectiveValid_Mask)) { | 672 !(fTypeMask & kOnlyPerspectiveValid_Mask)) { |
674 fTypeMask = this->computePerspectiveTypeMask(); | 673 fTypeMask = this->computePerspectiveTypeMask(); |
675 } | 674 } |
676 return (TypeMask)(fTypeMask & 0xF); | 675 return (TypeMask)(fTypeMask & 0xF); |
677 } | 676 } |
678 | 677 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 static void RotTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], | 710 static void RotTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], |
712 int count); | 711 int count); |
713 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int); | 712 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int); |
714 | 713 |
715 static const MapPtsProc gMapPtsProcs[]; | 714 static const MapPtsProc gMapPtsProcs[]; |
716 | 715 |
717 friend class SkPerspIter; | 716 friend class SkPerspIter; |
718 }; | 717 }; |
719 | 718 |
720 #endif | 719 #endif |
OLD | NEW |