aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts/SkColor_opts_SSE2.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-11-25 10:05:43 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-25 10:05:43 -0800
commit785982ed80ce43653f64640d04dae7eaf5e2f809 (patch)
treec4d23b7b9f92f4255ceb011067014c41e559f339 /src/opts/SkColor_opts_SSE2.h
parent6f78a6448b8532722eeb8ce1191caa1c3a999df8 (diff)
Eliminate static initializers in SkColor_SSE2.h.
Chrome hates static initializers. Two global masks can become a single local mask instead. Perf looks like a no-op: $ c --match bitmaprect_80 bitmap_RGBA --config 8888 bitmap_RGBA_8888_scale 13.7us -> 14.1us 1.03x bitmap_RGBA_8888_update_volatile 4.53us -> 4.6us 1.02x bitmap_RGBA_8888 4.55us -> 4.61us 1.01x bitmap_RGBA_8888_update 4.64us -> 4.67us 1.01x bitmap_RGBA_8888_A_source_stripes_three 9.66us -> 9.71us 1.01x bitmaprect_80_filter_identity 10.6us -> 10.5us 0.99x bitmaprect_80_nofilter_identity 10.5us -> 10.4us 0.99x TBR=reed@google.com BUG=skia: Review URL: https://codereview.chromium.org/762453002
Diffstat (limited to 'src/opts/SkColor_opts_SSE2.h')
-rw-r--r--src/opts/SkColor_opts_SSE2.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/opts/SkColor_opts_SSE2.h b/src/opts/SkColor_opts_SSE2.h
index c52fc1e876..95fb69cceb 100644
--- a/src/opts/SkColor_opts_SSE2.h
+++ b/src/opts/SkColor_opts_SSE2.h
@@ -42,41 +42,40 @@ static inline __m128i SkAlphaMulAlpha_SSE2(const __m128i& a,
return prod;
}
-static const __m128i rb_mask = _mm_set1_epi32(0x00FF00FF);
-static const __m128i ag_mask = _mm_set1_epi32(0xFF00FF00);
-
// Portable version SkAlphaMulQ is in SkColorPriv.h.
static inline __m128i SkAlphaMulQ_SSE2(const __m128i& c, const __m128i& scale) {
+ const __m128i mask = _mm_set1_epi32(0xFF00FF);
__m128i s = _mm_or_si128(_mm_slli_epi32(scale, 16), scale);
// uint32_t rb = ((c & mask) * scale) >> 8
- __m128i rb = _mm_and_si128(rb_mask, c);
+ __m128i rb = _mm_and_si128(mask, c);
rb = _mm_mullo_epi16(rb, s);
rb = _mm_srli_epi16(rb, 8);
// uint32_t ag = ((c >> 8) & mask) * scale
__m128i ag = _mm_srli_epi16(c, 8);
- ASSERT_EQ(ag, _mm_and_si128(rb_mask, ag)); // ag = _mm_srli_epi16(c, 8) did this for us.
+ ASSERT_EQ(ag, _mm_and_si128(mask, ag)); // ag = _mm_srli_epi16(c, 8) did this for us.
ag = _mm_mullo_epi16(ag, s);
// (rb & mask) | (ag & ~mask)
- ASSERT_EQ(rb, _mm_and_si128(rb_mask, rb)); // rb = _mm_srli_epi16(rb, 8) did this for us.
- ag = _mm_and_si128(ag_mask, ag);
+ ASSERT_EQ(rb, _mm_and_si128(mask, rb)); // rb = _mm_srli_epi16(rb, 8) did this for us.
+ ag = _mm_andnot_si128(mask, ag);
return _mm_or_si128(rb, ag);
}
// Fast path for SkAlphaMulQ_SSE2 with a constant scale factor.
static inline __m128i SkAlphaMulQ_SSE2(const __m128i& c, const unsigned scale) {
+ const __m128i mask = _mm_set1_epi32(0xFF00FF);
__m128i s = _mm_set1_epi16(scale << 8); // Move scale factor to upper byte of word.
// With mulhi, red and blue values are already in the right place and
// don't need to be divided by 256.
- __m128i rb = _mm_and_si128(rb_mask, c);
+ __m128i rb = _mm_and_si128(mask, c);
rb = _mm_mulhi_epu16(rb, s);
- __m128i ag = _mm_and_si128(ag_mask, c);
+ __m128i ag = _mm_andnot_si128(mask, c);
ag = _mm_mulhi_epu16(ag, s); // Alpha and green values are in the higher byte of each word.
- ag = _mm_and_si128(ag_mask, ag);
+ ag = _mm_andnot_si128(mask, ag);
return _mm_or_si128(rb, ag);
}