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

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

Issue 698873003: Sk4x_sse.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ~0 Created 6 years 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 | « no previous file | src/core/Sk4x_sse.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef Sk4x_DEFINED 1 #ifndef Sk4x_DEFINED
2 #define Sk4x_DEFINED 2 #define Sk4x_DEFINED
3 3
4 #include "SkTypes.h" 4 #include "SkTypes.h"
5 5
6 #define SK4X_PREAMBLE 1 6 #define SK4X_PREAMBLE 1
7 #include "Sk4x_portable.h" 7 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
8 #include "Sk4x_sse.h"
9 #else
10 #include "Sk4x_portable.h"
11 #endif
8 #undef SK4X_PREAMBLE 12 #undef SK4X_PREAMBLE
9 13
10 template <typename T> class Sk4x; 14 template <typename T> class Sk4x;
11 typedef Sk4x<float> Sk4f; 15 typedef Sk4x<float> Sk4f;
12 typedef Sk4x<int32_t> Sk4i; 16 typedef Sk4x<int32_t> Sk4i;
13 17
18 // Some Sk4x methods are implemented only for Sk4f or Sk4i.
19 // They might be unavailable, really slow, or just a bad idea.
20 // Talk to mtklein if you find yourself unable to link and
21 // really need one of those methods.
22
14 template <typename T> class Sk4x { 23 template <typename T> class Sk4x {
15 public: 24 public:
16 Sk4x(); // Uninitialized; use Sk4x(0,0,0,0) for zero. 25 Sk4x(); // Uninitialized; use Sk4x(0,0,0,0) for zero.
17 Sk4x(T, T, T, T); 26 Sk4x(T, T, T, T);
18 27
19 Sk4x(const Sk4x&); 28 Sk4x(const Sk4x&);
20 Sk4x& operator=(const Sk4x&); 29 Sk4x& operator=(const Sk4x&);
21 30
22 static Sk4x Load (const T[4]); 31 static Sk4x Load (const T[4]);
23 static Sk4x LoadAligned(const T[4]); 32 static Sk4x LoadAligned(const T[4]);
24 33
25 void store (T[4]) const; 34 void store (T[4]) const;
26 void storeAligned(T[4]) const; 35 void storeAligned(T[4]) const;
27 36
28 template <typename Dst> Dst reinterpret() const; 37 template <typename Dst> Dst reinterpret() const;
29 template <typename Dst> Dst cast() const; 38 template <typename Dst> Dst cast() const;
30 39
31 bool allTrue() const; 40 bool allTrue() const;
32 bool anyTrue() const; 41 bool anyTrue() const;
33 42
34 Sk4x bitNot() const; 43 Sk4x bitNot() const;
35 Sk4x bitAnd(const Sk4x&) const; 44 Sk4x bitAnd(const Sk4x&) const;
36 Sk4x bitOr(const Sk4x&) const; 45 Sk4x bitOr(const Sk4x&) const;
46 // TODO: Sk4x bitAndNot(const Sk4x&) const; is efficient in SSE.
37 Sk4x add(const Sk4x&) const; 47 Sk4x add(const Sk4x&) const;
38 Sk4x subtract(const Sk4x&) const; 48 Sk4x subtract(const Sk4x&) const;
39 Sk4x multiply(const Sk4x&) const; 49 Sk4x multiply(const Sk4x&) const;
40 Sk4x divide(const Sk4x&) const; 50 Sk4x divide(const Sk4x&) const;
41 51
42 Sk4i equal(const Sk4x&) const; 52 Sk4i equal(const Sk4x&) const;
43 Sk4i notEqual(const Sk4x&) const; 53 Sk4i notEqual(const Sk4x&) const;
44 Sk4i lessThan(const Sk4x&) const; 54 Sk4i lessThan(const Sk4x&) const;
45 Sk4i greaterThan(const Sk4x&) const; 55 Sk4i greaterThan(const Sk4x&) const;
46 Sk4i lessThanEqual(const Sk4x&) const; 56 Sk4i lessThanEqual(const Sk4x&) const;
47 Sk4i greaterThanEqual(const Sk4x&) const; 57 Sk4i greaterThanEqual(const Sk4x&) const;
48 58
49 static Sk4x Min(const Sk4x& a, const Sk4x& b); 59 static Sk4x Min(const Sk4x& a, const Sk4x& b);
50 static Sk4x Max(const Sk4x& a, const Sk4x& b); 60 static Sk4x Max(const Sk4x& a, const Sk4x& b);
51 61
52 // Swizzles follow OpenCL xyzw convention. 62 // Swizzles follow OpenCL xyzw convention.
53 Sk4x zwxy() const; 63 Sk4x zwxy() const;
54 64
55 // When there's a second argument, it's abcd. 65 // When there's a second argument, it's abcd.
56 static Sk4x XYAB(const Sk4x& xyzw, const Sk4x& abcd); 66 static Sk4x XYAB(const Sk4x& xyzw, const Sk4x& abcd);
57 static Sk4x ZWCD(const Sk4x& xyzw, const Sk4x& abcd); 67 static Sk4x ZWCD(const Sk4x& xyzw, const Sk4x& abcd);
58 68
69 // TODO: these are particularly efficient in SSE. Useful? Also efficient i n NEON?
70 // static Sk4x XAYB(const Sk4x& xyzw, const Sk4x& abcd);
71 // static Sk4x ZCWD(const Sk4x& xyzw, const Sk4x& abcd);
72
59 private: 73 private:
60 // It's handy to have Sk4f and Sk4i be mutual friends. 74 // It's handy to have Sk4f and Sk4i be mutual friends.
61 template <typename S> friend class Sk4x; 75 template <typename S> friend class Sk4x;
62 76
63 #define SK4X_PRIVATE 1 77 #define SK4X_PRIVATE 1
64 #include "Sk4x_portable.h" 78 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
79 #include "Sk4x_sse.h"
80 #else
81 #include "Sk4x_portable.h"
82 #endif
65 #undef SK4X_PRIVATE 83 #undef SK4X_PRIVATE
66 }; 84 };
67 85
68 #include "Sk4x_portable.h" 86 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
87 #include "Sk4x_sse.h"
88 #else
89 #include "Sk4x_portable.h"
90 #endif
69 91
70 #endif//Sk4x_DEFINED 92 #endif//Sk4x_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/Sk4x_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698