| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 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 "SkMathPriv.h" | 8 #include "SkMathPriv.h" |
| 9 #include "SkFloatBits.h" | 9 #include "SkFloatBits.h" |
| 10 #include "SkFloatingPoint.h" | 10 #include "SkFloatingPoint.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 if (x & 0xC) { | 36 if (x & 0xC) { |
| 37 sub_shift(zeros, x, 2); | 37 sub_shift(zeros, x, 2); |
| 38 } | 38 } |
| 39 if (x & 0x2) { | 39 if (x & 0x2) { |
| 40 sub_shift(zeros, x, 1); | 40 sub_shift(zeros, x, 1); |
| 41 } | 41 } |
| 42 | 42 |
| 43 return zeros; | 43 return zeros; |
| 44 } | 44 } |
| 45 | 45 |
| 46 SkFixed SkFixedMul_portable(SkFixed a, SkFixed b) { | |
| 47 #if defined(SkLONGLONG) | |
| 48 return static_cast<SkFixed>((int64_t)a * b >> 16); | |
| 49 #else | |
| 50 int sa = SkExtractSign(a); | |
| 51 int sb = SkExtractSign(b); | |
| 52 // now make them positive | |
| 53 a = SkApplySign(a, sa); | |
| 54 b = SkApplySign(b, sb); | |
| 55 | |
| 56 uint32_t ah = a >> 16; | |
| 57 uint32_t al = a & 0xFFFF; | |
| 58 uint32_t bh = b >> 16; | |
| 59 uint32_t bl = b & 0xFFFF; | |
| 60 | |
| 61 uint32_t R = ah * b + al * bh + (al * bl >> 16); | |
| 62 | |
| 63 return SkApplySign(R, sa ^ sb); | |
| 64 #endif | |
| 65 } | |
| 66 | |
| 67 /////////////////////////////////////////////////////////////////////////////// | 46 /////////////////////////////////////////////////////////////////////////////// |
| 68 | 47 |
| 69 #define DIVBITS_ITER(n) \ | 48 #define DIVBITS_ITER(n) \ |
| 70 case n: \ | 49 case n: \ |
| 71 if ((numer = (numer << 1) - denom) >= 0) \ | 50 if ((numer = (numer << 1) - denom) >= 0) \ |
| 72 result |= 1 << (n - 1); else numer += denom | 51 result |= 1 << (n - 1); else numer += denom |
| 73 | 52 |
| 74 int32_t SkDivBits(int32_t numer, int32_t denom, int shift_bias) { | 53 int32_t SkDivBits(int32_t numer, int32_t denom, int shift_bias) { |
| 75 SkASSERT(denom != 0); | 54 SkASSERT(denom != 0); |
| 76 if (numer == 0) { | 55 if (numer == 0) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (SkScalarNearlyZero(*cosValue)) { | 146 if (SkScalarNearlyZero(*cosValue)) { |
| 168 *cosValue = 0; | 147 *cosValue = 0; |
| 169 } | 148 } |
| 170 } | 149 } |
| 171 | 150 |
| 172 if (SkScalarNearlyZero(sinValue)) { | 151 if (SkScalarNearlyZero(sinValue)) { |
| 173 sinValue = 0; | 152 sinValue = 0; |
| 174 } | 153 } |
| 175 return sinValue; | 154 return sinValue; |
| 176 } | 155 } |
| OLD | NEW |