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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 SkNx operator + (const SkNx& o) const { return _mm_add_epi32(fVec, o.fVec);
} | 146 SkNx operator + (const SkNx& o) const { return _mm_add_epi32(fVec, o.fVec);
} |
147 SkNx operator - (const SkNx& o) const { return _mm_sub_epi32(fVec, o.fVec);
} | 147 SkNx operator - (const SkNx& o) const { return _mm_sub_epi32(fVec, o.fVec);
} |
148 SkNx operator * (const SkNx& o) const { | 148 SkNx operator * (const SkNx& o) const { |
149 __m128i mul20 = _mm_mul_epu32(fVec, o.fVec), | 149 __m128i mul20 = _mm_mul_epu32(fVec, o.fVec), |
150 mul31 = _mm_mul_epu32(_mm_srli_si128(fVec, 4), _mm_srli_si128(o.
fVec, 4)); | 150 mul31 = _mm_mul_epu32(_mm_srli_si128(fVec, 4), _mm_srli_si128(o.
fVec, 4)); |
151 return _mm_unpacklo_epi32(_mm_shuffle_epi32(mul20, _MM_SHUFFLE(0,0,2,0))
, | 151 return _mm_unpacklo_epi32(_mm_shuffle_epi32(mul20, _MM_SHUFFLE(0,0,2,0))
, |
152 _mm_shuffle_epi32(mul31, _MM_SHUFFLE(0,0,2,0))
); | 152 _mm_shuffle_epi32(mul31, _MM_SHUFFLE(0,0,2,0))
); |
153 } | 153 } |
154 | 154 |
| 155 SkNx operator | (const SkNx& o) const { return _mm_or_si128(fVec, o.fVec); } |
| 156 |
155 SkNx operator << (int bits) const { return _mm_slli_epi32(fVec, bits); } | 157 SkNx operator << (int bits) const { return _mm_slli_epi32(fVec, bits); } |
156 SkNx operator >> (int bits) const { return _mm_srai_epi32(fVec, bits); } | 158 SkNx operator >> (int bits) const { return _mm_srai_epi32(fVec, bits); } |
157 | 159 |
158 int operator[](int k) const { | 160 int operator[](int k) const { |
159 SkASSERT(0 <= k && k < 4); | 161 SkASSERT(0 <= k && k < 4); |
160 union { __m128i v; int is[4]; } pun = {fVec}; | 162 union { __m128i v; int is[4]; } pun = {fVec}; |
161 return pun.is[k&3]; | 163 return pun.is[k&3]; |
162 } | 164 } |
163 | 165 |
164 __m128i fVec; | 166 __m128i fVec; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 367 |
366 template<> /*static*/ inline Sk4h SkNx_cast<uint16_t, uint8_t>(const Sk4b& src)
{ | 368 template<> /*static*/ inline Sk4h SkNx_cast<uint16_t, uint8_t>(const Sk4b& src)
{ |
367 return _mm_unpacklo_epi8(src.fVec, _mm_setzero_si128()); | 369 return _mm_unpacklo_epi8(src.fVec, _mm_setzero_si128()); |
368 } | 370 } |
369 | 371 |
370 template<> /*static*/ inline Sk4b SkNx_cast<uint8_t, uint16_t>(const Sk4h& src)
{ | 372 template<> /*static*/ inline Sk4b SkNx_cast<uint8_t, uint16_t>(const Sk4h& src)
{ |
371 return _mm_packus_epi16(src.fVec, src.fVec); | 373 return _mm_packus_epi16(src.fVec, src.fVec); |
372 } | 374 } |
373 | 375 |
374 #endif//SkNx_sse_DEFINED | 376 #endif//SkNx_sse_DEFINED |
OLD | NEW |