OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkMath_DEFINED | 10 #ifndef SkMath_DEFINED |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 * the result overflows 32bits. | 46 * the result overflows 32bits. |
47 */ | 47 */ |
48 static inline int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) { | 48 static inline int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) { |
49 SkASSERT(denom); | 49 SkASSERT(denom); |
50 | 50 |
51 int64_t tmp = sk_64_mul(numer1, numer2) / denom; | 51 int64_t tmp = sk_64_mul(numer1, numer2) / denom; |
52 return sk_64_asS32(tmp); | 52 return sk_64_asS32(tmp); |
53 } | 53 } |
54 | 54 |
55 /** | 55 /** |
56 * Computes (numer1 << shift) / denom in full 64 intermediate precision. | |
57 * It is an error for denom to be 0. There is no special handling if | |
58 * the result overflows 32bits. | |
59 */ | |
60 int32_t SkDivBits(int32_t numer, int32_t denom, int shift); | |
61 | |
62 /** | |
63 * Return the integer square root of value, with a bias of bitBias | 56 * Return the integer square root of value, with a bias of bitBias |
64 */ | 57 */ |
65 int32_t SkSqrtBits(int32_t value, int bitBias); | 58 int32_t SkSqrtBits(int32_t value, int bitBias); |
66 | 59 |
67 /** Return the integer square root of n, treated as a SkFixed (16.16) | 60 /** Return the integer square root of n, treated as a SkFixed (16.16) |
68 */ | 61 */ |
69 #define SkSqrt32(n) SkSqrtBits(n, 15) | 62 #define SkSqrt32(n) SkSqrtBits(n, 15) |
70 | 63 |
71 //! Returns the number of leading zero bits (0...32) | 64 //! Returns the number of leading zero bits (0...32) |
72 int SkCLZ_portable(uint32_t); | 65 int SkCLZ_portable(uint32_t); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 *div = static_cast<Out>(d); | 188 *div = static_cast<Out>(d); |
196 *mod = static_cast<Out>(numer-d*denom); | 189 *mod = static_cast<Out>(numer-d*denom); |
197 #else | 190 #else |
198 // On x86 this will just be a single idiv. | 191 // On x86 this will just be a single idiv. |
199 *div = static_cast<Out>(numer/denom); | 192 *div = static_cast<Out>(numer/denom); |
200 *mod = static_cast<Out>(numer%denom); | 193 *mod = static_cast<Out>(numer%denom); |
201 #endif | 194 #endif |
202 } | 195 } |
203 | 196 |
204 #endif | 197 #endif |
OLD | NEW |