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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } else { | 78 } else { |
79 value <<= exp; | 79 value <<= exp; |
80 } | 80 } |
81 // apply the sign after we check for overflow | 81 // apply the sign after we check for overflow |
82 return SkApplySign(value, SkExtractSign(packed)); | 82 return SkApplySign(value, SkExtractSign(packed)); |
83 } else { | 83 } else { |
84 // apply the sign before we right-shift | 84 // apply the sign before we right-shift |
85 value = SkApplySign(value, SkExtractSign(packed)); | 85 value = SkApplySign(value, SkExtractSign(packed)); |
86 exp = -exp; | 86 exp = -exp; |
87 if (exp > 25) { // underflow | 87 if (exp > 25) { // underflow |
88 #ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED | 88 #ifdef SK_CPU_FLUSH_TO_ZERO |
89 // The iOS ARM processor discards small denormalized numbers to go faste
r. | 89 // The iOS ARM processor discards small denormalized numbers to go faste
r. |
90 // The comparision below empirically causes the result to agree with the | 90 // The comparision below empirically causes the result to agree with the |
91 // tests in MathTest test_float_floor | 91 // tests in MathTest test_float_floor |
92 if (exp > 149) { | 92 if (exp > 149) { |
93 return 0; | 93 return 0; |
94 } | 94 } |
95 #else | 95 #else |
96 exp = 25; | 96 exp = 25; |
97 #endif | 97 #endif |
98 } | 98 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } else { | 147 } else { |
148 value <<= exp; | 148 value <<= exp; |
149 } | 149 } |
150 // apply the sign after we check for overflow | 150 // apply the sign after we check for overflow |
151 return SkApplySign(value, SkExtractSign(packed)); | 151 return SkApplySign(value, SkExtractSign(packed)); |
152 } else { | 152 } else { |
153 // apply the sign before we right-shift | 153 // apply the sign before we right-shift |
154 value = SkApplySign(value, SkExtractSign(packed)); | 154 value = SkApplySign(value, SkExtractSign(packed)); |
155 exp = -exp; | 155 exp = -exp; |
156 if (exp > 25) { // underflow | 156 if (exp > 25) { // underflow |
157 #ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED | 157 #ifdef SK_CPU_FLUSH_TO_ZERO |
158 // The iOS ARM processor discards small denormalized numbers to go faste
r. | 158 // The iOS ARM processor discards small denormalized numbers to go faste
r. |
159 // The comparision below empirically causes the result to agree with the | 159 // The comparision below empirically causes the result to agree with the |
160 // tests in MathTest test_float_ceil | 160 // tests in MathTest test_float_ceil |
161 if (exp > 149) { | 161 if (exp > 149) { |
162 return 0; | 162 return 0; |
163 } | 163 } |
164 return 0 < value; | 164 return 0 < value; |
165 #else | 165 #else |
166 exp = 25; | 166 exp = 25; |
167 #endif | 167 #endif |
(...skipping 28 matching lines...) Expand all 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 } |
OLD | NEW |