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

Unified Diff: src/core/Sk4x.h

Issue 634543004: Start to vectorize SkTileGrid. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: revert portable Created 6 years, 2 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 | « include/core/SkTypes.h ('k') | src/core/Sk4x_clang.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/Sk4x.h
diff --git a/src/core/Sk4x.h b/src/core/Sk4x.h
new file mode 100644
index 0000000000000000000000000000000000000000..97881240b18dacfb36ef60e27d1bf7c20085cefc
--- /dev/null
+++ b/src/core/Sk4x.h
@@ -0,0 +1,92 @@
+#ifndef Sk4x_DEFINED
+#define Sk4x_DEFINED
+
+#include "SkTypes.h"
+
+// First we'll let Clang try its best with whatever instructions are available.
+// Otherwise fall back on portable code. This really should be a last resort.
+
+#define SK4X_PREAMBLE 1
+ #if defined(__clang__)
+ #include "Sk4x_clang.h"
+ #else
+ #include "Sk4x_portable.h"
+ #endif
+#undef SK4X_PREAMBLE
+
+template <typename T> class Sk4x;
+typedef Sk4x<int> Sk4i;
+typedef Sk4x<float> Sk4f;
+
+template <typename T> class Sk4x {
+public:
+ Sk4x(); // Uninitialized; use Sk4x(0,0,0,0) for zero.
+ Sk4x(T, T, T, T);
+ explicit Sk4x(const T[4]);
+
+ Sk4x(const Sk4x&);
+ Sk4x& operator=(const Sk4x&);
+
+ void set(T, T, T, T);
+
+ void store(T[4]) const;
+
+ template <typename Dst> Dst reinterpret() const;
+ template <typename Dst> Dst cast() const;
+
+ bool allTrue() const;
+ bool anyTrue() const;
+
+ Sk4x bitNot() const;
+ Sk4x bitAnd(const Sk4x&) const;
+ Sk4x bitOr (const Sk4x&) const;
+
+ Sk4i equal(const Sk4x&) const;
+ Sk4i notEqual(const Sk4x&) const;
+ Sk4i lessThan(const Sk4x&) const;
+ Sk4i greaterThan(const Sk4x&) const;
+ Sk4i lessThanEqual(const Sk4x&) const;
+ Sk4i greaterThanEqual(const Sk4x&) const;
+
+ Sk4x add(const Sk4x&) const;
+ Sk4x subtract(const Sk4x&) const;
+ Sk4x multiply(const Sk4x&) const;
+ Sk4x divide(const Sk4x&) const;
+
+ static Sk4x Min(const Sk4x& a, const Sk4x& b);
+ static Sk4x Max(const Sk4x& a, const Sk4x& b);
+
+ // Swizzles follow OpenCL xyzw convention.
+ Sk4x zwxy() const;
+
+ // When there's a second argument, it's abcd.
+ static Sk4x XYAB(const Sk4x& xyzw, const Sk4x& abcd);
+ static Sk4x ZWCD(const Sk4x& xyzw, const Sk4x& abcd);
+
+private:
+ // It's handy to have Sk4f and Sk4i be mutual friends.
+ template <typename S> friend class Sk4x;
+
+#define SK4X_PRIVATE 1
+ #if defined(__clang__)
+ #include "Sk4x_clang.h"
+ #else
+ #include "Sk4x_portable.h"
+ #endif
+#undef SK4X_PRIVATE
+};
+
+#if defined(__clang__)
+ #include "Sk4x_clang.h"
+#else
+ #include "Sk4x_portable.h"
+#endif
+
+// TODO ideas for enterprising coders:
+// 1) Add Sk4x_gcc.h? __builtin_shuffle is fairly new, which is a pain.
+// 2) Sk4x_sse.h would be good for Windows, and could possibly beat _clang / _gcc
+// (e.g. they can't generate _mm_movemask_ps for allTrue/anyTrue).
+// 3) Sk4x_neon.h might be a good idea if _clang / _gcc aren't good enough on ARM.
+
+
+#endif//Sk4x_DEFINED
« no previous file with comments | « include/core/SkTypes.h ('k') | src/core/Sk4x_clang.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698