| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkFloatBits.h" | 8 #include "SkFloatBits.h" |
| 9 #include "SkMathPriv.h" | 9 #include "SkMathPriv.h" |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 // now value is left-aligned to 24 bits | 198 // now value is left-aligned to 24 bits |
| 199 SkASSERT((value >> 23) == 1); | 199 SkASSERT((value >> 23) == 1); |
| 200 SkASSERT(shift >= 0 && shift <= 255); | 200 SkASSERT(shift >= 0 && shift <= 255); |
| 201 | 201 |
| 202 SkFloatIntUnion data; | 202 SkFloatIntUnion data; |
| 203 data.fSignBitInt = (sign << 31) | (shift << 23) | (value & ~MATISSA_MAGIC_BI
G); | 203 data.fSignBitInt = (sign << 31) | (shift << 23) | (value & ~MATISSA_MAGIC_BI
G); |
| 204 return data.fFloat; | 204 return data.fFloat; |
| 205 } | 205 } |
| 206 | |
| 207 float SkIntToFloatCast_NoOverflowCheck(int32_t value) { | |
| 208 if (0 == value) { | |
| 209 return 0; | |
| 210 } | |
| 211 | |
| 212 int shift = EXP_BIAS; | |
| 213 | |
| 214 // record the sign and make value positive | |
| 215 int sign = SkExtractSign(value); | |
| 216 value = SkApplySign(value, sign); | |
| 217 | |
| 218 int zeros = SkCLZ(value << 8); | |
| 219 value <<= zeros; | |
| 220 shift -= zeros; | |
| 221 | |
| 222 SkFloatIntUnion data; | |
| 223 data.fSignBitInt = (sign << 31) | (shift << 23) | (value & ~MATISSA_MAGIC_BI
G); | |
| 224 return data.fFloat; | |
| 225 } | |
| OLD | NEW |