| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 SkFloatBits_DEFINED | 10 #ifndef SkFloatBits_DEFINED |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 /** Convert a 2s compliment int to a sign-bit (i.e. int interpreted as float). | 27 /** Convert a 2s compliment int to a sign-bit (i.e. int interpreted as float). |
| 28 This undoes the result of SkSignBitTo2sCompliment(). | 28 This undoes the result of SkSignBitTo2sCompliment(). |
| 29 */ | 29 */ |
| 30 static inline int32_t Sk2sComplimentToSignBit(int32_t x) { | 30 static inline int32_t Sk2sComplimentToSignBit(int32_t x) { |
| 31 int sign = x >> 31; | 31 int sign = x >> 31; |
| 32 // make x positive | 32 // make x positive |
| 33 x = (x ^ sign) - sign; | 33 x = (x ^ sign) - sign; |
| 34 // set the sign bit as needed | 34 // set the sign bit as needed |
| 35 x |= sign << 31; | 35 x |= SkLeftShift(sign, 31); |
| 36 return x; | 36 return x; |
| 37 } | 37 } |
| 38 | 38 |
| 39 /** Given the bit representation of a float, return its value cast to an int. | 39 /** Given the bit representation of a float, return its value cast to an int. |
| 40 If the value is out of range, or NaN, return return +/- SK_MaxS32 | 40 If the value is out of range, or NaN, return return +/- SK_MaxS32 |
| 41 */ | 41 */ |
| 42 int32_t SkFloatBits_toIntCast(int32_t floatBits); | 42 int32_t SkFloatBits_toIntCast(int32_t floatBits); |
| 43 | 43 |
| 44 /** Given the bit representation of a float, return its floor as an int. | 44 /** Given the bit representation of a float, return its floor as an int. |
| 45 If the value is out of range, or NaN, return return +/- SK_MaxS32 | 45 If the value is out of range, or NaN, return return +/- SK_MaxS32 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 static inline int32_t SkFloatToIntCeil(float x) { | 123 static inline int32_t SkFloatToIntCeil(float x) { |
| 124 return SkFloatBits_toIntCeil(SkFloat2Bits(x)); | 124 return SkFloatBits_toIntCeil(SkFloat2Bits(x)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Scalar wrappers for float-bit routines | 127 // Scalar wrappers for float-bit routines |
| 128 | 128 |
| 129 #define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x) | 129 #define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x) |
| 130 #define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x) | 130 #define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x) |
| 131 | 131 |
| 132 #endif | 132 #endif |
| OLD | NEW |