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

Unified Diff: src/opts/Sk4px_SSE2.h

Issue 1447273004: trim some fat from SSE2 fixed point alpha code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/opts/SkPx_sse.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/Sk4px_SSE2.h
diff --git a/src/opts/Sk4px_SSE2.h b/src/opts/Sk4px_SSE2.h
index 5e97abf308b3af30c3d6f3301c7101f0030a72c5..9c3eb1210c105f9a9f6ccbf808c4818f59c5e7fa 100644
--- a/src/opts/Sk4px_SSE2.h
+++ b/src/opts/Sk4px_SSE2.h
@@ -63,18 +63,17 @@ inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const {
#else
inline Sk4px Sk4px::alphas() const {
static_assert(SK_A32_SHIFT == 24, "Intel's always little-endian.");
- __m128i as = _mm_srli_epi32(this->fVec, 24); // ___3 ___2 ___1 ___0
- as = _mm_or_si128(as, _mm_slli_si128(as, 1)); // __33 __22 __11 __00
- as = _mm_or_si128(as, _mm_slli_si128(as, 2)); // 3333 2222 1111 0000
+ // We exploit that A >= rgb for any premul pixel.
msarett 2015/11/17 19:59:57 Clever :)
+ __m128i as = fVec; // 3xxx 2xxx 1xxx 0xxx
+ as = _mm_max_epu8(as, _mm_srli_epi32(as, 8)); // 33xx 22xx 11xx 00xx
+ as = _mm_max_epu8(as, _mm_srli_epi32(as, 16)); // 3333 2222 1111 0000
return Sk16b(as);
}
inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) {
__m128i as = _mm_cvtsi32_si128(*(const uint32_t*)a); // ____ ____ ____ 3210
- as = _mm_unpacklo_epi8 (as, _mm_setzero_si128()); // ____ ____ _3_2 _1_0
- as = _mm_unpacklo_epi16(as, _mm_setzero_si128()); // ___3 ___2 ___1 ___0
- as = _mm_or_si128(as, _mm_slli_si128(as, 1)); // __33 __22 __11 __00
- as = _mm_or_si128(as, _mm_slli_si128(as, 2)); // 3333 2222 1111 0000
+ as = _mm_unpacklo_epi8 (as, as); // ____ ____ 3322 1100
+ as = _mm_unpacklo_epi16(as, as); // 3333 2222 1111 0000
return Sk16b(as);
}
#endif
« no previous file with comments | « no previous file | src/opts/SkPx_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698