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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #define sk_float_acos(x) acosf(x) | 84 #define sk_float_acos(x) acosf(x) |
85 #define sk_float_asin(x) asinf(x) | 85 #define sk_float_asin(x) asinf(x) |
86 #endif | 86 #endif |
87 #define sk_float_atan2(y,x) atan2f(y,x) | 87 #define sk_float_atan2(y,x) atan2f(y,x) |
88 #define sk_float_abs(x) fabsf(x) | 88 #define sk_float_abs(x) fabsf(x) |
89 #define sk_float_mod(x,y) fmodf(x,y) | 89 #define sk_float_mod(x,y) fmodf(x,y) |
90 #define sk_float_exp(x) expf(x) | 90 #define sk_float_exp(x) expf(x) |
91 #define sk_float_log(x) logf(x) | 91 #define sk_float_log(x) logf(x) |
92 #endif | 92 #endif |
93 | 93 |
94 // can't find log2f on android, but maybe that just a tool bug? | |
95 #ifdef SK_BUILD_FOR_ANDROID | |
96 static inline float sk_float_log2(float x) { | |
97 const double inv_ln_2 = 1.44269504088896; | |
98 return (float)(log(x) * inv_ln_2); | |
99 } | |
100 #else | |
101 #define sk_float_log2(x) log2f(x) | |
102 #endif | |
103 | |
104 #ifdef SK_BUILD_FOR_WIN | 94 #ifdef SK_BUILD_FOR_WIN |
105 #define sk_float_isfinite(x) _finite(x) | 95 #define sk_float_isfinite(x) _finite(x) |
106 #define sk_float_isnan(x) _isnan(x) | 96 #define sk_float_isnan(x) _isnan(x) |
107 static inline int sk_float_isinf(float x) { | 97 static inline int sk_float_isinf(float x) { |
108 int32_t bits = SkFloat2Bits(x); | 98 int32_t bits = SkFloat2Bits(x); |
109 return (bits << 1) == (0xFF << 24); | 99 return (bits << 1) == (0xFF << 24); |
110 } | 100 } |
111 #else | 101 #else |
112 #define sk_float_isfinite(x) isfinite(x) | 102 #define sk_float_isfinite(x) isfinite(x) |
113 #define sk_float_isnan(x) isnan(x) | 103 #define sk_float_isnan(x) isnan(x) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 float estimate = *SkTCast<float*>(&i); | 165 float estimate = *SkTCast<float*>(&i); |
176 | 166 |
177 // One step of Newton's method to refine. | 167 // One step of Newton's method to refine. |
178 const float estimate_sq = estimate*estimate; | 168 const float estimate_sq = estimate*estimate; |
179 estimate *= (1.5f-0.5f*x*estimate_sq); | 169 estimate *= (1.5f-0.5f*x*estimate_sq); |
180 return estimate; | 170 return estimate; |
181 #endif | 171 #endif |
182 } | 172 } |
183 | 173 |
184 #endif | 174 #endif |
OLD | NEW |