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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/MathBench.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkMath.h
diff --git a/include/core/SkMath.h b/include/core/SkMath.h
index 078c8fccdc2206975c07ed830222fe82f7e710af..66df00f40813514fe347a41df418392276431986 100644
--- a/include/core/SkMath.h
+++ b/include/core/SkMath.h
@@ -173,4 +173,13 @@ static inline U8CPU SkMulDiv255Round(U16CPU a, U16CPU b) {
return (prod + (prod >> 8)) >> 8;
}
+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
+ float xhalf = 0.5f * x;
+ int i = *SkTCast<int*>(&x);
+ i = 0x5f3759df - (i >> 1);
+ x = *SkTCast<float*>(&i);
+ x = x * (1.5f - xhalf * x * x);
+ return x;
+}
+
#endif
« 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