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 "SkRect.h" | 13 #include "SkRect.h" |
14 | 14 |
15 class SkString; | 15 class SkString; |
16 | 16 |
17 #ifdef SK_SCALAR_IS_FLOAT | 17 // TODO: can we remove these 3 (need to check chrome/android) |
18 typedef SkScalar SkPersp; | 18 typedef SkScalar SkPersp; |
19 #define SkScalarToPersp(x) (x) | 19 #define SkScalarToPersp(x) (x) |
20 #define SkPerspToScalar(x) (x) | 20 #define SkPerspToScalar(x) (x) |
21 #else | |
22 typedef SkFract SkPersp; | |
23 #define SkScalarToPersp(x) SkFixedToFract(x) | |
24 #define SkPerspToScalar(x) SkFractToFixed(x) | |
25 #endif | |
26 | 21 |
27 /** \class SkMatrix | 22 /** \class SkMatrix |
28 | 23 |
29 The SkMatrix class holds a 3x3 matrix for transforming coordinates. | 24 The SkMatrix class holds a 3x3 matrix for transforming coordinates. |
30 SkMatrix does not have a constructor, so it must be explicitly initialized | 25 SkMatrix does not have a constructor, so it must be explicitly initialized |
31 using either reset() - to construct an identity matrix, or one of the set | 26 using either reset() - to construct an identity matrix, or one of the set |
32 functions (e.g. setTranslate, setRotate, etc.). | 27 functions (e.g. setTranslate, setRotate, etc.). |
33 */ | 28 */ |
34 class SK_API SkMatrix { | 29 class SK_API SkMatrix { |
35 public: | 30 public: |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 * only difference between the two matrices. It considers NaN values to be | 531 * only difference between the two matrices. It considers NaN values to be |
537 * equal to themselves. So a matrix full of NaNs is "cheap equal" to | 532 * equal to themselves. So a matrix full of NaNs is "cheap equal" to |
538 * another matrix full of NaNs iff the NaN values are bitwise identical | 533 * another matrix full of NaNs iff the NaN values are bitwise identical |
539 * while according to strict the strict == test a matrix with a NaN value | 534 * while according to strict the strict == test a matrix with a NaN value |
540 * is equal to nothing, including itself. | 535 * is equal to nothing, including itself. |
541 */ | 536 */ |
542 bool cheapEqualTo(const SkMatrix& m) const { | 537 bool cheapEqualTo(const SkMatrix& m) const { |
543 return 0 == memcmp(fMat, m.fMat, sizeof(fMat)); | 538 return 0 == memcmp(fMat, m.fMat, sizeof(fMat)); |
544 } | 539 } |
545 | 540 |
546 #ifdef SK_SCALAR_IS_FIXED | |
547 friend bool operator==(const SkMatrix& a, const SkMatrix& b) { | |
548 return a.cheapEqualTo(b); | |
549 } | |
550 #else | |
551 friend bool operator==(const SkMatrix& a, const SkMatrix& b); | 541 friend bool operator==(const SkMatrix& a, const SkMatrix& b); |
552 #endif | |
553 friend bool operator!=(const SkMatrix& a, const SkMatrix& b) { | 542 friend bool operator!=(const SkMatrix& a, const SkMatrix& b) { |
554 return !(a == b); | 543 return !(a == b); |
555 } | 544 } |
556 | 545 |
557 enum { | 546 enum { |
558 // writeTo/readFromMemory will never return a value larger than this | 547 // writeTo/readFromMemory will never return a value larger than this |
559 kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t) | 548 kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t) |
560 }; | 549 }; |
561 // return the number of bytes written, whether or not buffer is null | 550 // return the number of bytes written, whether or not buffer is null |
562 size_t writeToMemory(void* buffer) const; | 551 size_t writeToMemory(void* buffer) const; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 static void RotTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], | 694 static void RotTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], |
706 int count); | 695 int count); |
707 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int); | 696 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int); |
708 | 697 |
709 static const MapPtsProc gMapPtsProcs[]; | 698 static const MapPtsProc gMapPtsProcs[]; |
710 | 699 |
711 friend class SkPerspIter; | 700 friend class SkPerspIter; |
712 }; | 701 }; |
713 | 702 |
714 #endif | 703 #endif |
OLD | NEW |