OLD | NEW |
1 // It is important _not_ to put header guards here. | 1 // It is important _not_ to put header guards here. |
2 // This file will be intentionally included three times. | 2 // This file will be intentionally included three times. |
3 | 3 |
4 #if defined(SK4X_PREAMBLE) | 4 #if defined(SK4X_PREAMBLE) |
| 5 #include "SkFloatingPoint.h" |
| 6 #include <math.h> |
5 | 7 |
6 #elif defined(SK4X_PRIVATE) | 8 #elif defined(SK4X_PRIVATE) |
7 typedef T Type; | 9 typedef T Type; |
8 typedef T Vector[4]; | 10 typedef T Vector[4]; |
9 | 11 |
10 Vector fVec; | 12 Vector fVec; |
11 | 13 |
12 template <int m, int a, int s, int k> | 14 template <int m, int a, int s, int k> |
13 static Sk4x Shuffle(const Sk4x&, const Sk4x&); | 15 static Sk4x Shuffle(const Sk4x&, const Sk4x&); |
14 | 16 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 fVec[2] op other.fVec[2], \ | 55 fVec[2] op other.fVec[2], \ |
54 fVec[3] op other.fVec[3] | 56 fVec[3] op other.fVec[3] |
55 M(Sk4x<T>) bitAnd(const Sk4x& other) const { return Sk4x(BINOP(&)); } | 57 M(Sk4x<T>) bitAnd(const Sk4x& other) const { return Sk4x(BINOP(&)); } |
56 M(Sk4x<T>) bitOr(const Sk4x& other) const { return Sk4x(BINOP(|)); } | 58 M(Sk4x<T>) bitOr(const Sk4x& other) const { return Sk4x(BINOP(|)); } |
57 M(Sk4x<T>) add(const Sk4x<T>& other) const { return Sk4x(BINOP(+)); } | 59 M(Sk4x<T>) add(const Sk4x<T>& other) const { return Sk4x(BINOP(+)); } |
58 M(Sk4x<T>) subtract(const Sk4x<T>& other) const { return Sk4x(BINOP(-)); } | 60 M(Sk4x<T>) subtract(const Sk4x<T>& other) const { return Sk4x(BINOP(-)); } |
59 M(Sk4x<T>) multiply(const Sk4x<T>& other) const { return Sk4x(BINOP(*)); } | 61 M(Sk4x<T>) multiply(const Sk4x<T>& other) const { return Sk4x(BINOP(*)); } |
60 M(Sk4x<T>) divide(const Sk4x<T>& other) const { return Sk4x(BINOP(/)); } | 62 M(Sk4x<T>) divide(const Sk4x<T>& other) const { return Sk4x(BINOP(/)); } |
61 #undef BINOP | 63 #undef BINOP |
62 | 64 |
| 65 template<> inline Sk4f Sk4f::rsqrt() const { |
| 66 return Sk4f(sk_float_rsqrt(fVec[0]), |
| 67 sk_float_rsqrt(fVec[1]), |
| 68 sk_float_rsqrt(fVec[2]), |
| 69 sk_float_rsqrt(fVec[3])); |
| 70 } |
| 71 |
| 72 template<> inline Sk4f Sk4f::sqrt() const { |
| 73 return Sk4f(sqrtf(fVec[0]), |
| 74 sqrtf(fVec[1]), |
| 75 sqrtf(fVec[2]), |
| 76 sqrtf(fVec[3])); |
| 77 } |
| 78 |
63 #define BOOL_BINOP(op) fVec[0] op other.fVec[0] ? -1 : 0, \ | 79 #define BOOL_BINOP(op) fVec[0] op other.fVec[0] ? -1 : 0, \ |
64 fVec[1] op other.fVec[1] ? -1 : 0, \ | 80 fVec[1] op other.fVec[1] ? -1 : 0, \ |
65 fVec[2] op other.fVec[2] ? -1 : 0, \ | 81 fVec[2] op other.fVec[2] ? -1 : 0, \ |
66 fVec[3] op other.fVec[3] ? -1 : 0 | 82 fVec[3] op other.fVec[3] ? -1 : 0 |
67 M(Sk4i) equal(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(==
)); } | 83 M(Sk4i) equal(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(==
)); } |
68 M(Sk4i) notEqual(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(!=
)); } | 84 M(Sk4i) notEqual(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(!=
)); } |
69 M(Sk4i) lessThan(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP( <
)); } | 85 M(Sk4i) lessThan(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP( <
)); } |
70 M(Sk4i) greaterThan(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP( >
)); } | 86 M(Sk4i) greaterThan(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP( >
)); } |
71 M(Sk4i) lessThanEqual(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(<=
)); } | 87 M(Sk4i) lessThanEqual(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(<=
)); } |
72 M(Sk4i) greaterThanEqual(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(>=
)); } | 88 M(Sk4i) greaterThanEqual(const Sk4x<T>& other) const { return Sk4i(BOOL_BINOP(>=
)); } |
(...skipping 20 matching lines...) Expand all Loading... |
93 k < 4 ? x.fVec[k] : y.fVec[k-4]); | 109 k < 4 ? x.fVec[k] : y.fVec[k-4]); |
94 } | 110 } |
95 | 111 |
96 M(Sk4x<T>) zwxy() const { return Shuffle<2,3,0,1>(*t
his, *this); } | 112 M(Sk4x<T>) zwxy() const { return Shuffle<2,3,0,1>(*t
his, *this); } |
97 M(Sk4x<T>) XYAB(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<0,1,4,5>( x
yzw, abcd); } | 113 M(Sk4x<T>) XYAB(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<0,1,4,5>( x
yzw, abcd); } |
98 M(Sk4x<T>) ZWCD(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<2,3,6,7>( x
yzw, abcd); } | 114 M(Sk4x<T>) ZWCD(const Sk4x& xyzw, const Sk4x& abcd) { return Shuffle<2,3,6,7>( x
yzw, abcd); } |
99 | 115 |
100 #undef M | 116 #undef M |
101 | 117 |
102 #endif | 118 #endif |
OLD | NEW |