Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: include/core/SkMath.h

Issue 21755002: Experiments on calculating reciprocal of square root (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Better calculate reciprocal of square root Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/MathBench.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « bench/MathBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698