Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: src/core/SkNx.h

Issue 1301413006: SkNx_shuffle (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: dup Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698