OLD | NEW |
| (Empty) |
1 #ifndef Sk4x_DEFINED | |
2 #define Sk4x_DEFINED | |
3 | |
4 #include "SkTypes.h" | |
5 | |
6 // First we'll let Clang or GCC try their best with whatever instructions are av
ailable. | |
7 // Otherwise fall back on portable code. This really should be a last resort. | |
8 | |
9 #define SK4X_PREAMBLE 1 | |
10 #if defined(__clang__) | |
11 #include "Sk4x_clang.h" | |
12 #elif defined(__GNUC__) | |
13 #include "Sk4x_gcc.h" | |
14 #else | |
15 #include "Sk4x_portable.h" | |
16 #endif | |
17 #undef SK4X_PREAMBLE | |
18 | |
19 template <typename T> class Sk4x; | |
20 typedef Sk4x<int> Sk4i; | |
21 typedef Sk4x<float> Sk4f; | |
22 | |
23 template <typename T> class Sk4x { | |
24 public: | |
25 Sk4x(); // Uninitialized; use Sk4x(0,0,0,0) for zero. | |
26 Sk4x(T, T, T, T); | |
27 explicit Sk4x(const T[4]); | |
28 | |
29 Sk4x(const Sk4x&); | |
30 Sk4x& operator=(const Sk4x&); | |
31 | |
32 void set(T, T, T, T); | |
33 | |
34 void store(T[4]) const; | |
35 | |
36 template <typename Dst> Dst reinterpret() const; | |
37 template <typename Dst> Dst cast() const; | |
38 | |
39 bool allTrue() const; | |
40 bool anyTrue() const; | |
41 | |
42 Sk4x bitNot() const; | |
43 Sk4x bitAnd(const Sk4x&) const; | |
44 Sk4x bitOr (const Sk4x&) const; | |
45 | |
46 Sk4i equal(const Sk4x&) const; | |
47 Sk4i notEqual(const Sk4x&) const; | |
48 Sk4i lessThan(const Sk4x&) const; | |
49 Sk4i greaterThan(const Sk4x&) const; | |
50 Sk4i lessThanEqual(const Sk4x&) const; | |
51 Sk4i greaterThanEqual(const Sk4x&) const; | |
52 | |
53 Sk4x add(const Sk4x&) const; | |
54 Sk4x subtract(const Sk4x&) const; | |
55 Sk4x multiply(const Sk4x&) const; | |
56 Sk4x divide(const Sk4x&) const; | |
57 | |
58 static Sk4x Min(const Sk4x& a, const Sk4x& b); | |
59 static Sk4x Max(const Sk4x& a, const Sk4x& b); | |
60 | |
61 // Swizzles follow OpenCL xyzw convention. | |
62 Sk4x zwxy() const; | |
63 | |
64 // When there's a second argument, it's abcd. | |
65 static Sk4x XYAB(const Sk4x& xyzw, const Sk4x& abcd); | |
66 static Sk4x ZWCD(const Sk4x& xyzw, const Sk4x& abcd); | |
67 | |
68 private: | |
69 // It's handy to have Sk4f and Sk4i be mutual friends. | |
70 template <typename S> friend class Sk4x; | |
71 | |
72 #define SK4X_PRIVATE 1 | |
73 #if defined(__clang__) | |
74 #include "Sk4x_clang.h" | |
75 #elif defined(__GNUC__) | |
76 #include "Sk4x_gcc.h" | |
77 #else | |
78 #include "Sk4x_portable.h" | |
79 #endif | |
80 #undef SK4X_PRIVATE | |
81 }; | |
82 | |
83 #if defined(__clang__) | |
84 #include "Sk4x_clang.h" | |
85 #elif defined(__GNUC__) | |
86 #include "Sk4x_gcc.h" | |
87 #else | |
88 #include "Sk4x_portable.h" | |
89 #endif | |
90 | |
91 // TODO ideas for enterprising coders: | |
92 // 1) Code generated for Max() isn't as good in Sk4x_gcc.h as it is in _clang.
Why? | |
93 // 2) Sk4x_sse.h would be good for Windows, and could possibly beat _clang / _
gcc | |
94 // (e.g. they can't generate _mm_movemask_ps for allTrue/anyTrue). | |
95 // 3) Sk4x_neon.h might be a good idea if _clang / _gcc aren't good enough on
ARM. | |
96 | |
97 | |
98 #endif//Sk4x_DEFINED | |
OLD | NEW |