Chromium Code Reviews| Index: src/core/SkFloatBits.cpp |
| diff --git a/src/core/SkFloatBits.cpp b/src/core/SkFloatBits.cpp |
| index 39b51abf1dc8a9939c41e69463ee50a37b9b1956..b0690e520970d85ac273ec202c0c54470a10dfab 100644 |
| --- a/src/core/SkFloatBits.cpp |
| +++ b/src/core/SkFloatBits.cpp |
| @@ -85,7 +85,14 @@ int32_t SkFloatBits_toIntFloor(int32_t packed) { |
| value = SkApplySign(value, SkExtractSign(packed)); |
| exp = -exp; |
| if (exp > 25) { // underflow |
| +#ifdef SK_FAST_UNDERFLOW_BEHAVIOR |
| + // The iOS ARM processor discards small denormalized numbers to go faster. |
| + // The comparision below empirically causes the result to agree with the |
| + // tests in MathTest test_float_floor |
| + if (exp > 149) return 0; |
|
reed1
2014/07/10 21:40:05
nit: {} and indentation
if (exp > 149) {
retu
caryclark
2014/07/11 12:57:19
Done.
|
| +#else |
| exp = 25; |
| +#endif |
| } |
| // int add = 0; |
| return value >> exp; |
| @@ -145,7 +152,15 @@ int32_t SkFloatBits_toIntCeil(int32_t packed) { |
| value = SkApplySign(value, SkExtractSign(packed)); |
| exp = -exp; |
| if (exp > 25) { // underflow |
| +#ifdef SK_FAST_UNDERFLOW_BEHAVIOR |
| + // The iOS ARM processor discards small denormalized numbers to go faster. |
| + // The comparision below empirically causes the result to agree with the |
| + // tests in MathTest test_float_ceil |
| + if (exp > 149) return 0; |
| + return 0 < value; |
| +#else |
| exp = 25; |
| +#endif |
| } |
| int add = (1 << exp) - 1; |
| return (value + add) >> exp; |