Add sk_float_rsqrt with SSE + NEON fast paths.

Current numbers:

N4:
running bench [640 480]      math_fastIsqrt    NONRENDERING: cmsecs =      3.12
running bench [640 480]      math_slowIsqrt    NONRENDERING: cmsecs =      4.82
running bench [640 480] math_sk_float_rsqrt    NONRENDERING: cmsecs =      1.99

Desktop:
running bench [640 480]      math_fastIsqrt    NONRENDERING: cmsecs =      0.89
running bench [640 480]      math_slowIsqrt    NONRENDERING: cmsecs =      0.94
running bench [640 480] math_sk_float_rsqrt    NONRENDERING: cmsecs =      0.09

Haven't found any other benches where this is a significant effect yet.

BUG=
R=reed@google.com

Author: mtklein@google.com

Review URL: https://codereview.chromium.org/60083014

git-svn-id: http://skia.googlecode.com/svn/trunk@12203 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PointTest.cpp b/tests/PointTest.cpp
index 1255a8c..9f91c47 100644
--- a/tests/PointTest.cpp
+++ b/tests/PointTest.cpp
@@ -117,7 +117,8 @@
     REPORTER_ASSERT(reporter, pt == copy);  // pt is unchanged
 }
 
-static void PointTest(skiatest::Reporter* reporter) {
+#include "TestClassDef.h"
+DEF_TEST(Point, reporter) {
     test_casts(reporter);
 
     static const struct {
@@ -137,5 +138,22 @@
     test_overflow(reporter);
 }
 
-#include "TestClassDef.h"
-DEFINE_TESTCLASS("Point", PointTestClass, PointTest)
+DEF_TEST(Point_setLengthFast, reporter) {
+    // Scale a (1,1) point to a bunch of different lengths,
+    // making sure the slow and fast paths are within 0.1%.
+    const float tests[] = { 1.0f, 0.0f, 1.0e-37f, 3.4e38f, 42.0f, 0.00012f };
+
+    const SkPoint kOne = {1.0f, 1.0f};
+    for (unsigned i = 0; i < SK_ARRAY_COUNT(tests); i++) {
+        SkPoint slow = kOne, fast = kOne;
+
+        slow.setLength(tests[i]);
+        fast.setLengthFast(tests[i]);
+
+        if (slow.length() < FLT_MIN && fast.length() < FLT_MIN) continue;
+
+        SkScalar ratio = slow.length() / fast.length();
+        REPORTER_ASSERT(reporter, ratio > 0.999f);
+        REPORTER_ASSERT(reporter, ratio < 1.001f);
+    }
+}