Index: src/core/SkNx.h |
diff --git a/src/core/SkNx.h b/src/core/SkNx.h |
index ff94e0545870fa51bf9559b587fb615a3ca1e5bd..8d0ad720165b403b2adbdd8e35b49f1ab3c1c7f6 100644 |
--- a/src/core/SkNx.h |
+++ b/src/core/SkNx.h |
@@ -266,8 +266,23 @@ 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 either 1 or N indices: |
+// Sk4f(1,2,3,4) f; |
reed1
2015/09/01 15:45:03
do you mean Sk4f f(1,2,3,4); ?
Actually, I think
mtklein_C
2015/09/01 16:00:03
Yep, done.
|
+// SkNx_shuffle<0>(f); // ~~~> Sk4f(1,1,1,1) |
+// SkNx_shuffle<2,1,0,3>(f); // ~~~> Sk4f(3,2,1,4) |
+template <int... Ix, typename SkNx> |
+inline SkNx SkNx_shuffle(const SkNx& src) { return SkNx_shuffle_impl<SkNx, Ix...>(src); } |
+ |
} // namespace |
+ |
+ |
+ |
// Include platform specific specializations if available. |
#ifndef SKNX_NO_SIMD |
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |