| 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 20 matching lines...) Expand all Loading... |
| 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 #if (defined(_MSC_VER) && defined(__clang__)) | 35 #if (defined(_MSC_VER) && defined(__clang__)) |
| 36 # define SK_BUILD_WITH_CLANG_CL 1 | 36 # define SK_BUILD_WITH_CLANG_CL 1 |
| 37 #else | 37 #else |
| 38 # define SK_BUILD_WITH_CLANG_CL 0 | 38 # define SK_BUILD_WITH_CLANG_CL 0 |
| 39 #endif | 39 #endif |
| 40 #if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (_MSC_VER >= 1800) | 40 #if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (_MSC_VER >= 1800) |
| 41 return copysign(x, y); | 41 return copysignf(x, y); |
| 42 | 42 |
| 43 // 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. |
| 44 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L | 44 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L |
| 45 return copysignf(x, y); | 45 return copysignf(x, y); |
| 46 | 46 |
| 47 // Visual studio prior to 13 only has 'double _copysign(double, double)'. | 47 // Visual studio prior to 13 only has 'double _copysign(double, double)'. |
| 48 #elif defined(_MSC_VER) | 48 #elif defined(_MSC_VER) |
| 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. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 float estimate = *SkTCast<float*>(&i); | 177 float estimate = *SkTCast<float*>(&i); |
| 178 | 178 |
| 179 // One step of Newton's method to refine. | 179 // One step of Newton's method to refine. |
| 180 const float estimate_sq = estimate*estimate; | 180 const float estimate_sq = estimate*estimate; |
| 181 estimate *= (1.5f-0.5f*x*estimate_sq); | 181 estimate *= (1.5f-0.5f*x*estimate_sq); |
| 182 return estimate; | 182 return estimate; |
| 183 #endif | 183 #endif |
| 184 } | 184 } |
| 185 | 185 |
| 186 #endif | 186 #endif |
| OLD | NEW |