| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkNx.h" | 8 #include "SkNx.h" |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void test_Ni(skiatest::Reporter* r) { | 82 void test_Ni(skiatest::Reporter* r) { |
| 83 auto assert_eq = [&](const SkNi<N,T>& v, T a, T b, T c, T d, T e, T f, T g,
T h) { | 83 auto assert_eq = [&](const SkNi<N,T>& v, T a, T b, T c, T d, T e, T f, T g,
T h) { |
| 84 T vals[8]; | 84 T vals[8]; |
| 85 v.store(vals); | 85 v.store(vals); |
| 86 | 86 |
| 87 switch (N) { | 87 switch (N) { |
| 88 case 8: REPORTER_ASSERT(r, vals[4] == e && vals[5] == f && vals[6] ==
g && vals[7] == h); | 88 case 8: REPORTER_ASSERT(r, vals[4] == e && vals[5] == f && vals[6] ==
g && vals[7] == h); |
| 89 case 4: REPORTER_ASSERT(r, vals[2] == c && vals[3] == d); | 89 case 4: REPORTER_ASSERT(r, vals[2] == c && vals[3] == d); |
| 90 case 2: REPORTER_ASSERT(r, vals[0] == a && vals[1] == b); | 90 case 2: REPORTER_ASSERT(r, vals[0] == a && vals[1] == b); |
| 91 } | 91 } |
| 92 switch (N) { |
| 93 case 8: REPORTER_ASSERT(r, v.template kth<4>() == e && v.template kth<
5>() == f && |
| 94 v.template kth<6>() == g && v.template kth<
7>() == h); |
| 95 case 4: REPORTER_ASSERT(r, v.template kth<2>() == c && v.template kth<
3>() == d); |
| 96 case 2: REPORTER_ASSERT(r, v.template kth<0>() == a && v.template kth<
1>() == b); |
| 97 } |
| 92 }; | 98 }; |
| 93 | 99 |
| 94 T vals[] = { 1,2,3,4,5,6,7,8 }; | 100 T vals[] = { 1,2,3,4,5,6,7,8 }; |
| 95 SkNi<N,T> a = SkNi<N,T>::Load(vals), | 101 SkNi<N,T> a = SkNi<N,T>::Load(vals), |
| 96 b(a), | 102 b(a), |
| 97 c = a; | 103 c = a; |
| 98 SkNi<N,T> d; | 104 SkNi<N,T> d; |
| 99 d = a; | 105 d = a; |
| 100 | 106 |
| 101 assert_eq(a, 1,2,3,4,5,6,7,8); | 107 assert_eq(a, 1,2,3,4,5,6,7,8); |
| 102 assert_eq(b, 1,2,3,4,5,6,7,8); | 108 assert_eq(b, 1,2,3,4,5,6,7,8); |
| 103 assert_eq(c, 1,2,3,4,5,6,7,8); | 109 assert_eq(c, 1,2,3,4,5,6,7,8); |
| 104 assert_eq(d, 1,2,3,4,5,6,7,8); | 110 assert_eq(d, 1,2,3,4,5,6,7,8); |
| 105 | 111 |
| 106 assert_eq(a+a, 2,4,6,8,10,12,14,16); | 112 assert_eq(a+a, 2,4,6,8,10,12,14,16); |
| 107 assert_eq(a*a, 1,4,9,16,25,36,49,64); | 113 assert_eq(a*a, 1,4,9,16,25,36,49,64); |
| 108 assert_eq(a*a-a, 0,2,6,12,20,30,42,56); | 114 assert_eq(a*a-a, 0,2,6,12,20,30,42,56); |
| 109 | 115 |
| 110 assert_eq(a >> 2, 0,0,0,1,1,1,1,2); | 116 assert_eq(a >> 2, 0,0,0,1,1,1,1,2); |
| 111 assert_eq(a << 1, 2,4,6,8,10,12,14,16); | 117 assert_eq(a << 1, 2,4,6,8,10,12,14,16); |
| 112 | 118 |
| 113 REPORTER_ASSERT(r, a.template kth<1>() == 2); | 119 REPORTER_ASSERT(r, a.template kth<1>() == 2); |
| 114 } | 120 } |
| 115 | 121 |
| 116 DEF_TEST(SkNi, r) { | 122 DEF_TEST(SkNi, r) { |
| 117 test_Ni<2, uint16_t>(r); | 123 test_Ni<2, uint16_t>(r); |
| 118 test_Ni<4, uint16_t>(r); | 124 test_Ni<4, uint16_t>(r); |
| 119 test_Ni<8, uint16_t>(r); | 125 test_Ni<8, uint16_t>(r); |
| 126 |
| 127 test_Ni<2, int>(r); |
| 128 test_Ni<4, int>(r); |
| 129 test_Ni<8, int>(r); |
| 120 } | 130 } |
| OLD | NEW |