Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: src/opts/SkColor_opts_SSE2.h

Issue 755573002: Cleanup with SkAlphaMulQ_SSE2() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 __m128i ag = _mm_srli_epi16(c, 8); 56 __m128i ag = _mm_srli_epi16(c, 8);
57 ASSERT_EQ(ag, _mm_and_si128(mask, ag)); // ag = _mm_srli_epi16(c, 8) did th is for us. 57 ASSERT_EQ(ag, _mm_and_si128(mask, ag)); // ag = _mm_srli_epi16(c, 8) did th is for us.
58 ag = _mm_mullo_epi16(ag, s); 58 ag = _mm_mullo_epi16(ag, s);
59 59
60 // (rb & mask) | (ag & ~mask) 60 // (rb & mask) | (ag & ~mask)
61 ASSERT_EQ(rb, _mm_and_si128(mask, rb)); // rb = _mm_srli_epi16(rb, 8) did t his for us. 61 ASSERT_EQ(rb, _mm_and_si128(mask, rb)); // rb = _mm_srli_epi16(rb, 8) did t his for us.
62 ag = _mm_andnot_si128(mask, ag); 62 ag = _mm_andnot_si128(mask, ag);
63 return _mm_or_si128(rb, ag); 63 return _mm_or_si128(rb, ag);
64 } 64 }
65 65
66 // Fast path for colors scale the same factor.
mtklein 2014/11/24 16:48:23 Maybe // Fast path for SkAlphaMulQ_SSE2 with a co
qiankun 2014/11/25 05:33:52 Done.
67 static inline __m128i SkAlphaMulQ_SSE2(const __m128i& c, const unsigned scale) {
68 __m128i mask = _mm_set1_epi32(0xFF00FF);
69 __m128i s = _mm_set1_epi16(scale << 8); // Move scale factor to upper byte o f word.
70
71 // With mulhi, red and blue values are already in the right place and
72 // don't need to be divided by 256.
73 __m128i rb = _mm_and_si128(mask, c);
74 rb = _mm_mulhi_epu16(rb, s);
75
76 __m128i ag = _mm_srli_epi16(c, 8);
77 ag = _mm_mulhi_epu16(ag, s); // Alpha and green values are in the lower byte of each word.
78 ag = _mm_slli_epi16(ag, 8); // Shift alpha and green to higher byte of each word.
79
80 return _mm_or_si128(rb, ag);
81 }
82
66 static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) { 83 static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) {
67 __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT)); 84 __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT));
68 return _mm_srli_epi32(a, 24); 85 return _mm_srli_epi32(a, 24);
69 } 86 }
70 87
71 static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) { 88 static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) {
72 __m128i r = _mm_slli_epi32(src, (24 - SK_R32_SHIFT)); 89 __m128i r = _mm_slli_epi32(src, (24 - SK_R32_SHIFT));
73 return _mm_srli_epi32(r, 24); 90 return _mm_srli_epi32(r, 24);
74 } 91 }
75 92
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 __m128i b = _mm_packs_epi32(b1, b2); 197 __m128i b = _mm_packs_epi32(b1, b2);
181 198
182 // Store 8 16-bit colors in dst. 199 // Store 8 16-bit colors in dst.
183 __m128i d_pixel = SkPackRGB16_SSE2(r, g, b); 200 __m128i d_pixel = SkPackRGB16_SSE2(r, g, b);
184 201
185 return d_pixel; 202 return d_pixel;
186 } 203 }
187 204
188 #undef ASSERT_EQ 205 #undef ASSERT_EQ
189 #endif // SkColor_opts_SSE2_DEFINED 206 #endif // SkColor_opts_SSE2_DEFINED
OLDNEW
« src/opts/SkBlitRow_opts_SSE2.cpp ('K') | « src/opts/SkBlitRow_opts_SSE2.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698