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_sse_DEFINED | 8 #ifndef SkNx_sse_DEFINED |
9 #define SkNx_sse_DEFINED | 9 #define SkNx_sse_DEFINED |
10 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 static SkNi Min(const SkNi& a, const SkNi& b) { | 251 static SkNi Min(const SkNi& a, const SkNi& b) { |
252 // No unsigned _mm_min_epu16, so we'll shift into a space where we can u
se the | 252 // No unsigned _mm_min_epu16, so we'll shift into a space where we can u
se the |
253 // signed version, _mm_min_epi16, then shift back. | 253 // signed version, _mm_min_epi16, then shift back. |
254 const uint16_t top = 0x8000; // Keep this separate from _mm_set1_epi16 o
r MSVC will whine. | 254 const uint16_t top = 0x8000; // Keep this separate from _mm_set1_epi16 o
r MSVC will whine. |
255 const __m128i top_8x = _mm_set1_epi16(top); | 255 const __m128i top_8x = _mm_set1_epi16(top); |
256 return _mm_add_epi8(top_8x, _mm_min_epi16(_mm_sub_epi8(a.fVec, top_8x), | 256 return _mm_add_epi8(top_8x, _mm_min_epi16(_mm_sub_epi8(a.fVec, top_8x), |
257 _mm_sub_epi8(b.fVec, top_8x)))
; | 257 _mm_sub_epi8(b.fVec, top_8x)))
; |
258 } | 258 } |
259 | 259 |
| 260 SkNi thenElse(const SkNi& t, const SkNi& e) const { |
| 261 return _mm_or_si128(_mm_and_si128 (fVec, t.fVec), |
| 262 _mm_andnot_si128(fVec, e.fVec)); |
| 263 } |
| 264 |
260 template <int k> uint16_t kth() const { | 265 template <int k> uint16_t kth() const { |
261 SkASSERT(0 <= k && k < 8); | 266 SkASSERT(0 <= k && k < 8); |
262 return _mm_extract_epi16(fVec, k); | 267 return _mm_extract_epi16(fVec, k); |
263 } | 268 } |
264 | 269 |
265 __m128i fVec; | 270 __m128i fVec; |
266 }; | 271 }; |
267 | 272 |
268 template <> | 273 template <> |
269 class SkNi<16, uint8_t> { | 274 class SkNi<16, uint8_t> { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return _mm_or_si128(_mm_and_si128 (fVec, t.fVec), | 309 return _mm_or_si128(_mm_and_si128 (fVec, t.fVec), |
305 _mm_andnot_si128(fVec, e.fVec)); | 310 _mm_andnot_si128(fVec, e.fVec)); |
306 } | 311 } |
307 | 312 |
308 __m128i fVec; | 313 __m128i fVec; |
309 }; | 314 }; |
310 | 315 |
311 } // namespace | 316 } // namespace |
312 | 317 |
313 #endif//SkNx_sse_DEFINED | 318 #endif//SkNx_sse_DEFINED |
OLD | NEW |