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

Side by Side Diff: src/core/Sk4x_portable.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_clang.h ('k') | src/core/SkTileGrid.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 #if defined(SK4X_PREAMBLE)
5
6 #elif defined(SK4X_PRIVATE)
7 typedef T Vector[4];
8
9 Vector fVec;
10
11 template <int m, int a, int s, int k>
12 static Sk4x Shuffle(const Sk4x&, const Sk4x&);
13
14 #else // defined(SK4X_PRIVATE)
15
16 template <typename T>
17 Sk4x<T>::Sk4x() { }
18
19 template <typename T>
20 Sk4x<T>::Sk4x(T a, T b, T c, T d) { this->set(a,b,c,d); }
21
22 template <typename T>
23 Sk4x<T>::Sk4x(const T vals[4]) { this->set(vals[0], vals[1], vals[2], vals[3]); }
24
25 template <typename T>
26 Sk4x<T>::Sk4x(const Sk4x<T>& other) { *this = other; }
27
28 template <typename T>
29 Sk4x<T>& Sk4x<T>::operator=(const Sk4x<T>& other) {
30 this->set(other.fVec[0], other.fVec[1], other.fVec[2], other.fVec[3]);
31 return *this;
32 }
33
34 template <typename T>
35 void Sk4x<T>::set(T a, T b, T c, T d) {
36 fVec[0] = a;
37 fVec[1] = b;
38 fVec[2] = c;
39 fVec[3] = d;
40 }
41
42 template <typename T>
43 void Sk4x<T>::store(T vals[4]) const {
44 vals[0] = fVec[0];
45 vals[1] = fVec[1];
46 vals[2] = fVec[2];
47 vals[3] = fVec[3];
48 }
49
50 template <typename T>
51 template <typename Dst> Dst Sk4x<T>::reinterpret() const {
52 return Dst(reinterpret_cast<const typename Dst::Vector*>(fVec));
53 }
54
55 template <typename T>
56 template <typename Dst> Dst Sk4x<T>::cast() const {
57 return Dst(fVec[0], fVec[1], fVec[2], fVec[3]);
58 }
59
60 template <typename T>
61 bool Sk4x<T>::allTrue() const { return fVec[0] & fVec[1] & fVec[2] & fVec[3]; }
62 template <typename T>
63 bool Sk4x<T>::anyTrue() const { return fVec[0] | fVec[1] | fVec[2] | fVec[3]; }
64
65 template <typename T>
66 Sk4x<T> Sk4x<T>::bitNot() const { return Sk4x(~fVec[0], ~fVec[1], ~fVec[2], ~fVe c[3]); }
67
68 #define BINOP(op) fVec[0] op other.fVec[0], \
69 fVec[1] op other.fVec[1], \
70 fVec[2] op other.fVec[2], \
71 fVec[3] op other.fVec[3]
72
73 template <typename T> Sk4x<T> Sk4x<T>::bitAnd(const Sk4x& other) const { return Sk4x(BINOP(&)); }
74 template <typename T> Sk4x<T> Sk4x<T>::bitOr (const Sk4x& other) const { return Sk4x(BINOP(|)); }
75
76 template <typename T>
77 Sk4i Sk4x<T>:: equal(const Sk4x<T>& other) const { return Sk4i(BINOP(= =)); }
78 template <typename T>
79 Sk4i Sk4x<T>:: notEqual(const Sk4x<T>& other) const { return Sk4i(BINOP(! =)); }
80 template <typename T>
81 Sk4i Sk4x<T>:: lessThan(const Sk4x<T>& other) const { return Sk4i(BINOP( <)); }
82 template <typename T>
83 Sk4i Sk4x<T>:: greaterThan(const Sk4x<T>& other) const { return Sk4i(BINOP( >)); }
84 template <typename T>
85 Sk4i Sk4x<T>:: lessThanEqual(const Sk4x<T>& other) const { return Sk4i(BINOP(< =)); }
86 template <typename T>
87 Sk4i Sk4x<T>::greaterThanEqual(const Sk4x<T>& other) const { return Sk4i(BINOP(> =)); }
88
89 template <typename T>
90 Sk4x<T> Sk4x<T>:: add(const Sk4x<T>& other) const { return Sk4x(BINOP(+)); }
91 template <typename T>
92 Sk4x<T> Sk4x<T>::subtract(const Sk4x<T>& other) const { return Sk4x(BINOP(-)); }
93 template <typename T>
94 Sk4x<T> Sk4x<T>::multiply(const Sk4x<T>& other) const { return Sk4x(BINOP(*)); }
95 template <typename T>
96 Sk4x<T> Sk4x<T>:: divide(const Sk4x<T>& other) const { return Sk4x(BINOP(/)); }
97
98 #undef BINOP
99
100 template <typename T>
101 Sk4x<T> Sk4x<T>::Min(const Sk4x<T>& a, const Sk4x<T>& b) {
102 return Sk4x(SkTMin(a.fVec[0], b.fVec[0]),
103 SkTMin(a.fVec[1], b.fVec[1]),
104 SkTMin(a.fVec[2], b.fVec[2]),
105 SkTMin(a.fVec[3], b.fVec[3]));
106 }
107
108 template <typename T>
109 Sk4x<T> Sk4x<T>::Max(const Sk4x<T>& a, const Sk4x<T>& b) {
110 return Sk4x(SkTMax(a.fVec[0], b.fVec[0]),
111 SkTMax(a.fVec[1], b.fVec[1]),
112 SkTMax(a.fVec[2], b.fVec[2]),
113 SkTMax(a.fVec[3], b.fVec[3]));
114 }
115
116 template <typename T>
117 template <int m, int a, int s, int k>
118 Sk4x<T> Sk4x<T>::Shuffle(const Sk4x<T>& x, const Sk4x<T>& y) {
119 return Sk4x(m < 4 ? x.fVec[m] : y.fVec[m-4],
120 a < 4 ? x.fVec[a] : y.fVec[a-4],
121 s < 4 ? x.fVec[s] : y.fVec[s-4],
122 k < 4 ? x.fVec[k] : y.fVec[k-4]);
123 }
124
125 template <typename T>
126 Sk4x<T> Sk4x<T>::zwxy() const { return Shuffle<2,3,0,1>(*this, *this); }
127
128 template <typename T>
129 Sk4x<T> Sk4x<T>::XYAB(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<0,1,4 ,5>(xyzw, abcd); }
130
131 template <typename T>
132 Sk4x<T> Sk4x<T>::ZWCD(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<2,3,6 ,7>(xyzw, abcd); }
133
134 #endif // defined(SK4X_PRIVATE)
OLDNEW
« no previous file with comments | « src/core/Sk4x_clang.h ('k') | src/core/SkTileGrid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698