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 "Sk4px.h" | 8 #include "Sk4px.h" |
9 #include "SkNx.h" | 9 #include "SkNx.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 DEF_TEST(SkNx_abs, r) { | 210 DEF_TEST(SkNx_abs, r) { |
211 auto fs = Sk4f(0.0f, -0.0f, 2.0f, -4.0f).abs(); | 211 auto fs = Sk4f(0.0f, -0.0f, 2.0f, -4.0f).abs(); |
212 REPORTER_ASSERT(r, fs.kth<0>() == 0.0f); | 212 REPORTER_ASSERT(r, fs.kth<0>() == 0.0f); |
213 REPORTER_ASSERT(r, fs.kth<1>() == 0.0f); | 213 REPORTER_ASSERT(r, fs.kth<1>() == 0.0f); |
214 REPORTER_ASSERT(r, fs.kth<2>() == 2.0f); | 214 REPORTER_ASSERT(r, fs.kth<2>() == 2.0f); |
215 REPORTER_ASSERT(r, fs.kth<3>() == 4.0f); | 215 REPORTER_ASSERT(r, fs.kth<3>() == 4.0f); |
216 } | 216 } |
217 | 217 |
| 218 DEF_TEST(SkNx_floor, r) { |
| 219 auto fs = Sk4f(0.4f, -0.4f, 0.6f, -0.6f).floor(); |
| 220 REPORTER_ASSERT(r, fs.kth<0>() == 0.0f); |
| 221 REPORTER_ASSERT(r, fs.kth<1>() == -1.0f); |
| 222 REPORTER_ASSERT(r, fs.kth<2>() == 0.0f); |
| 223 REPORTER_ASSERT(r, fs.kth<3>() == -1.0f); |
| 224 } |
| 225 |
218 DEF_TEST(SkNx_shuffle, r) { | 226 DEF_TEST(SkNx_shuffle, r) { |
219 Sk4f f4(0,10,20,30); | 227 Sk4f f4(0,10,20,30); |
220 | 228 |
221 Sk2f f2 = SkNx_shuffle<2,1>(f4); | 229 Sk2f f2 = SkNx_shuffle<2,1>(f4); |
222 REPORTER_ASSERT(r, f2[0] == 20); | 230 REPORTER_ASSERT(r, f2[0] == 20); |
223 REPORTER_ASSERT(r, f2[1] == 10); | 231 REPORTER_ASSERT(r, f2[1] == 10); |
224 | 232 |
225 f4 = SkNx_shuffle<0,1,1,0>(f2); | 233 f4 = SkNx_shuffle<0,1,1,0>(f2); |
226 REPORTER_ASSERT(r, f4[0] == 20); | 234 REPORTER_ASSERT(r, f4[0] == 20); |
227 REPORTER_ASSERT(r, f4[1] == 10); | 235 REPORTER_ASSERT(r, f4[1] == 10); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), | 268 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), |
261 }; | 269 }; |
262 auto u4_0 = Sk4h::Load(s16); | 270 auto u4_0 = Sk4h::Load(s16); |
263 auto f4 = SkNx_cast<float>(u4_0); | 271 auto f4 = SkNx_cast<float>(u4_0); |
264 auto u4_1 = SkNx_cast<uint16_t>(f4); | 272 auto u4_1 = SkNx_cast<uint16_t>(f4); |
265 uint16_t d16[4]; | 273 uint16_t d16[4]; |
266 u4_1.store(d16); | 274 u4_1.store(d16); |
267 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); | 275 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); |
268 } | 276 } |
269 } | 277 } |
OLD | NEW |