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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 */ | 143 */ |
144 static inline int SkNextLog2(uint32_t value) { | 144 static inline int SkNextLog2(uint32_t value) { |
145 SkASSERT(value != 0); | 145 SkASSERT(value != 0); |
146 return 32 - SkCLZ(value - 1); | 146 return 32 - SkCLZ(value - 1); |
147 } | 147 } |
148 | 148 |
149 /** | 149 /** |
150 * Returns true if value is a power of 2. Does not explicitly check for | 150 * Returns true if value is a power of 2. Does not explicitly check for |
151 * value <= 0. | 151 * value <= 0. |
152 */ | 152 */ |
153 static inline bool SkIsPow2(int value) { | 153 template <typename T> inline bool SkIsPow2(T value) { |
154 return (value & (value - 1)) == 0; | 154 return (value & (value - 1)) == 0; |
155 } | 155 } |
156 | 156 |
157 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
158 | 158 |
159 /** | 159 /** |
160 * SkMulS16(a, b) multiplies a * b, but requires that a and b are both int16_t. | 160 * SkMulS16(a, b) multiplies a * b, but requires that a and b are both int16_t. |
161 * With this requirement, we can generate faster instructions on some | 161 * With this requirement, we can generate faster instructions on some |
162 * architectures. | 162 * architectures. |
163 */ | 163 */ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 *div = static_cast<Out>(d); | 223 *div = static_cast<Out>(d); |
224 *mod = static_cast<Out>(numer-d*denom); | 224 *mod = static_cast<Out>(numer-d*denom); |
225 #else | 225 #else |
226 // On x86 this will just be a single idiv. | 226 // On x86 this will just be a single idiv. |
227 *div = static_cast<Out>(numer/denom); | 227 *div = static_cast<Out>(numer/denom); |
228 *mod = static_cast<Out>(numer%denom); | 228 *mod = static_cast<Out>(numer%denom); |
229 #endif | 229 #endif |
230 } | 230 } |
231 | 231 |
232 #endif | 232 #endif |
OLD | NEW |