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

Unified Diff: src/core/SkNx.h

Issue 1301413006: SkNx_shuffle (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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..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
« 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