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 #ifndef SkScalar_DEFINED | 8 #ifndef SkScalar_DEFINED |
9 #define SkScalar_DEFINED | 9 #define SkScalar_DEFINED |
10 | 10 |
11 #include "../private/SkFixed.h" | |
12 #include "../private/SkFloatingPoint.h" | 11 #include "../private/SkFloatingPoint.h" |
13 | 12 |
14 // TODO: move this sort of check into SkPostConfig.h | 13 // TODO: move this sort of check into SkPostConfig.h |
15 #define SK_SCALAR_IS_DOUBLE 0 | 14 #define SK_SCALAR_IS_DOUBLE 0 |
16 #undef SK_SCALAR_IS_FLOAT | 15 #undef SK_SCALAR_IS_FLOAT |
17 #define SK_SCALAR_IS_FLOAT 1 | 16 #define SK_SCALAR_IS_FLOAT 1 |
18 | 17 |
19 | 18 |
20 #if SK_SCALAR_IS_FLOAT | 19 #if SK_SCALAR_IS_FLOAT |
21 | 20 |
22 typedef float SkScalar; | 21 typedef float SkScalar; |
23 | 22 |
24 #define SK_Scalar1 1.0f | 23 #define SK_Scalar1 1.0f |
25 #define SK_ScalarHalf 0.5f | 24 #define SK_ScalarHalf 0.5f |
26 #define SK_ScalarSqrt2 1.41421356f | 25 #define SK_ScalarSqrt2 1.41421356f |
27 #define SK_ScalarPI 3.14159265f | 26 #define SK_ScalarPI 3.14159265f |
28 #define SK_ScalarTanPIOver8 0.414213562f | 27 #define SK_ScalarTanPIOver8 0.414213562f |
29 #define SK_ScalarRoot2Over2 0.707106781f | 28 #define SK_ScalarRoot2Over2 0.707106781f |
30 #define SK_ScalarMax 3.402823466e+38f | 29 #define SK_ScalarMax 3.402823466e+38f |
31 #define SK_ScalarInfinity SK_FloatInfinity | 30 #define SK_ScalarInfinity SK_FloatInfinity |
32 #define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity | 31 #define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity |
33 #define SK_ScalarNaN SK_FloatNaN | 32 #define SK_ScalarNaN SK_FloatNaN |
34 | 33 |
35 #define SkFixedToScalar(x) SkFixedToFloat(x) | |
36 #define SkScalarToFixed(x) SkFloatToFixed(x) | |
37 | |
38 #define SkScalarFloorToScalar(x) sk_float_floor(x) | 34 #define SkScalarFloorToScalar(x) sk_float_floor(x) |
39 #define SkScalarCeilToScalar(x) sk_float_ceil(x) | 35 #define SkScalarCeilToScalar(x) sk_float_ceil(x) |
40 #define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f) | 36 #define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f) |
41 #define SkScalarTruncToScalar(x) sk_float_trunc(x) | 37 #define SkScalarTruncToScalar(x) sk_float_trunc(x) |
42 | 38 |
43 #define SkScalarFloorToInt(x) sk_float_floor2int(x) | 39 #define SkScalarFloorToInt(x) sk_float_floor2int(x) |
44 #define SkScalarCeilToInt(x) sk_float_ceil2int(x) | 40 #define SkScalarCeilToInt(x) sk_float_ceil2int(x) |
45 #define SkScalarRoundToInt(x) sk_float_round2int(x) | 41 #define SkScalarRoundToInt(x) sk_float_round2int(x) |
46 | 42 |
47 #define SkScalarAbs(x) sk_float_abs(x) | 43 #define SkScalarAbs(x) sk_float_abs(x) |
(...skipping 20 matching lines...) Expand all Loading... |
68 #define SK_ScalarHalf 0.5 | 64 #define SK_ScalarHalf 0.5 |
69 #define SK_ScalarSqrt2 1.414213562373095 | 65 #define SK_ScalarSqrt2 1.414213562373095 |
70 #define SK_ScalarPI 3.141592653589793 | 66 #define SK_ScalarPI 3.141592653589793 |
71 #define SK_ScalarTanPIOver8 0.4142135623731 | 67 #define SK_ScalarTanPIOver8 0.4142135623731 |
72 #define SK_ScalarRoot2Over2 0.70710678118655 | 68 #define SK_ScalarRoot2Over2 0.70710678118655 |
73 #define SK_ScalarMax 1.7976931348623157+308 | 69 #define SK_ScalarMax 1.7976931348623157+308 |
74 #define SK_ScalarInfinity SK_DoubleInfinity | 70 #define SK_ScalarInfinity SK_DoubleInfinity |
75 #define SK_ScalarNegativeInfinity SK_DoubleNegativeInfinity | 71 #define SK_ScalarNegativeInfinity SK_DoubleNegativeInfinity |
76 #define SK_ScalarNaN SK_DoubleNaN | 72 #define SK_ScalarNaN SK_DoubleNaN |
77 | 73 |
78 #define SkFixedToScalar(x) SkFixedToDouble(x) | |
79 #define SkScalarToFixed(x) SkDoubleToFixed(x) | |
80 | |
81 #define SkScalarFloorToScalar(x) floor(x) | 74 #define SkScalarFloorToScalar(x) floor(x) |
82 #define SkScalarCeilToScalar(x) ceil(x) | 75 #define SkScalarCeilToScalar(x) ceil(x) |
83 #define SkScalarRoundToScalar(x) floor((x) + 0.5) | 76 #define SkScalarRoundToScalar(x) floor((x) + 0.5) |
84 #define SkScalarTruncToScalar(x) trunc(x) | 77 #define SkScalarTruncToScalar(x) trunc(x) |
85 | 78 |
86 #define SkScalarFloorToInt(x) (int)floor(x) | 79 #define SkScalarFloorToInt(x) (int)floor(x) |
87 #define SkScalarCeilToInt(x) (int)ceil(x) | 80 #define SkScalarCeilToInt(x) (int)ceil(x) |
88 #define SkScalarRoundToInt(x) (int)floor((x) + 0.5) | 81 #define SkScalarRoundToInt(x) (int)floor((x) + 0.5) |
89 | 82 |
90 #define SkScalarAbs(x) abs(x) | 83 #define SkScalarAbs(x) abs(x) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 SkASSERT(n >= 0); | 258 SkASSERT(n >= 0); |
266 for (int i = 0; i < n; ++i) { | 259 for (int i = 0; i < n; ++i) { |
267 if (a[i] != b[i]) { | 260 if (a[i] != b[i]) { |
268 return false; | 261 return false; |
269 } | 262 } |
270 } | 263 } |
271 return true; | 264 return true; |
272 } | 265 } |
273 | 266 |
274 #endif | 267 #endif |
OLD | NEW |