OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkNx_DEFINED | 8 #ifndef SkNx_DEFINED |
9 #define SkNx_DEFINED | 9 #define SkNx_DEFINED |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 static SkNx Max(const SkNx& a, const SkNx& b) { | 68 static SkNx Max(const SkNx& a, const SkNx& b) { |
69 return {Half::Max(a.fLo, b.fLo), Half::Max(a.fHi, b.fHi)}; | 69 return {Half::Max(a.fLo, b.fLo), Half::Max(a.fHi, b.fHi)}; |
70 } | 70 } |
71 | 71 |
72 T operator[](int k) const { | 72 T operator[](int k) const { |
73 SkASSERT(0 <= k && k < N); | 73 SkASSERT(0 <= k && k < N); |
74 return k < N/2 ? fLo[k] : fHi[k-N/2]; | 74 return k < N/2 ? fLo[k] : fHi[k-N/2]; |
75 } | 75 } |
76 | 76 |
77 template <int k> T kth() const { return (*this)[k]; } | |
78 | |
79 bool allTrue() const { return fLo.allTrue() && fHi.allTrue(); } | 77 bool allTrue() const { return fLo.allTrue() && fHi.allTrue(); } |
80 bool anyTrue() const { return fLo.anyTrue() || fHi.anyTrue(); } | 78 bool anyTrue() const { return fLo.anyTrue() || fHi.anyTrue(); } |
81 SkNx thenElse(const SkNx& t, const SkNx& e) const { | 79 SkNx thenElse(const SkNx& t, const SkNx& e) const { |
82 return SkNx(fLo.thenElse(t.fLo, e.fLo), fHi.thenElse(t.fHi, e.fHi)); | 80 return SkNx(fLo.thenElse(t.fLo, e.fLo), fHi.thenElse(t.fHi, e.fHi)); |
83 } | 81 } |
84 | 82 |
85 protected: | 83 protected: |
86 static_assert(0 == (N & (N-1)), "N must be a power of 2."); | 84 static_assert(0 == (N & (N-1)), "N must be a power of 2."); |
87 | 85 |
88 Half fLo, fHi; | 86 Half fLo, fHi; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 SkNx rsqrt2() const { return this->rsqrt1(); } | 130 SkNx rsqrt2() const { return this->rsqrt1(); } |
133 | 131 |
134 SkNx invert() const { return 1 / fVal; } | 132 SkNx invert() const { return 1 / fVal; } |
135 SkNx approxInvert() const { return this->invert(); } | 133 SkNx approxInvert() const { return this->invert(); } |
136 | 134 |
137 T operator[](int k) const { | 135 T operator[](int k) const { |
138 SkASSERT(0 == k); | 136 SkASSERT(0 == k); |
139 return fVal; | 137 return fVal; |
140 } | 138 } |
141 | 139 |
142 template <int k> T kth() const { return (*this)[k]; } | |
143 | |
144 bool allTrue() const { return fVal != 0; } | 140 bool allTrue() const { return fVal != 0; } |
145 bool anyTrue() const { return fVal != 0; } | 141 bool anyTrue() const { return fVal != 0; } |
146 SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e
; } | 142 SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e
; } |
147 | 143 |
148 protected: | 144 protected: |
149 static double Floor(double val) { return ::floor (val); } | 145 static double Floor(double val) { return ::floor (val); } |
150 static float Floor(float val) { return ::floorf(val); } | 146 static float Floor(float val) { return ::floorf(val); } |
151 static double Sqrt(double val) { return ::sqrt (val); } | 147 static double Sqrt(double val) { return ::sqrt (val); } |
152 static float Sqrt(float val) { return ::sqrtf(val); } | 148 static float Sqrt(float val) { return ::sqrtf(val); } |
153 | 149 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 static inline | 207 static inline |
212 void Sk4f_ToBytes(uint8_t p[16], const Sk4f& a, const Sk4f& b, const Sk4f& c
, const Sk4f& d) { | 208 void Sk4f_ToBytes(uint8_t p[16], const Sk4f& a, const Sk4f& b, const Sk4f& c
, const Sk4f& d) { |
213 SkNx_cast<uint8_t>(a).store(p+ 0); | 209 SkNx_cast<uint8_t>(a).store(p+ 0); |
214 SkNx_cast<uint8_t>(b).store(p+ 4); | 210 SkNx_cast<uint8_t>(b).store(p+ 4); |
215 SkNx_cast<uint8_t>(c).store(p+ 8); | 211 SkNx_cast<uint8_t>(c).store(p+ 8); |
216 SkNx_cast<uint8_t>(d).store(p+12); | 212 SkNx_cast<uint8_t>(d).store(p+12); |
217 } | 213 } |
218 #endif | 214 #endif |
219 | 215 |
220 #endif//SkNx_DEFINED | 216 #endif//SkNx_DEFINED |
OLD | NEW |