Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2015 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SkFloatingPoint_opts_DEFINED | |
| 9 #define SkFloatingPoint_opts_DEFINED | |
| 10 | |
| 11 #include "SkFloatingPoint.h" | |
| 12 | |
| 13 namespace SK_OPTS_NS { | |
| 14 | |
| 15 #if defined(SK_ARM_HAS_NEON) | |
| 16 static float rsqrt(float x) { | |
| 17 return sk_float_rsqrt(x); // This sk_float_rsqrt copy will take the NEO N compile-time path. | |
| 18 } | |
| 19 #else | |
| 20 static float rsqrt(float x) { | |
|
mtklein
2016/01/22 13:53:02
The portable rsqrt() logic has not changed.
It's
| |
| 21 // Get initial estimate. | |
| 22 int i = *SkTCast<int*>(&x); | |
| 23 i = 0x5F1FFFF9 - (i>>1); | |
| 24 float estimate = *SkTCast<float*>(&i); | |
| 25 | |
| 26 // One step of Newton's method to refine. | |
| 27 const float estimate_sq = estimate*estimate; | |
| 28 estimate *= 0.703952253f*(2.38924456f-x*estimate_sq); | |
| 29 return estimate; | |
| 30 } | |
| 31 #endif | |
| 32 | |
| 33 } // namespace SK_OPTS_NS | |
| 34 | |
| 35 #endif//SkFloatingPoint_opts_DEFINED | |
| OLD | NEW |