| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 #ifdef SK_USE_FLOATBITS | 109 #ifdef SK_USE_FLOATBITS |
| 110 #define sk_float_floor2int(x) SkFloatToIntFloor(x) | 110 #define sk_float_floor2int(x) SkFloatToIntFloor(x) |
| 111 #define sk_float_round2int(x) SkFloatToIntRound(x) | 111 #define sk_float_round2int(x) SkFloatToIntRound(x) |
| 112 #define sk_float_ceil2int(x) SkFloatToIntCeil(x) | 112 #define sk_float_ceil2int(x) SkFloatToIntCeil(x) |
| 113 #else | 113 #else |
| 114 #define sk_float_floor2int(x) (int)sk_float_floor(x) | 114 #define sk_float_floor2int(x) (int)sk_float_floor(x) |
| 115 #define sk_float_round2int(x) (int)sk_float_floor((x) + 0.5f) | 115 #define sk_float_round2int(x) (int)sk_float_floor((x) + 0.5f) |
| 116 #define sk_float_ceil2int(x) (int)sk_float_ceil(x) | 116 #define sk_float_ceil2int(x) (int)sk_float_ceil(x) |
| 117 #endif | 117 #endif |
| 118 | 118 |
| 119 #define sk_double_floor(x) floor(x) |
| 120 #define sk_double_round(x) floor((x) + 0.5) |
| 121 #define sk_double_ceil(x) ceil(x) |
| 122 #define sk_double_floor2int(x) (int)floor(x) |
| 123 #define sk_double_round2int(x) (int)floor((x) + 0.5f) |
| 124 #define sk_double_ceil2int(x) (int)ceil(x) |
| 125 |
| 119 extern const uint32_t gIEEENotANumber; | 126 extern const uint32_t gIEEENotANumber; |
| 120 extern const uint32_t gIEEEInfinity; | 127 extern const uint32_t gIEEEInfinity; |
| 121 extern const uint32_t gIEEENegativeInfinity; | 128 extern const uint32_t gIEEENegativeInfinity; |
| 122 | 129 |
| 123 #define SK_FloatNaN (*SkTCast<const float*>(&gIEEENotANumber)) | 130 #define SK_FloatNaN (*SkTCast<const float*>(&gIEEENotANumber)) |
| 124 #define SK_FloatInfinity (*SkTCast<const float*>(&gIEEEInfinity)) | 131 #define SK_FloatInfinity (*SkTCast<const float*>(&gIEEEInfinity)) |
| 125 #define SK_FloatNegativeInfinity (*SkTCast<const float*>(&gIEEENegativeInfini
ty)) | 132 #define SK_FloatNegativeInfinity (*SkTCast<const float*>(&gIEEENegativeInfini
ty)) |
| 126 | 133 |
| 127 #if defined(__SSE__) | 134 #if defined(__SSE__) |
| 128 #include <xmmintrin.h> | 135 #include <xmmintrin.h> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 158 float estimate = *SkTCast<float*>(&i); | 165 float estimate = *SkTCast<float*>(&i); |
| 159 | 166 |
| 160 // One step of Newton's method to refine. | 167 // One step of Newton's method to refine. |
| 161 const float estimate_sq = estimate*estimate; | 168 const float estimate_sq = estimate*estimate; |
| 162 estimate *= (1.5f-0.5f*x*estimate_sq); | 169 estimate *= (1.5f-0.5f*x*estimate_sq); |
| 163 return estimate; | 170 return estimate; |
| 164 #endif | 171 #endif |
| 165 } | 172 } |
| 166 | 173 |
| 167 #endif | 174 #endif |
| OLD | NEW |