| 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 14 matching lines...) Expand all Loading... |
| 25 // C++98 cmath std::pow seems to be the earliest portable way to get float pow. | 25 // C++98 cmath std::pow seems to be the earliest portable way to get float pow. |
| 26 // However, on Linux including cmath undefines isfinite. | 26 // However, on Linux including cmath undefines isfinite. |
| 27 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14608 | 27 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14608 |
| 28 static inline float sk_float_pow(float base, float exp) { | 28 static inline float sk_float_pow(float base, float exp) { |
| 29 return powf(base, exp); | 29 return powf(base, exp); |
| 30 } | 30 } |
| 31 | 31 |
| 32 static inline float sk_float_copysign(float x, float y) { | 32 static inline float sk_float_copysign(float x, float y) { |
| 33 // c++11 contains a 'float copysign(float, float)' function in <cmath>. | 33 // c++11 contains a 'float copysign(float, float)' function in <cmath>. |
| 34 // clang-cl reports __cplusplus for clang, not the __cplusplus vc++ version _MSC
_VER would report. | 34 // clang-cl reports __cplusplus for clang, not the __cplusplus vc++ version _MSC
_VER would report. |
| 35 #define SK_BUILD_WITH_CLANG_CL (defined(_MSC_VER) && defined(__clang__)) | 35 #if (defined(_MSC_VER) && defined(__clang__)) |
| 36 #if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (defined(_MSC_VER) &&
_MSC_VER >= 1800) | 36 # define SK_BUILD_WITH_CLANG_CL 1 |
| 37 #else |
| 38 # define SK_BUILD_WITH_CLANG_CL 0 |
| 39 #endif |
| 40 #if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (_MSC_VER >= 1800) |
| 37 return copysign(x, y); | 41 return copysign(x, y); |
| 38 | 42 |
| 39 // Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6. | 43 // Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6. |
| 40 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L | 44 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L |
| 41 return copysignf(x, y); | 45 return copysignf(x, y); |
| 42 | 46 |
| 43 // Visual studio prior to 13 only has 'double _copysign(double, double)'. | 47 // Visual studio prior to 13 only has 'double _copysign(double, double)'. |
| 44 #elif defined(_MSC_VER) | 48 #elif defined(_MSC_VER) |
| 45 return (float)_copysign(x, y); | 49 return (float)_copysign(x, y); |
| 46 | 50 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 float estimate = *SkTCast<float*>(&i); | 158 float estimate = *SkTCast<float*>(&i); |
| 155 | 159 |
| 156 // One step of Newton's method to refine. | 160 // One step of Newton's method to refine. |
| 157 const float estimate_sq = estimate*estimate; | 161 const float estimate_sq = estimate*estimate; |
| 158 estimate *= (1.5f-0.5f*x*estimate_sq); | 162 estimate *= (1.5f-0.5f*x*estimate_sq); |
| 159 return estimate; | 163 return estimate; |
| 160 #endif | 164 #endif |
| 161 } | 165 } |
| 162 | 166 |
| 163 #endif | 167 #endif |
| OLD | NEW |