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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 int dbits = SkCLZ(denom) - 1; | 65 int dbits = SkCLZ(denom) - 1; |
66 int bits = shift_bias - nbits + dbits; | 66 int bits = shift_bias - nbits + dbits; |
67 | 67 |
68 if (bits < 0) { // answer will underflow | 68 if (bits < 0) { // answer will underflow |
69 return 0; | 69 return 0; |
70 } | 70 } |
71 if (bits > 31) { // answer will overflow | 71 if (bits > 31) { // answer will overflow |
72 return SkApplySign(SK_MaxS32, sign); | 72 return SkApplySign(SK_MaxS32, sign); |
73 } | 73 } |
74 | 74 |
75 denom <<= dbits; | 75 denom *= 1 << dbits; |
76 numer <<= nbits; | 76 numer *= 1 << nbits; |
77 | 77 |
78 SkFixed result = 0; | 78 SkFixed result = 0; |
79 | 79 |
80 // do the first one | 80 // do the first one |
81 if ((numer -= denom) >= 0) { | 81 if ((numer -= denom) >= 0) { |
82 result = 1; | 82 result = 1; |
83 } else { | 83 } else { |
84 numer += denom; | 84 numer += denom; |
85 } | 85 } |
86 | 86 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 if (SkScalarNearlyZero(*cosValue)) { | 146 if (SkScalarNearlyZero(*cosValue)) { |
147 *cosValue = 0; | 147 *cosValue = 0; |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 if (SkScalarNearlyZero(sinValue)) { | 151 if (SkScalarNearlyZero(sinValue)) { |
152 sinValue = 0; | 152 sinValue = 0; |
153 } | 153 } |
154 return sinValue; | 154 return sinValue; |
155 } | 155 } |
OLD | NEW |