OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkMatrix.h" | 8 #include "SkMatrix.h" |
9 #include "Sk64.h" | 9 #include "Sk64.h" |
10 #include "SkFloatBits.h" | 10 #include "SkFloatBits.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 kAffine_Shift, | 44 kAffine_Shift, |
45 kPerspective_Shift, | 45 kPerspective_Shift, |
46 kRectStaysRect_Shift | 46 kRectStaysRect_Shift |
47 }; | 47 }; |
48 | 48 |
49 #ifdef SK_SCALAR_IS_FLOAT | 49 #ifdef SK_SCALAR_IS_FLOAT |
50 static const int32_t kScalar1Int = 0x3f800000; | 50 static const int32_t kScalar1Int = 0x3f800000; |
51 #else | 51 #else |
52 #define scalarAsInt(x) (x) | 52 #define scalarAsInt(x) (x) |
53 static const int32_t kScalar1Int = (1 << 16); | 53 static const int32_t kScalar1Int = (1 << 16); |
54 static const int32_t kPersp1Int = (1 << 30); | |
55 #endif | 54 #endif |
56 | 55 |
57 uint8_t SkMatrix::computePerspectiveTypeMask() const { | 56 uint8_t SkMatrix::computePerspectiveTypeMask() const { |
58 #ifdef SK_SCALAR_SLOW_COMPARES | 57 #ifdef SK_SCALAR_SLOW_COMPARES |
59 if (SkScalarAs2sCompliment(fMat[kMPersp0]) | | 58 if (SkScalarAs2sCompliment(fMat[kMPersp0]) | |
60 SkScalarAs2sCompliment(fMat[kMPersp1]) | | 59 SkScalarAs2sCompliment(fMat[kMPersp1]) | |
61 (SkScalarAs2sCompliment(fMat[kMPersp2]) - kPersp1Int)) { | 60 (SkScalarAs2sCompliment(fMat[kMPersp2]) - SK_Fract1)) { |
62 return SkToU8(kORableMasks); | 61 return SkToU8(kORableMasks); |
63 } | 62 } |
64 #else | 63 #else |
65 // Benchmarking suggests that replacing this set of SkScalarAs2sCompliment | 64 // Benchmarking suggests that replacing this set of SkScalarAs2sCompliment |
66 // is a win, but replacing those below is not. We don't yet understand | 65 // is a win, but replacing those below is not. We don't yet understand |
67 // that result. | 66 // that result. |
68 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 || | 67 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 || |
69 fMat[kMPersp2] != kMatrix22Elem) { | 68 fMat[kMPersp2] != kMatrix22Elem) { |
70 // If this is a perspective transform, we return true for all other | 69 // If this is a perspective transform, we return true for all other |
71 // transform flags - this does not disable any optimizations, respects | 70 // transform flags - this does not disable any optimizations, respects |
72 // the rule that the type mask must be conservative, and speeds up | 71 // the rule that the type mask must be conservative, and speeds up |
73 // type mask computation. | 72 // type mask computation. |
74 return SkToU8(kORableMasks); | 73 return SkToU8(kORableMasks); |
75 } | 74 } |
76 #endif | 75 #endif |
77 | 76 |
78 return SkToU8(kOnlyPerspectiveValid_Mask | kUnknown_Mask); | 77 return SkToU8(kOnlyPerspectiveValid_Mask | kUnknown_Mask); |
79 } | 78 } |
80 | 79 |
81 uint8_t SkMatrix::computeTypeMask() const { | 80 uint8_t SkMatrix::computeTypeMask() const { |
82 unsigned mask = 0; | 81 unsigned mask = 0; |
83 | 82 |
84 #ifdef SK_SCALAR_SLOW_COMPARES | 83 #ifdef SK_SCALAR_SLOW_COMPARES |
85 if (SkScalarAs2sCompliment(fMat[kMPersp0]) | | 84 if (SkScalarAs2sCompliment(fMat[kMPersp0]) | |
86 SkScalarAs2sCompliment(fMat[kMPersp1]) | | 85 SkScalarAs2sCompliment(fMat[kMPersp1]) | |
87 (SkScalarAs2sCompliment(fMat[kMPersp2]) - kPersp1Int)) { | 86 (SkScalarAs2sCompliment(fMat[kMPersp2]) - SK_Fract1)) { |
88 return SkToU8(kORableMasks); | 87 return SkToU8(kORableMasks); |
89 } | 88 } |
90 | 89 |
91 if (SkScalarAs2sCompliment(fMat[kMTransX]) | | 90 if (SkScalarAs2sCompliment(fMat[kMTransX]) | |
92 SkScalarAs2sCompliment(fMat[kMTransY])) { | 91 SkScalarAs2sCompliment(fMat[kMTransY])) { |
93 mask |= kTranslate_Mask; | 92 mask |= kTranslate_Mask; |
94 } | 93 } |
95 #else | 94 #else |
96 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 || | 95 if (fMat[kMPersp0] != 0 || fMat[kMPersp1] != 0 || |
97 fMat[kMPersp2] != kMatrix22Elem) { | 96 fMat[kMPersp2] != kMatrix22Elem) { |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 rotation1->fX = cos1; | 2107 rotation1->fX = cos1; |
2109 rotation1->fY = sin1; | 2108 rotation1->fY = sin1; |
2110 } | 2109 } |
2111 if (NULL != rotation2) { | 2110 if (NULL != rotation2) { |
2112 rotation2->fX = cos2; | 2111 rotation2->fX = cos2; |
2113 rotation2->fY = sin2; | 2112 rotation2->fY = sin2; |
2114 } | 2113 } |
2115 | 2114 |
2116 return true; | 2115 return true; |
2117 } | 2116 } |
OLD | NEW |