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