Index: src/core/SkNx.h |
diff --git a/src/core/SkNx.h b/src/core/SkNx.h |
index ff94e0545870fa51bf9559b587fb615a3ca1e5bd..f8b27fc1ed0572c862839d80c707d2a3f25280f2 100644 |
--- a/src/core/SkNx.h |
+++ b/src/core/SkNx.h |
@@ -266,8 +266,27 @@ protected: |
T fVal; |
}; |
+// This default implementation can be specialized by ../opts/SkNx_foo.h |
+// if there's a better platform-specific shuffle strategy. |
+template <typename SkNx, int... Ix> |
+inline SkNx SkNx_shuffle_impl(const SkNx& src) { return SkNx( src.template kth<Ix>()... ); } |
+ |
+// This generic shuffle can be called on either SkNi or SkNf with 1 or N indices: |
+// Sk4f f(a,b,c,d); |
+// SkNx_shuffle<3>(f); // ~~~> Sk4f(d,d,d,d) |
+// SkNx_shuffle<2,1,0,3>(f); // ~~~> Sk4f(c,b,a,d) |
+template <int... Ix, typename SkNx> |
+inline SkNx SkNx_shuffle(const SkNx& src) { return SkNx_shuffle_impl<SkNx, Ix...>(src); } |
+ |
+// A reminder alias that shuffles can be used to duplicate a single index across a vector. |
+template <int Ix, typename SkNx> |
+inline SkNx SkNx_dup(const SkNx& src) { return SkNx_shuffle<Ix>(src); } |
+ |
} // namespace |
+ |
+ |
+ |
// Include platform specific specializations if available. |
#ifndef SKNX_NO_SIMD |
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |