OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "Sk64.h" | 8 #include "Sk64.h" |
9 #include "SkMathPriv.h" | 9 #include "SkMathPriv.h" |
10 | 10 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 246 } |
247 denom <<= (dbits - 1); | 247 denom <<= (dbits - 1); |
248 shift_left_bits(hi, lo, nbits - 1); | 248 shift_left_bits(hi, lo, nbits - 1); |
249 } | 249 } |
250 | 250 |
251 int32_t rhi = 0; | 251 int32_t rhi = 0; |
252 uint32_t rlo = 0; | 252 uint32_t rlo = 0; |
253 | 253 |
254 do { | 254 do { |
255 shift_left(rhi, rlo); | 255 shift_left(rhi, rlo); |
256 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR | |
257 if ((uint32_t)denom <= (uint32_t)hi) | 256 if ((uint32_t)denom <= (uint32_t)hi) |
258 { | 257 { |
259 hi -= denom; | 258 hi -= denom; |
260 rlo |= 1; | 259 rlo |= 1; |
261 } | 260 } |
262 #else | |
263 int32_t diff = (denom - hi - 1) >> 31; | |
264 hi -= denom & diff; | |
265 rlo -= diff; | |
266 #endif | |
267 shift_left(hi, lo); | 261 shift_left(hi, lo); |
268 } while (--bits >= 0); | 262 } while (--bits >= 0); |
269 SkASSERT(rhi >= 0); | 263 SkASSERT(rhi >= 0); |
270 | 264 |
271 fHi = rhi; | 265 fHi = rhi; |
272 fLo = rlo; | 266 fLo = rlo; |
273 if (sign < 0) | 267 if (sign < 0) |
274 this->negate(); | 268 this->negate(); |
275 } | 269 } |
276 | 270 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 else | 345 else |
352 N.roundRight(-shiftN); | 346 N.roundRight(-shiftN); |
353 N.div(D.get32(), Sk64::kTrunc_DivOption); | 347 N.div(D.get32(), Sk64::kTrunc_DivOption); |
354 if (N.is32()) | 348 if (N.is32()) |
355 result = N.get32(); | 349 result = N.get32(); |
356 else | 350 else |
357 result = SK_MaxS32; | 351 result = SK_MaxS32; |
358 } | 352 } |
359 return SkApplySign(result, sign); | 353 return SkApplySign(result, sign); |
360 } | 354 } |
OLD | NEW |