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 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 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 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) | 34 #if (!defined(_MSC_VER) && __cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC _VER >= 1800) |
|
bungeman-skia
2014/09/12 20:54:52
So this won't break Chromium for now because Chrom
| |
| 35 return copysign(x, y); | 35 return copysign(x, y); |
| 36 | 36 |
| 37 // Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6. | 37 // Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6. |
| 38 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L | 38 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L |
| 39 return copysignf(x, y); | 39 return copysignf(x, y); |
| 40 | 40 |
| 41 // Visual studio prior to 13 only has 'double _copysign(double, double)'. | 41 // Visual studio prior to 13 only has 'double _copysign(double, double)'. |
| 42 #elif defined(_MSC_VER) | 42 #elif defined(_MSC_VER) |
| 43 return (float)_copysign(x, y); | 43 return (float)_copysign(x, y); |
| 44 | 44 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 float estimate = *SkTCast<float*>(&i); | 152 float estimate = *SkTCast<float*>(&i); |
| 153 | 153 |
| 154 // One step of Newton's method to refine. | 154 // One step of Newton's method to refine. |
| 155 const float estimate_sq = estimate*estimate; | 155 const float estimate_sq = estimate*estimate; |
| 156 estimate *= (1.5f-0.5f*x*estimate_sq); | 156 estimate *= (1.5f-0.5f*x*estimate_sq); |
| 157 return estimate; | 157 return estimate; |
| 158 #endif | 158 #endif |
| 159 } | 159 } |
| 160 | 160 |
| 161 #endif | 161 #endif |
| OLD | NEW |