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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 * Return a*b/255, rounding any fractional bits. | 166 * Return a*b/255, rounding any fractional bits. |
167 * Only valid if a and b are unsigned and <= 32767. | 167 * Only valid if a and b are unsigned and <= 32767. |
168 */ | 168 */ |
169 static inline U8CPU SkMulDiv255Round(U16CPU a, U16CPU b) { | 169 static inline U8CPU SkMulDiv255Round(U16CPU a, U16CPU b) { |
170 SkASSERT(a <= 32767); | 170 SkASSERT(a <= 32767); |
171 SkASSERT(b <= 32767); | 171 SkASSERT(b <= 32767); |
172 unsigned prod = SkMulS16(a, b) + 128; | 172 unsigned prod = SkMulS16(a, b) + 128; |
173 return (prod + (prod >> 8)) >> 8; | 173 return (prod + (prod >> 8)) >> 8; |
174 } | 174 } |
175 | 175 |
176 static inline float SkFloatInvSqrt(float x) { | |
reed1
2013/08/12 14:05:54
Need dox for a public API
1. Should probably be r
Yang Gu
2013/08/13 03:33:31
We may add "fast" into name (e.g., SkFloatFastInvS
| |
177 float xhalf = 0.5f * x; | |
178 int i = *SkTCast<int*>(&x); | |
179 i = 0x5f3759df - (i >> 1); | |
180 x = *SkTCast<float*>(&i); | |
181 x = x * (1.5f - xhalf * x * x); | |
182 return x; | |
183 } | |
184 | |
176 #endif | 185 #endif |
OLD | NEW |