From f31fa24914c683abcc2c860093b142725c43fbe6 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Mon, 12 May 2014 15:38:00 +0000 Subject: Make gMask_00FF00FF a constant This is to optimize SkAlphaMulQ() in PIC mode. With the visibility=default symbol the constant is not known at compile time (and is not a constant), but instead is fetched through a double indirection through GOT. The function is quite hot on one of the chromium benchmarks: rasterize_and_record_micro.key_silk_cases. This change replaces the symbol with a compile-time constant. As a bonus the variable is not exported from the dynamic library, i. e. a cleaner library interface. See specific performance improvements on Android here: http://goo.gl/iMuTDt R=skyostil@chromium.org, tomhudson@chromium.org, mtklein@google.com, reed@google.com, tomhudson@google.com Author: pasko@chromium.org Review URL: https://codereview.chromium.org/270473003 git-svn-id: http://skia.googlecode.com/svn/trunk@14696 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkBitmapProcState_filter.h | 8 ++++---- src/core/SkBlitMask_D32.cpp | 3 --- src/core/SkBlitter.cpp | 5 ----- src/opts/SkColor_opts_SSE2.h | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/SkBitmapProcState_filter.h b/src/core/SkBitmapProcState_filter.h index 12606656dd..99f40eca56 100644 --- a/src/core/SkBitmapProcState_filter.h +++ b/src/core/SkBitmapProcState_filter.h @@ -26,7 +26,7 @@ static inline void Filter_32_opaque(unsigned x, unsigned y, SkASSERT((unsigned)y <= 0xF); int xy = x * y; - static const uint32_t mask = gMask_00FF00FF; //0xFF00FF; + const uint32_t mask = 0xFF00FF; int scale = 256 - 16*y - 16*x + xy; uint32_t lo = (a00 & mask) * scale; @@ -56,7 +56,7 @@ static inline void Filter_32_alpha(unsigned x, unsigned y, SkASSERT(alphaScale <= 256); int xy = x * y; - static const uint32_t mask = gMask_00FF00FF; //0xFF00FF; + const uint32_t mask = 0xFF00FF; int scale = 256 - 16*y - 16*x + xy; uint32_t lo = (a00 & mask) * scale; @@ -86,7 +86,7 @@ static inline void Filter_32_opaque(unsigned t, SkPMColor* dstColor) { SkASSERT((unsigned)t <= 0xF); - static const uint32_t mask = gMask_00FF00FF; //0x00FF00FF; + const uint32_t mask = 0xFF00FF; int scale = 256 - 16*t; uint32_t lo = (color0 & mask) * scale; @@ -108,7 +108,7 @@ static inline void Filter_32_alpha(unsigned t, SkASSERT((unsigned)t <= 0xF); SkASSERT(alphaScale <= 256); - static const uint32_t mask = gMask_00FF00FF; //0x00FF00FF; + const uint32_t mask = 0xFF00FF; int scale = 256 - 16*t; uint32_t lo = (color0 & mask) * scale; diff --git a/src/core/SkBlitMask_D32.cpp b/src/core/SkBlitMask_D32.cpp index 1f16d775b5..008386caa5 100644 --- a/src/core/SkBlitMask_D32.cpp +++ b/src/core/SkBlitMask_D32.cpp @@ -353,9 +353,6 @@ static void A8_RowProc_Blend(SkPMColor* SK_RESTRICT dst, static void A8_RowProc_Opaque(SkPMColor* SK_RESTRICT dst, const uint8_t* SK_RESTRICT mask, const SkPMColor* SK_RESTRICT src, int count) { -#if 0 // suppress warning - const uint32_t rbmask = gMask_00FF00FF; -#endif for (int i = 0; i < count; ++i) { int m = mask[i]; if (m) { diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index 81e46c5622..a86881ad37 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -993,11 +993,6 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device, /////////////////////////////////////////////////////////////////////////////// -const uint16_t gMask_0F0F = 0xF0F; -const uint32_t gMask_00FF00FF = 0xFF00FF; - -/////////////////////////////////////////////////////////////////////////////// - class SkTransparentShaderContext : public SkShader::Context { public: SkTransparentShaderContext(const SkShader& shader, const SkShader::ContextRec& rec) diff --git a/src/opts/SkColor_opts_SSE2.h b/src/opts/SkColor_opts_SSE2.h index b06fe1a76f..7e61d526b3 100644 --- a/src/opts/SkColor_opts_SSE2.h +++ b/src/opts/SkColor_opts_SSE2.h @@ -42,7 +42,7 @@ static inline __m128i SkAlphaMulAlpha_SSE2(const __m128i& a, // Portable version SkAlphaMulQ is in SkColorPriv.h. static inline __m128i SkAlphaMulQ_SSE2(const __m128i& c, const __m128i& scale) { - __m128i mask = _mm_set1_epi32(gMask_00FF00FF); + __m128i mask = _mm_set1_epi32(0xFF00FF); __m128i s = _mm_or_si128(_mm_slli_epi32(scale, 16), scale); // uint32_t rb = ((c & mask) * scale) >> 8 -- cgit v1.2.3