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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 void Sk64::abs() | 127 void Sk64::abs() |
128 { | 128 { |
129 if (fHi < 0) | 129 if (fHi < 0) |
130 { | 130 { |
131 fHi = -fHi - Sk32ToBool(fLo); | 131 fHi = -fHi - Sk32ToBool(fLo); |
132 fLo = 0 - fLo; | 132 fLo = 0 - fLo; |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 //////////////////////////////////////////////////////////////// | |
137 | |
138 static inline int32_t round_right_16(int32_t hi, uint32_t lo) | |
139 { | |
140 uint32_t sum = lo + (1 << 15); | |
141 hi += (sum < lo); | |
142 return (hi << 16) | (sum >> 16); | |
143 } | |
144 | |
145 SkBool Sk64::isFixed() const | 136 SkBool Sk64::isFixed() const |
146 { | 137 { |
147 Sk64 tmp = *this; | 138 Sk64 tmp = *this; |
148 tmp.roundRight(16); | 139 tmp.roundRight(16); |
149 return tmp.is32(); | 140 return tmp.is32(); |
150 } | 141 } |
151 | 142 |
152 SkFract Sk64::getFract() const | 143 SkFract Sk64::getFract() const |
153 { | 144 { |
154 Sk64 tmp = *this; | 145 Sk64 tmp = *this; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 else | 336 else |
346 N.roundRight(-shiftN); | 337 N.roundRight(-shiftN); |
347 N.div(D.get32(), Sk64::kTrunc_DivOption); | 338 N.div(D.get32(), Sk64::kTrunc_DivOption); |
348 if (N.is32()) | 339 if (N.is32()) |
349 result = N.get32(); | 340 result = N.get32(); |
350 else | 341 else |
351 result = SK_MaxS32; | 342 result = SK_MaxS32; |
352 } | 343 } |
353 return SkApplySign(result, sign); | 344 return SkApplySign(result, sign); |
354 } | 345 } |
OLD | NEW |