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

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

Issue 724333003: Optimize SkAlphaMulQ_SSE2 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 __m128i mask = _mm_set1_epi32(0xFF00FF); 45 __m128i mask = _mm_set1_epi32(0xFF00FF);
46 __m128i s = _mm_or_si128(_mm_slli_epi32(scale, 16), scale); 46 __m128i s = _mm_or_si128(_mm_slli_epi32(scale, 16), scale);
47 47
48 // uint32_t rb = ((c & mask) * scale) >> 8 48 // uint32_t rb = ((c & mask) * scale) >> 8
49 __m128i rb = _mm_and_si128(mask, c); 49 __m128i rb = _mm_and_si128(mask, c);
50 rb = _mm_mullo_epi16(rb, s); 50 rb = _mm_mullo_epi16(rb, s);
51 rb = _mm_srli_epi16(rb, 8); 51 rb = _mm_srli_epi16(rb, 8);
52 52
53 // uint32_t ag = ((c >> 8) & mask) * scale 53 // uint32_t ag = ((c >> 8) & mask) * scale
54 __m128i ag = _mm_srli_epi16(c, 8); 54 __m128i ag = _mm_srli_epi16(c, 8);
55 ag = _mm_and_si128(ag, mask);
56 ag = _mm_mullo_epi16(ag, s); 55 ag = _mm_mullo_epi16(ag, s);
57 56
58 // (rb & mask) | (ag & ~mask) 57 // (rb & mask) | (ag & ~mask)
59 rb = _mm_and_si128(mask, rb);
mtklein 2014/11/14 14:22:58 Hmm. It'd be nice to explain / assert this for re
qiankun 2014/11/14 15:35:21 Done.
60 ag = _mm_andnot_si128(mask, ag); 58 ag = _mm_andnot_si128(mask, ag);
61 return _mm_or_si128(rb, ag); 59 return _mm_or_si128(rb, ag);
62 } 60 }
63 61
64 static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) { 62 static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) {
65 __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT)); 63 __m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT));
66 return _mm_srli_epi32(a, 24); 64 return _mm_srli_epi32(a, 24);
67 } 65 }
68 66
69 static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) { 67 static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 b2 = _mm_and_si128(b2, _mm_set1_epi32(SK_B16_MASK)); 175 b2 = _mm_and_si128(b2, _mm_set1_epi32(SK_B16_MASK));
178 __m128i b = _mm_packs_epi32(b1, b2); 176 __m128i b = _mm_packs_epi32(b1, b2);
179 177
180 // Store 8 16-bit colors in dst. 178 // Store 8 16-bit colors in dst.
181 __m128i d_pixel = SkPackRGB16_SSE2(r, g, b); 179 __m128i d_pixel = SkPackRGB16_SSE2(r, g, b);
182 180
183 return d_pixel; 181 return d_pixel;
184 } 182 }
185 183
186 #endif // SkColor_opts_SSE2_DEFINED 184 #endif // SkColor_opts_SSE2_DEFINED
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698