| 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 #ifndef SkNx_DEFINED | 8 #ifndef SkNx_DEFINED |
| 9 #define SkNx_DEFINED | 9 #define SkNx_DEFINED |
| 10 | 10 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 static double Sqrt(double val) { return ::sqrt ( val); } | 259 static double Sqrt(double val) { return ::sqrt ( val); } |
| 260 | 260 |
| 261 I pun() const { | 261 I pun() const { |
| 262 union { T f; I i; } pun = { fVal }; | 262 union { T f; I i; } pun = { fVal }; |
| 263 return pun.i; | 263 return pun.i; |
| 264 } | 264 } |
| 265 | 265 |
| 266 T fVal; | 266 T fVal; |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 // This default implementation can be specialized by ../opts/SkNx_foo.h |
| 270 // if there's a better platform-specific shuffle strategy. |
| 271 template <typename SkNx, int... Ix> |
| 272 inline SkNx SkNx_shuffle_impl(const SkNx& src) { return SkNx( src.template kth<I
x>()... ); } |
| 273 |
| 274 // This generic shuffle can be called on either SkNi or SkNf with 1 or N indices
: |
| 275 // Sk4f f(a,b,c,d); |
| 276 // SkNx_shuffle<3>(f); // ~~~> Sk4f(d,d,d,d) |
| 277 // SkNx_shuffle<2,1,0,3>(f); // ~~~> Sk4f(c,b,a,d) |
| 278 template <int... Ix, typename SkNx> |
| 279 inline SkNx SkNx_shuffle(const SkNx& src) { return SkNx_shuffle_impl<SkNx, Ix...
>(src); } |
| 280 |
| 281 // A reminder alias that shuffles can be used to duplicate a single index across
a vector. |
| 282 template <int Ix, typename SkNx> |
| 283 inline SkNx SkNx_dup(const SkNx& src) { return SkNx_shuffle<Ix>(src); } |
| 284 |
| 269 } // namespace | 285 } // namespace |
| 270 | 286 |
| 287 |
| 288 |
| 289 |
| 271 // Include platform specific specializations if available. | 290 // Include platform specific specializations if available. |
| 272 #ifndef SKNX_NO_SIMD | 291 #ifndef SKNX_NO_SIMD |
| 273 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 292 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
| 274 #include "../opts/SkNx_sse.h" | 293 #include "../opts/SkNx_sse.h" |
| 275 #elif defined(SK_ARM_HAS_NEON) | 294 #elif defined(SK_ARM_HAS_NEON) |
| 276 #include "../opts/SkNx_neon.h" | 295 #include "../opts/SkNx_neon.h" |
| 277 #endif | 296 #endif |
| 278 #endif | 297 #endif |
| 279 | 298 |
| 280 #undef REQUIRE | 299 #undef REQUIRE |
| 281 | 300 |
| 282 typedef SkNf<2, float> Sk2f; | 301 typedef SkNf<2, float> Sk2f; |
| 283 typedef SkNf<2, double> Sk2d; | 302 typedef SkNf<2, double> Sk2d; |
| 284 typedef SkNf<2, SkScalar> Sk2s; | 303 typedef SkNf<2, SkScalar> Sk2s; |
| 285 | 304 |
| 286 typedef SkNf<4, float> Sk4f; | 305 typedef SkNf<4, float> Sk4f; |
| 287 typedef SkNf<4, double> Sk4d; | 306 typedef SkNf<4, double> Sk4d; |
| 288 typedef SkNf<4, SkScalar> Sk4s; | 307 typedef SkNf<4, SkScalar> Sk4s; |
| 289 | 308 |
| 290 typedef SkNi<4, uint16_t> Sk4h; | 309 typedef SkNi<4, uint16_t> Sk4h; |
| 291 typedef SkNi<8, uint16_t> Sk8h; | 310 typedef SkNi<8, uint16_t> Sk8h; |
| 292 typedef SkNi<16, uint16_t> Sk16h; | 311 typedef SkNi<16, uint16_t> Sk16h; |
| 293 | 312 |
| 294 typedef SkNi<16, uint8_t> Sk16b; | 313 typedef SkNi<16, uint8_t> Sk16b; |
| 295 | 314 |
| 296 typedef SkNi<4, int32_t> Sk4i; | 315 typedef SkNi<4, int32_t> Sk4i; |
| 297 typedef SkNi<4, uint32_t> Sk4u; | 316 typedef SkNi<4, uint32_t> Sk4u; |
| 298 | 317 |
| 299 #endif//SkNx_DEFINED | 318 #endif//SkNx_DEFINED |
| OLD | NEW |