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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkTypes.h ('k') | src/core/Sk4x_clang.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 #ifndef Sk4x_DEFINED
2 #define Sk4x_DEFINED
3
4 #include "SkTypes.h"
5
6 // First we'll let Clang try its best with whatever instructions are available.
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 #else
13 #include "Sk4x_portable.h"
14 #endif
15 #undef SK4X_PREAMBLE
16
17 template <typename T> class Sk4x;
18 typedef Sk4x<int> Sk4i;
19 typedef Sk4x<float> Sk4f;
20
21 template <typename T> class Sk4x {
22 public:
23 Sk4x(); // Uninitialized; use Sk4x(0,0,0,0) for zero.
24 Sk4x(T, T, T, T);
25 explicit Sk4x(const T[4]);
26
27 Sk4x(const Sk4x&);
28 Sk4x& operator=(const Sk4x&);
29
30 void set(T, T, T, T);
31
32 void store(T[4]) const;
33
34 template <typename Dst> Dst reinterpret() const;
35 template <typename Dst> Dst cast() const;
36
37 bool allTrue() const;
38 bool anyTrue() const;
39
40 Sk4x bitNot() const;
41 Sk4x bitAnd(const Sk4x&) const;
42 Sk4x bitOr (const Sk4x&) const;
43
44 Sk4i equal(const Sk4x&) const;
45 Sk4i notEqual(const Sk4x&) const;
46 Sk4i lessThan(const Sk4x&) const;
47 Sk4i greaterThan(const Sk4x&) const;
48 Sk4i lessThanEqual(const Sk4x&) const;
49 Sk4i greaterThanEqual(const Sk4x&) const;
50
51 Sk4x add(const Sk4x&) const;
52 Sk4x subtract(const Sk4x&) const;
53 Sk4x multiply(const Sk4x&) const;
54 Sk4x divide(const Sk4x&) const;
55
56 static Sk4x Min(const Sk4x& a, const Sk4x& b);
57 static Sk4x Max(const Sk4x& a, const Sk4x& b);
58
59 // Swizzles follow OpenCL xyzw convention.
60 Sk4x zwxy() const;
61
62 // When there's a second argument, it's abcd.
63 static Sk4x XYAB(const Sk4x& xyzw, const Sk4x& abcd);
64 static Sk4x ZWCD(const Sk4x& xyzw, const Sk4x& abcd);
65
66 private:
67 // It's handy to have Sk4f and Sk4i be mutual friends.
68 template <typename S> friend class Sk4x;
69
70 #define SK4X_PRIVATE 1
71 #if defined(__clang__)
72 #include "Sk4x_clang.h"
73 #else
74 #include "Sk4x_portable.h"
75 #endif
76 #undef SK4X_PRIVATE
77 };
78
79 #if defined(__clang__)
80 #include "Sk4x_clang.h"
81 #else
82 #include "Sk4x_portable.h"
83 #endif
84
85 // TODO ideas for enterprising coders:
86 // 1) Add Sk4x_gcc.h? __builtin_shuffle is fairly new, which is a pain.
87 // 2) Sk4x_sse.h would be good for Windows, and could possibly beat _clang / _ gcc
88 // (e.g. they can't generate _mm_movemask_ps for allTrue/anyTrue).
89 // 3) Sk4x_neon.h might be a good idea if _clang / _gcc aren't good enough on ARM.
90
91
92 #endif//Sk4x_DEFINED
OLDNEW
« 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