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

Side by Side Diff: src/core/Sk4x_clang.h

Issue 637863005: Revert of Start to vectorize SkTileGrid. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/core/Sk4x.h ('k') | src/core/Sk4x_portable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // It is important _not_ to put header guards here.
2 // This file will be intentionally included three times.
3
4 // Useful reading:
5 // http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vec tors
6
7 #if defined(SK4X_PREAMBLE)
8
9 #elif defined(SK4X_PRIVATE)
10 typedef T Vector __attribute__((ext_vector_type(4)));
11
12 /*implicit*/ Sk4x(Vector vec) : fVec(vec) {}
13
14 template <int m, int a, int s, int k>
15 static Sk4x Shuffle(const Sk4x&, const Sk4x&);
16
17 Vector fVec;
18
19 #else // defined(SK4X_PRIVATE)
20
21 template <typename T>
22 Sk4x<T>::Sk4x() { }
23
24 template <typename T>
25 Sk4x<T>::Sk4x(T a, T b, T c, T d) { this->set(a,b,c,d); }
26
27 template <typename T>
28 Sk4x<T>::Sk4x(const T vals[4]) { this->set(vals[0], vals[1], vals[2], vals[3]); }
29
30 template <typename T>
31 Sk4x<T>::Sk4x(const Sk4x<T>& other) { *this = other; }
32
33 template <typename T>
34 Sk4x<T>& Sk4x<T>::operator=(const Sk4x<T>& other) { fVec = other.fVec; return *t his; }
35
36 template <typename T>
37 void Sk4x<T>::set(T a, T b, T c, T d) {
38 Vector v = { a, b, c, d };
39 fVec = v;
40 }
41
42 template <typename T>
43 void Sk4x<T>::store(T vals[4]) const {
44 SkASSERT(SkIsAlign16((uintptr_t)vals));
45 *reinterpret_cast<Vector*>(vals) = fVec;
46 }
47
48 template <typename T>
49 template <typename Dst> Dst Sk4x<T>::reinterpret() const {
50 return Dst((typename Dst::Vector)fVec);
51 }
52
53 template <typename T>
54 template <typename Dst> Dst Sk4x<T>::cast() const {
55 #if __has_builtin(__builtin_convertvector)
56 return Dst(__builtin_convertvector(fVec, typename Dst::Vector));
57 #else
58 return Dst(fVec[0], fVec[1], fVec[2], fVec[3]);
59 #endif
60 }
61
62 template <typename T>
63 bool Sk4x<T>::allTrue() const { return fVec[0] & fVec[1] & fVec[2] & fVec[3]; }
64 template <typename T>
65 bool Sk4x<T>::anyTrue() const { return fVec[0] | fVec[1] | fVec[2] | fVec[3]; }
66
67 template <typename T> Sk4x<T> Sk4x<T>::bitNot() const { return ~fVec; }
68
69 template <typename T> Sk4x<T> Sk4x<T>::bitAnd(const Sk4x& other) const { return fVec & other.fVec; }
70 template <typename T> Sk4x<T> Sk4x<T>::bitOr (const Sk4x& other) const { return fVec | other.fVec; }
71
72 template <typename T>
73 Sk4i Sk4x<T>:: equal(const Sk4x<T>& other) const { return fVec == othe r.fVec; }
74 template <typename T>
75 Sk4i Sk4x<T>:: notEqual(const Sk4x<T>& other) const { return fVec != othe r.fVec; }
76 template <typename T>
77 Sk4i Sk4x<T>:: lessThan(const Sk4x<T>& other) const { return fVec < othe r.fVec; }
78 template <typename T>
79 Sk4i Sk4x<T>:: greaterThan(const Sk4x<T>& other) const { return fVec > othe r.fVec; }
80 template <typename T>
81 Sk4i Sk4x<T>:: lessThanEqual(const Sk4x<T>& other) const { return fVec <= othe r.fVec; }
82 template <typename T>
83 Sk4i Sk4x<T>::greaterThanEqual(const Sk4x<T>& other) const { return fVec >= othe r.fVec; }
84
85 template <typename T>
86 Sk4x<T> Sk4x<T>:: add(const Sk4x<T>& other) const { return fVec + other.fVec ; }
87 template <typename T>
88 Sk4x<T> Sk4x<T>::subtract(const Sk4x<T>& other) const { return fVec - other.fVec ; }
89 template <typename T>
90 Sk4x<T> Sk4x<T>::multiply(const Sk4x<T>& other) const { return fVec * other.fVec ; }
91 template <typename T>
92 Sk4x<T> Sk4x<T>:: divide(const Sk4x<T>& other) const { return fVec / other.fVec ; }
93
94 template <typename T>
95 Sk4x<T> Sk4x<T>::Min(const Sk4x<T>& a, const Sk4x<T>& b) {
96 Sk4i less(a.lessThan(b));
97 Sk4i val = a.reinterpret<Sk4i>().bitAnd(less).bitOr(
98 b.reinterpret<Sk4i>().bitAnd(less.bitNot()));
99 return val.reinterpret<Sk4x>();
100 }
101
102 template <typename T>
103 Sk4x<T> Sk4x<T>::Max(const Sk4x<T>& a, const Sk4x<T>& b) {
104 Sk4i less(a.lessThan(b));
105 Sk4i val = b.reinterpret<Sk4i>().bitAnd(less).bitOr(
106 a.reinterpret<Sk4i>().bitAnd(less.bitNot()));
107 return val.reinterpret<Sk4x>();
108 }
109
110 template <typename T>
111 template <int m, int a, int s, int k>
112 Sk4x<T> Sk4x<T>::Shuffle(const Sk4x<T>& x, const Sk4x<T>& y) {
113 return __builtin_shufflevector(x.fVec, y.fVec, m,a,s,k);
114 }
115
116 template <typename T>
117 Sk4x<T> Sk4x<T>::zwxy() const { return fVec.zwxy; }
118
119 template <typename T>
120 Sk4x<T> Sk4x<T>::XYAB(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<0,1,4 ,5>(xyzw, abcd); }
121
122 template <typename T>
123 Sk4x<T> Sk4x<T>::ZWCD(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<2,3,6 ,7>(xyzw, abcd); }
124
125 #endif // defined(SK4X_PRIVATE)
OLDNEW
« no previous file with comments | « src/core/Sk4x.h ('k') | src/core/Sk4x_portable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698