OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #ifndef SkMatrix44_DEFINED | 8 #ifndef SkMatrix44_DEFINED |
9 #define SkMatrix44_DEFINED | 9 #define SkMatrix44_DEFINED |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 static inline double SkDoubleToMScalar(double x) { | 26 static inline double SkDoubleToMScalar(double x) { |
27 return x; | 27 return x; |
28 } | 28 } |
29 static inline double SkMScalarToDouble(double x) { | 29 static inline double SkMScalarToDouble(double x) { |
30 return x; | 30 return x; |
31 } | 31 } |
32 static inline double SkMScalarAbs(double x) { | 32 static inline double SkMScalarAbs(double x) { |
33 return fabs(x); | 33 return fabs(x); |
34 } | 34 } |
35 static const SkMScalar SK_MScalarPI = 3.141592653589793; | 35 static const SkMScalar SK_MScalarPI = 3.141592653589793; |
| 36 |
| 37 #define SkMScalarFloor(x) sk_double_floor(x) |
| 38 #define SkMScalarCeil(x) sk_double_ceil(x) |
| 39 #define SkMScalarRound(x) sk_double_round(x) |
| 40 |
| 41 #define SkMScalarFloorToInt(x) sk_double_floor2int(x) |
| 42 #define SkMScalarCeilToInt(x) sk_double_ceil2int(x) |
| 43 #define SkMScalarRoundToInt(x) sk_double_round2int(x) |
| 44 |
| 45 |
36 #elif defined SK_MSCALAR_IS_FLOAT | 46 #elif defined SK_MSCALAR_IS_FLOAT |
37 #ifdef SK_MSCALAR_IS_DOUBLE | 47 #ifdef SK_MSCALAR_IS_DOUBLE |
38 #error "can't define MSCALAR both as DOUBLE and FLOAT" | 48 #error "can't define MSCALAR both as DOUBLE and FLOAT" |
39 #endif | 49 #endif |
40 typedef float SkMScalar; | 50 typedef float SkMScalar; |
41 | 51 |
42 static inline float SkFloatToMScalar(float x) { | 52 static inline float SkFloatToMScalar(float x) { |
43 return x; | 53 return x; |
44 } | 54 } |
45 static inline float SkMScalarToFloat(float x) { | 55 static inline float SkMScalarToFloat(float x) { |
46 return x; | 56 return x; |
47 } | 57 } |
48 static inline float SkDoubleToMScalar(double x) { | 58 static inline float SkDoubleToMScalar(double x) { |
49 return static_cast<float>(x); | 59 return static_cast<float>(x); |
50 } | 60 } |
51 static inline double SkMScalarToDouble(float x) { | 61 static inline double SkMScalarToDouble(float x) { |
52 return static_cast<double>(x); | 62 return static_cast<double>(x); |
53 } | 63 } |
54 static inline float SkMScalarAbs(float x) { | 64 static inline float SkMScalarAbs(float x) { |
55 return sk_float_abs(x); | 65 return sk_float_abs(x); |
56 } | 66 } |
57 static const SkMScalar SK_MScalarPI = 3.14159265f; | 67 static const SkMScalar SK_MScalarPI = 3.14159265f; |
| 68 |
| 69 #define SkMScalarFloor(x) sk_float_floor(x) |
| 70 #define SkMScalarCeil(x) sk_float_ceil(x) |
| 71 #define SkMScalarRound(x) sk_float_round(x) |
| 72 |
| 73 #define SkMScalarFloorToInt(x) sk_float_floor2int(x) |
| 74 #define SkMScalarCeilToInt(x) sk_float_ceil2int(x) |
| 75 #define SkMScalarRoundToInt(x) sk_float_round2int(x) |
| 76 |
58 #endif | 77 #endif |
59 | 78 |
60 #define SkMScalarToScalar SkMScalarToFloat | 79 #define SkIntToMScalar(n) static_cast<SkMScalar>(n) |
61 #define SkScalarToMScalar SkFloatToMScalar | 80 |
| 81 #define SkMScalarToScalar(x) SkMScalarToFloat(x) |
| 82 #define SkScalarToMScalar(x) SkFloatToMScalar(x) |
62 | 83 |
63 static const SkMScalar SK_MScalar1 = 1; | 84 static const SkMScalar SK_MScalar1 = 1; |
64 | 85 |
65 /////////////////////////////////////////////////////////////////////////////// | 86 /////////////////////////////////////////////////////////////////////////////// |
66 | 87 |
67 struct SkVector4 { | 88 struct SkVector4 { |
68 SkScalar fData[4]; | 89 SkScalar fData[4]; |
69 | 90 |
70 SkVector4() { | 91 SkVector4() { |
71 this->set(0, 0, 0, 1); | 92 this->set(0, 0, 0, 1); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 /** | 456 /** |
436 * Does not take the time to 'compute' the typemask. Only returns true if | 457 * Does not take the time to 'compute' the typemask. Only returns true if |
437 * we already know that this matrix is identity. | 458 * we already know that this matrix is identity. |
438 */ | 459 */ |
439 inline bool isTriviallyIdentity() const { | 460 inline bool isTriviallyIdentity() const { |
440 return 0 == fTypeMask; | 461 return 0 == fTypeMask; |
441 } | 462 } |
442 }; | 463 }; |
443 | 464 |
444 #endif | 465 #endif |
OLD | NEW |