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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 static SkNx Max(const SkNx& x, const SkNx& y) { return x.fVal > y.fVal ? x :
y; } | 159 static SkNx Max(const SkNx& x, const SkNx& y) { return x.fVal > y.fVal ? x :
y; } |
160 | 160 |
161 SkNx saturatedAdd(const SkNx& y) const { | 161 SkNx saturatedAdd(const SkNx& y) const { |
162 static_assert(std::is_unsigned<T>::value, ""); | 162 static_assert(std::is_unsigned<T>::value, ""); |
163 T sum = fVal + y.fVal; | 163 T sum = fVal + y.fVal; |
164 return sum < fVal ? std::numeric_limits<T>::max() : sum; | 164 return sum < fVal ? std::numeric_limits<T>::max() : sum; |
165 } | 165 } |
166 | 166 |
167 SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e
; } | 167 SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e
; } |
168 | 168 |
| 169 SkNx logicalShiftRight(int bits) const { return ((unsigned) fVal) >> bits; } |
| 170 |
169 private: | 171 private: |
170 // Helper functions to choose the right float/double methods. (In <cmath> m
adness lies...) | 172 // Helper functions to choose the right float/double methods. (In <cmath> m
adness lies...) |
171 static float Abs(float val) { return ::fabsf(val); } | 173 static float Abs(float val) { return ::fabsf(val); } |
172 static float Sqrt(float val) { return ::sqrtf(val); } | 174 static float Sqrt(float val) { return ::sqrtf(val); } |
173 static float Floor(float val) { return ::floorf(val); } | 175 static float Floor(float val) { return ::floorf(val); } |
174 | 176 |
175 static double Abs(double val) { return ::fabs(val); } | 177 static double Abs(double val) { return ::fabs(val); } |
176 static double Sqrt(double val) { return ::sqrt(val); } | 178 static double Sqrt(double val) { return ::sqrt(val); } |
177 static double Floor(double val) { return ::floor(val); } | 179 static double Floor(double val) { return ::floor(val); } |
178 | 180 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 322 |
321 #endif | 323 #endif |
322 | 324 |
323 SI void Sk4f_ToBytes(uint8_t p[16], const Sk4f& a, const Sk4f& b, const Sk4f& c,
const Sk4f& d) { | 325 SI void Sk4f_ToBytes(uint8_t p[16], const Sk4f& a, const Sk4f& b, const Sk4f& c,
const Sk4f& d) { |
324 SkNx_cast<uint8_t>(SkNx_join(SkNx_join(a,b), SkNx_join(c,d))).store(p); | 326 SkNx_cast<uint8_t>(SkNx_join(SkNx_join(a,b), SkNx_join(c,d))).store(p); |
325 } | 327 } |
326 | 328 |
327 #undef SI | 329 #undef SI |
328 | 330 |
329 #endif//SkNx_DEFINED | 331 #endif//SkNx_DEFINED |
OLD | NEW |