OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Android Open Source Project | 2 * Copyright 2014 The Android Open Source Project |
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 SkColor_opts_SSE2_DEFINED | 8 #ifndef SkColor_opts_SSE2_DEFINED |
9 #define SkColor_opts_SSE2_DEFINED | 9 #define SkColor_opts_SSE2_DEFINED |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 rb = _mm_mulhi_epu16(rb, s); | 74 rb = _mm_mulhi_epu16(rb, s); |
75 | 75 |
76 __m128i ag = _mm_andnot_si128(mask, c); | 76 __m128i ag = _mm_andnot_si128(mask, c); |
77 ag = _mm_mulhi_epu16(ag, s); // Alpha and green values are in the higher
byte of each word. | 77 ag = _mm_mulhi_epu16(ag, s); // Alpha and green values are in the higher
byte of each word. |
78 ag = _mm_andnot_si128(mask, ag); | 78 ag = _mm_andnot_si128(mask, ag); |
79 | 79 |
80 return _mm_or_si128(rb, ag); | 80 return _mm_or_si128(rb, ag); |
81 } | 81 } |
82 | 82 |
83 static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) { | 83 static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) { |
| 84 #if SK_A32_SHIFT == 24 // It's very common (universal?) that alph
a is the top byte. |
| 85 return _mm_srli_epi32(src, 24); // You'd hope the compiler would remove th
e left shift then, |
| 86 #else // but I've seen Clang just do a dumb left
shift of zero. :( |
84 __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT)); | 87 __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT)); |
85 return _mm_srli_epi32(a, 24); | 88 return _mm_srli_epi32(a, 24); |
| 89 #endif |
86 } | 90 } |
87 | 91 |
88 static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) { | 92 static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) { |
89 __m128i r = _mm_slli_epi32(src, (24 - SK_R32_SHIFT)); | 93 __m128i r = _mm_slli_epi32(src, (24 - SK_R32_SHIFT)); |
90 return _mm_srli_epi32(r, 24); | 94 return _mm_srli_epi32(r, 24); |
91 } | 95 } |
92 | 96 |
93 static inline __m128i SkGetPackedG32_SSE2(const __m128i& src) { | 97 static inline __m128i SkGetPackedG32_SSE2(const __m128i& src) { |
94 __m128i g = _mm_slli_epi32(src, (24 - SK_G32_SHIFT)); | 98 __m128i g = _mm_slli_epi32(src, (24 - SK_G32_SHIFT)); |
95 return _mm_srli_epi32(g, 24); | 99 return _mm_srli_epi32(g, 24); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 dst_scale = _mm_mullo_epi16(dst_scale, src_scale); | 230 dst_scale = _mm_mullo_epi16(dst_scale, src_scale); |
227 dst_scale = _mm_srli_epi16(dst_scale, 8); | 231 dst_scale = _mm_srli_epi16(dst_scale, 8); |
228 dst_scale = _mm_sub_epi32(_mm_set1_epi32(256), dst_scale); | 232 dst_scale = _mm_sub_epi32(_mm_set1_epi32(256), dst_scale); |
229 | 233 |
230 __m128i result = SkAlphaMulQ_SSE2(src, alpha); | 234 __m128i result = SkAlphaMulQ_SSE2(src, alpha); |
231 return _mm_add_epi8(result, SkAlphaMulQ_SSE2(dst, dst_scale)); | 235 return _mm_add_epi8(result, SkAlphaMulQ_SSE2(dst, dst_scale)); |
232 } | 236 } |
233 | 237 |
234 #undef ASSERT_EQ | 238 #undef ASSERT_EQ |
235 #endif // SkColor_opts_SSE2_DEFINED | 239 #endif // SkColor_opts_SSE2_DEFINED |
OLD | NEW |