Add SkNx_cast().

SkNx_cast() can cast between any of our vector types,
provided they have the same number of elements.

Any types should work with the default implementation,
and we can drop in specializations as needed, like the
SSE and NEON Sk4f -> Sk4i I included here as an example.

To make this work, I made some internal name changes:
    SkNi<N,T> -> SkNx<N, T>
    SkNf<N>   -> SkNx<N, float>
User aliases (Sk4f, Sk16b, etc.) stay the same.
We can land this first (it's PS1) if that makes things easier.

BUG=skia:
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot

Review URL: https://codereview.chromium.org/1464623002
diff --git a/tests/SkNxTest.cpp b/tests/SkNxTest.cpp
index 31baebc..b3e03d0 100644
--- a/tests/SkNxTest.cpp
+++ b/tests/SkNxTest.cpp
@@ -13,7 +13,8 @@
 template <int N>
 static void test_Nf(skiatest::Reporter* r) {
 
-    auto assert_nearly_eq = [&](float eps, const SkNf<N>& v, float a, float b, float c, float d) {
+    auto assert_nearly_eq = [&](float eps, const SkNx<N, float>& v,
+                                float a, float b, float c, float d) {
         auto close = [=](float a, float b) { return fabsf(a-b) <= eps; };
         float vals[4];
         v.store(vals);
@@ -26,15 +27,15 @@
             REPORTER_ASSERT(r, ok);
         }
     };
-    auto assert_eq = [&](const SkNf<N>& v, float a, float b, float c, float d) {
+    auto assert_eq = [&](const SkNx<N, float>& v, float a, float b, float c, float d) {
         return assert_nearly_eq(0, v, a,b,c,d);
     };
 
     float vals[] = {3, 4, 5, 6};
-    SkNf<N> a = SkNf<N>::Load(vals),
-            b(a),
-            c = a;
-    SkNf<N> d;
+    SkNx<N,float> a = SkNx<N,float>::Load(vals),
+                  b(a),
+                  c = a;
+    SkNx<N,float> d;
     d = a;
 
     assert_eq(a, 3, 4, 5, 6);
@@ -47,9 +48,9 @@
     assert_eq(a*b-b, 6, 12, 20, 30);
     assert_eq((a*b).sqrt(), 3, 4, 5, 6);
     assert_eq(a/b, 1, 1, 1, 1);
-    assert_eq(SkNf<N>(0)-a, -3, -4, -5, -6);
+    assert_eq(SkNx<N,float>(0)-a, -3, -4, -5, -6);
 
-    SkNf<N> fours(4);
+    SkNx<N,float> fours(4);
 
     assert_eq(fours.sqrt(), 2,2,2,2);
     assert_nearly_eq(0.001f, fours.rsqrt0(), 0.5, 0.5, 0.5, 0.5);
@@ -59,8 +60,8 @@
     assert_eq(               fours.      invert(), 0.25, 0.25, 0.25, 0.25);
     assert_nearly_eq(0.001f, fours.approxInvert(), 0.25, 0.25, 0.25, 0.25);
 
-    assert_eq(SkNf<N>::Min(a, fours), 3, 4, 4, 4);
-    assert_eq(SkNf<N>::Max(a, fours), 4, 4, 5, 6);
+    assert_eq(SkNx<N,float>::Min(a, fours), 3, 4, 4, 4);
+    assert_eq(SkNx<N,float>::Max(a, fours), 4, 4, 5, 6);
 
     // Test some comparisons.  This is not exhaustive.
     REPORTER_ASSERT(r, (a == b).allTrue());
@@ -81,7 +82,7 @@
 
 template <int N, typename T>
 void test_Ni(skiatest::Reporter* r) {
-    auto assert_eq = [&](const SkNi<N,T>& v, T a, T b, T c, T d, T e, T f, T g, T h) {
+    auto assert_eq = [&](const SkNx<N,T>& v, T a, T b, T c, T d, T e, T f, T g, T h) {
         T vals[8];
         v.store(vals);
 
@@ -99,10 +100,10 @@
     };
 
     T vals[] = { 1,2,3,4,5,6,7,8 };
-    SkNi<N,T> a = SkNi<N,T>::Load(vals),
+    SkNx<N,T> a = SkNx<N,T>::Load(vals),
               b(a),
               c = a;
-    SkNi<N,T> d;
+    SkNx<N,T> d;
     d = a;
 
     assert_eq(a, 1,2,3,4,5,6,7,8);
@@ -120,7 +121,7 @@
     REPORTER_ASSERT(r, a.template kth<1>() == 2);
 }
 
-DEF_TEST(SkNi, r) {
+DEF_TEST(SkNx, r) {
     test_Ni<2, uint16_t>(r);
     test_Ni<4, uint16_t>(r);
     test_Ni<8, uint16_t>(r);
@@ -220,3 +221,13 @@
     REPORTER_ASSERT(r, bytes[2] == 255);
     REPORTER_ASSERT(r, bytes[3] == 255);
 }
+
+DEF_TEST(SkNx_cast, r) {
+    Sk4f fs(-1.7f, -1.4f, 0.5f, 1.9f);
+    Sk4i is = SkNx_cast<int>(fs);
+
+    REPORTER_ASSERT(r, is.kth<0>() == -1);
+    REPORTER_ASSERT(r, is.kth<1>() == -1);
+    REPORTER_ASSERT(r, is.kth<2>() ==  0);
+    REPORTER_ASSERT(r, is.kth<3>() ==  1);
+}