Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 #define sk_float_acos(x) static_cast<float>(acos(x)) | 81 #define sk_float_acos(x) static_cast<float>(acos(x)) |
| 82 #define sk_float_asin(x) static_cast<float>(asin(x)) | 82 #define sk_float_asin(x) static_cast<float>(asin(x)) |
| 83 #else | 83 #else |
| 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) |
|
robertphillips
2015/01/16 01:13:37
Map sk_float_log2 to log2f here?
reed1
2015/01/16 13:00:11
Done.
| |
| 92 #endif | 92 #endif |
| 93 | 93 |
| 94 // 1 / ln(2) | |
| 95 #define SK_INVERSE_LN_2 1.44269504088896 | |
| 96 | |
| 97 // log2(x) = log(x) / log(2) | |
| 98 #define sk_float_log2(x) (float)(::log(x) * SK_INVERSE_LN_2) | |
| 99 | |
| 94 #ifdef SK_BUILD_FOR_WIN | 100 #ifdef SK_BUILD_FOR_WIN |
| 95 #define sk_float_isfinite(x) _finite(x) | 101 #define sk_float_isfinite(x) _finite(x) |
| 96 #define sk_float_isnan(x) _isnan(x) | 102 #define sk_float_isnan(x) _isnan(x) |
| 97 static inline int sk_float_isinf(float x) { | 103 static inline int sk_float_isinf(float x) { |
| 98 int32_t bits = SkFloat2Bits(x); | 104 int32_t bits = SkFloat2Bits(x); |
| 99 return (bits << 1) == (0xFF << 24); | 105 return (bits << 1) == (0xFF << 24); |
| 100 } | 106 } |
| 101 #else | 107 #else |
| 102 #define sk_float_isfinite(x) isfinite(x) | 108 #define sk_float_isfinite(x) isfinite(x) |
| 103 #define sk_float_isnan(x) isnan(x) | 109 #define sk_float_isnan(x) isnan(x) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 float estimate = *SkTCast<float*>(&i); | 171 float estimate = *SkTCast<float*>(&i); |
| 166 | 172 |
| 167 // One step of Newton's method to refine. | 173 // One step of Newton's method to refine. |
| 168 const float estimate_sq = estimate*estimate; | 174 const float estimate_sq = estimate*estimate; |
| 169 estimate *= (1.5f-0.5f*x*estimate_sq); | 175 estimate *= (1.5f-0.5f*x*estimate_sq); |
| 170 return estimate; | 176 return estimate; |
| 171 #endif | 177 #endif |
| 172 } | 178 } |
| 173 | 179 |
| 174 #endif | 180 #endif |
| OLD | NEW |