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 SkFloatingPoint_DEFINED | 10 #ifndef SkFloatingPoint_DEFINED |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return (float)_copysign(x, y); | 49 return (float)_copysign(x, y); |
50 | 50 |
51 // Otherwise convert to bits and extract sign. | 51 // Otherwise convert to bits and extract sign. |
52 #else | 52 #else |
53 int32_t xbits = SkFloat2Bits(x); | 53 int32_t xbits = SkFloat2Bits(x); |
54 int32_t ybits = SkFloat2Bits(y); | 54 int32_t ybits = SkFloat2Bits(y); |
55 return SkBits2Float((xbits & 0x7FFFFFFF) | (ybits & 0x80000000)); | 55 return SkBits2Float((xbits & 0x7FFFFFFF) | (ybits & 0x80000000)); |
56 #endif | 56 #endif |
57 } | 57 } |
58 | 58 |
59 #ifdef SK_BUILD_FOR_WINCE | 59 #define sk_float_sqrt(x) sqrtf(x) |
60 #define sk_float_sqrt(x) (float)::sqrt(x) | 60 #define sk_float_sin(x) sinf(x) |
61 #define sk_float_sin(x) (float)::sin(x) | 61 #define sk_float_cos(x) cosf(x) |
62 #define sk_float_cos(x) (float)::cos(x) | 62 #define sk_float_tan(x) tanf(x) |
63 #define sk_float_tan(x) (float)::tan(x) | 63 #define sk_float_floor(x) floorf(x) |
64 #define sk_float_acos(x) (float)::acos(x) | 64 #define sk_float_ceil(x) ceilf(x) |
65 #define sk_float_asin(x) (float)::asin(x) | 65 #ifdef SK_BUILD_FOR_MAC |
66 #define sk_float_atan2(y,x) (float)::atan2(y,x) | 66 # define sk_float_acos(x) static_cast<float>(acos(x)) |
67 #define sk_float_abs(x) (float)::fabs(x) | 67 # define sk_float_asin(x) static_cast<float>(asin(x)) |
68 #define sk_float_mod(x,y) (float)::fmod(x,y) | |
69 #define sk_float_exp(x) (float)::exp(x) | |
70 #define sk_float_log(x) (float)::log(x) | |
71 #define sk_float_floor(x) (float)::floor(x) | |
72 #define sk_float_ceil(x) (float)::ceil(x) | |
73 #else | 68 #else |
74 #define sk_float_sqrt(x) sqrtf(x) | 69 # define sk_float_acos(x) acosf(x) |
75 #define sk_float_sin(x) sinf(x) | 70 # define sk_float_asin(x) asinf(x) |
76 #define sk_float_cos(x) cosf(x) | |
77 #define sk_float_tan(x) tanf(x) | |
78 #define sk_float_floor(x) floorf(x) | |
79 #define sk_float_ceil(x) ceilf(x) | |
80 #ifdef SK_BUILD_FOR_MAC | |
81 #define sk_float_acos(x) static_cast<float>(acos(x)) | |
82 #define sk_float_asin(x) static_cast<float>(asin(x)) | |
83 #else | |
84 #define sk_float_acos(x) acosf(x) | |
85 #define sk_float_asin(x) asinf(x) | |
86 #endif | 71 #endif |
87 #define sk_float_atan2(y,x) atan2f(y,x) | 72 #define sk_float_atan2(y,x) atan2f(y,x) |
88 #define sk_float_abs(x) fabsf(x) | 73 #define sk_float_abs(x) fabsf(x) |
89 #define sk_float_mod(x,y) fmodf(x,y) | 74 #define sk_float_mod(x,y) fmodf(x,y) |
90 #define sk_float_exp(x) expf(x) | 75 #define sk_float_exp(x) expf(x) |
91 #define sk_float_log(x) logf(x) | 76 #define sk_float_log(x) logf(x) |
92 #endif | |
93 | 77 |
94 #define sk_float_round(x) sk_float_floor((x) + 0.5f) | 78 #define sk_float_round(x) sk_float_floor((x) + 0.5f) |
95 | 79 |
96 // can't find log2f on android, but maybe that just a tool bug? | 80 // can't find log2f on android, but maybe that just a tool bug? |
97 #ifdef SK_BUILD_FOR_ANDROID | 81 #ifdef SK_BUILD_FOR_ANDROID |
98 static inline float sk_float_log2(float x) { | 82 static inline float sk_float_log2(float x) { |
99 const double inv_ln_2 = 1.44269504088896; | 83 const double inv_ln_2 = 1.44269504088896; |
100 return (float)(log(x) * inv_ln_2); | 84 return (float)(log(x) * inv_ln_2); |
101 } | 85 } |
102 #else | 86 #else |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 float estimate = *SkTCast<float*>(&i); | 155 float estimate = *SkTCast<float*>(&i); |
172 | 156 |
173 // One step of Newton's method to refine. | 157 // One step of Newton's method to refine. |
174 const float estimate_sq = estimate*estimate; | 158 const float estimate_sq = estimate*estimate; |
175 estimate *= 0.703952253f*(2.38924456f-x*estimate_sq); | 159 estimate *= 0.703952253f*(2.38924456f-x*estimate_sq); |
176 return estimate; | 160 return estimate; |
177 #endif | 161 #endif |
178 } | 162 } |
179 | 163 |
180 #endif | 164 #endif |
OLD | NEW |