Index: src/opts/SkColor_opts_SSE2.h |
diff --git a/src/opts/SkColor_opts_SSE2.h b/src/opts/SkColor_opts_SSE2.h |
index 95fb69cceb7355f0c4405fd55087239264e5b7ea..970abb859b980dff84dd4f1085ddd967ac2b7d3e 100644 |
--- a/src/opts/SkColor_opts_SSE2.h |
+++ b/src/opts/SkColor_opts_SSE2.h |
@@ -81,8 +81,12 @@ static inline __m128i SkAlphaMulQ_SSE2(const __m128i& c, const unsigned scale) { |
} |
static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) { |
+#if SK_A32_SHIFT == 24 // It's very common (universal?) that alpha is the top byte. |
+ return _mm_srli_epi32(src, 24); // You'd hope the compiler would remove the left shift then, |
+#else // but I've seen Clang just do a dumb left shift of zero. :( |
__m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT)); |
return _mm_srli_epi32(a, 24); |
+#endif |
} |
static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) { |