aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-08-23 11:11:55 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-23 17:25:26 +0000
commitcd71f115a846332d95b29fbeed3f315d8c01753d (patch)
treed8c1b2eec555fe1bd9204d7867ad7c5bf1d5cbc3 /src/opts
parent59a62ed9462efa58573594da0f0088bba37960af (diff)
make SkOpts functions inline, not static
When Skia's built with an interestingly advanced instruction set baseline like SSSE3 or SSE4.1, we end up with two distinct copies of some SkOpts functions, one default in SkOpts.o and one specialization from SkOpts_{ssse3,sse41}.o. These functions are static, and so are technically unrelated, even though they're the same code compiled with the same instructions available. They're going to be identical. What we want here is to remove static but mark them as inline instead. In this case inline means "if the linker sees multiple copies of this, that's cool, just pick any one arbitrarily". That's just what we want. Now, when I disassemble a binary before and after this change, I do see the redundant routines removed. However, the file size change is minimal... I suspect that this must mean the linker has noticed that we had identical code and physically folded the two logically independent routines. I don't know how prevalent this optimization is, though, so it doesn't hurt to give it more of a "one copy please" hint with inline. There may also be a difference here between the binary size (~unchanged) and the in-memory layout of that binary? Change-Id: Id9c8f0ffc84aa1c9a066c22b623d34adab281857 Reviewed-on: https://skia-review.googlesource.com/37501 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/opts')
-rw-r--r--src/opts/SkBlitMask_opts.h6
-rw-r--r--src/opts/SkBlitRow_opts.h2
-rw-r--r--src/opts/SkBlurImageFilter_opts.h5
-rw-r--r--src/opts/SkChecksum_opts.h8
-rw-r--r--src/opts/SkSwizzler_opts.h60
-rw-r--r--src/opts/SkUtils_opts.h6
-rw-r--r--src/opts/SkXfermode_opts.h2
7 files changed, 45 insertions, 44 deletions
diff --git a/src/opts/SkBlitMask_opts.h b/src/opts/SkBlitMask_opts.h
index 2f4fe6ffb8..644bae4677 100644
--- a/src/opts/SkBlitMask_opts.h
+++ b/src/opts/SkBlitMask_opts.h
@@ -189,9 +189,9 @@ namespace SK_OPTS_NS {
}
#endif
-static void blit_mask_d32_a8(SkPMColor* dst, size_t dstRB,
- const SkAlpha* mask, size_t maskRB,
- SkColor color, int w, int h) {
+/*not static*/ inline void blit_mask_d32_a8(SkPMColor* dst, size_t dstRB,
+ const SkAlpha* mask, size_t maskRB,
+ SkColor color, int w, int h) {
if (color == SK_ColorBLACK) {
blit_mask_d32_a8_black(dst, dstRB, mask, maskRB, w, h);
} else if (SkColorGetA(color) == 0xFF) {
diff --git a/src/opts/SkBlitRow_opts.h b/src/opts/SkBlitRow_opts.h
index 74dead5da0..3cf858527b 100644
--- a/src/opts/SkBlitRow_opts.h
+++ b/src/opts/SkBlitRow_opts.h
@@ -76,7 +76,7 @@ static inline uint8x8_t SkPMSrcOver_neon2(uint8x8_t dst, uint8x8_t src) {
#endif
-static inline
+/*not static*/ inline
void blit_row_s32a_opaque(SkPMColor* dst, const SkPMColor* src, int len, U8CPU alpha) {
SkASSERT(alpha == 0xFF);
sk_msan_assert_initialized(src, src+len);
diff --git a/src/opts/SkBlurImageFilter_opts.h b/src/opts/SkBlurImageFilter_opts.h
index 246aba5e12..b6b429816c 100644
--- a/src/opts/SkBlurImageFilter_opts.h
+++ b/src/opts/SkBlurImageFilter_opts.h
@@ -216,8 +216,9 @@ enum class BlurDirection { kX, kY };
#endif
template<BlurDirection srcDirection, BlurDirection dstDirection>
-static void box_blur(const SkPMColor* src, int srcStride, const SkIRect& srcBounds, SkPMColor* dst,
- int kernelSize, int leftOffset, int rightOffset, int width, int height) {
+/*not static*/ inline
+void box_blur(const SkPMColor* src, int srcStride, const SkIRect& srcBounds, SkPMColor* dst,
+ int kernelSize, int leftOffset, int rightOffset, int width, int height) {
int left = srcBounds.left();
int right = srcBounds.right();
int top = srcBounds.top();
diff --git a/src/opts/SkChecksum_opts.h b/src/opts/SkChecksum_opts.h
index 089e87c1a3..90e7af0d96 100644
--- a/src/opts/SkChecksum_opts.h
+++ b/src/opts/SkChecksum_opts.h
@@ -28,7 +28,7 @@ static inline T unaligned_load(const uint8_t* src) {
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE42 && (defined(__x86_64__) || defined(_M_X64))
// This is not a CRC32. It's Just A Hash that uses those instructions because they're fast.
- static uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t seed) {
+ /*not static*/ inline uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t seed) {
auto data = (const uint8_t*)vdata;
// _mm_crc32_u64() operates on 64-bit registers, so we use uint64_t for a while.
@@ -84,7 +84,7 @@ static inline T unaligned_load(const uint8_t* src) {
#elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE42
// 32-bit version of above, using _mm_crc32_u32() but not _mm_crc32_u64().
- static uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) {
+ /*not static*/ inline uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) {
auto data = (const uint8_t*)vdata;
if (bytes >= 12) {
@@ -128,7 +128,7 @@ static inline T unaligned_load(const uint8_t* src) {
}
#elif defined(SK_ARM_HAS_CRC32)
- static uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) {
+ /*not static*/ inline uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) {
auto data = (const uint8_t*)vdata;
if (bytes >= 24) {
uint32_t a = hash,
@@ -173,7 +173,7 @@ static inline T unaligned_load(const uint8_t* src) {
#else
// This is Murmur3.
- static uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) {
+ /*not static*/ inline uint32_t hash_fn(const void* vdata, size_t bytes, uint32_t hash) {
auto data = (const uint8_t*)vdata;
size_t original_bytes = bytes;
diff --git a/src/opts/SkSwizzler_opts.h b/src/opts/SkSwizzler_opts.h
index a22e145020..4d9da5cc8d 100644
--- a/src/opts/SkSwizzler_opts.h
+++ b/src/opts/SkSwizzler_opts.h
@@ -235,15 +235,15 @@ static void premul_should_swapRB(uint32_t* dst, const void* vsrc, int count) {
proc(dst, src, count);
}
-static void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) {
premul_should_swapRB<false>(dst, src, count);
}
-static void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) {
premul_should_swapRB<true>(dst, src, count);
}
-static void RGBA_to_BGRA(uint32_t* dst, const void* vsrc, int count) {
+/*not static*/ inline void RGBA_to_BGRA(uint32_t* dst, const void* vsrc, int count) {
auto src = (const uint32_t*)vsrc;
while (count >= 16) {
// Load 16 pixels.
@@ -330,15 +330,15 @@ static void insert_alpha_should_swaprb(uint32_t dst[], const void* vsrc, int cou
proc(dst, src, count);
}
-static void RGB_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void RGB_to_RGB1(uint32_t dst[], const void* src, int count) {
insert_alpha_should_swaprb<false>(dst, src, count);
}
-static void RGB_to_BGR1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void RGB_to_BGR1(uint32_t dst[], const void* src, int count) {
insert_alpha_should_swaprb<true>(dst, src, count);
}
-static void gray_to_RGB1(uint32_t dst[], const void* vsrc, int count) {
+/*not static*/ inline void gray_to_RGB1(uint32_t dst[], const void* vsrc, int count) {
const uint8_t* src = (const uint8_t*) vsrc;
while (count >= 16) {
// Load 16 pixels.
@@ -434,11 +434,11 @@ static void expand_grayA(uint32_t dst[], const void* vsrc, int count) {
proc(dst, src, count);
}
-static void grayA_to_RGBA(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void grayA_to_RGBA(uint32_t dst[], const void* src, int count) {
expand_grayA<false>(dst, src, count);
}
-static void grayA_to_rgbA(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void grayA_to_rgbA(uint32_t dst[], const void* src, int count) {
expand_grayA<true>(dst, src, count);
}
@@ -482,11 +482,11 @@ static void inverted_cmyk_to(uint32_t* dst, const void* vsrc, int count) {
proc(dst, src, count);
}
-static void inverted_CMYK_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void inverted_CMYK_to_RGB1(uint32_t dst[], const void* src, int count) {
inverted_cmyk_to<kRGB1>(dst, src, count);
}
-static void inverted_CMYK_to_BGR1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void inverted_CMYK_to_BGR1(uint32_t dst[], const void* src, int count) {
inverted_cmyk_to<kBGR1>(dst, src, count);
}
@@ -571,15 +571,15 @@ static void premul_should_swapRB(uint32_t* dst, const void* vsrc, int count) {
proc(dst, src, count);
}
-static void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) {
premul_should_swapRB<false>(dst, src, count);
}
-static void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) {
premul_should_swapRB<true>(dst, src, count);
}
-static void RGBA_to_BGRA(uint32_t* dst, const void* vsrc, int count) {
+/*not static*/ inline void RGBA_to_BGRA(uint32_t* dst, const void* vsrc, int count) {
auto src = (const uint32_t*)vsrc;
const __m128i swapRB = _mm_setr_epi8(2,1,0,3, 6,5,4,7, 10,9,8,11, 14,13,12,15);
@@ -631,15 +631,15 @@ static void insert_alpha_should_swaprb(uint32_t dst[], const void* vsrc, int cou
proc(dst, src, count);
}
-static void RGB_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void RGB_to_RGB1(uint32_t dst[], const void* src, int count) {
insert_alpha_should_swaprb<false>(dst, src, count);
}
-static void RGB_to_BGR1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void RGB_to_BGR1(uint32_t dst[], const void* src, int count) {
insert_alpha_should_swaprb<true>(dst, src, count);
}
-static void gray_to_RGB1(uint32_t dst[], const void* vsrc, int count) {
+/*not static*/ inline void gray_to_RGB1(uint32_t dst[], const void* vsrc, int count) {
const uint8_t* src = (const uint8_t*) vsrc;
const __m128i alphas = _mm_set1_epi8((uint8_t) 0xFF);
@@ -669,7 +669,7 @@ static void gray_to_RGB1(uint32_t dst[], const void* vsrc, int count) {
gray_to_RGB1_portable(dst, src, count);
}
-static void grayA_to_RGBA(uint32_t dst[], const void* vsrc, int count) {
+/*not static*/ inline void grayA_to_RGBA(uint32_t dst[], const void* vsrc, int count) {
const uint8_t* src = (const uint8_t*) vsrc;
while (count >= 8) {
__m128i ga = _mm_loadu_si128((const __m128i*) src);
@@ -691,7 +691,7 @@ static void grayA_to_RGBA(uint32_t dst[], const void* vsrc, int count) {
grayA_to_RGBA_portable(dst, src, count);
}
-static void grayA_to_rgbA(uint32_t dst[], const void* vsrc, int count) {
+/*not static*/ inline void grayA_to_rgbA(uint32_t dst[], const void* vsrc, int count) {
const uint8_t* src = (const uint8_t*) vsrc;
while (count >= 8) {
__m128i grayA = _mm_loadu_si128((const __m128i*) src);
@@ -789,53 +789,53 @@ static void inverted_cmyk_to(uint32_t* dst, const void* vsrc, int count) {
proc(dst, src, count);
}
-static void inverted_CMYK_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void inverted_CMYK_to_RGB1(uint32_t dst[], const void* src, int count) {
inverted_cmyk_to<kRGB1>(dst, src, count);
}
-static void inverted_CMYK_to_BGR1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void inverted_CMYK_to_BGR1(uint32_t dst[], const void* src, int count) {
inverted_cmyk_to<kBGR1>(dst, src, count);
}
#else
-static void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) {
RGBA_to_rgbA_portable(dst, src, count);
}
-static void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) {
RGBA_to_bgrA_portable(dst, src, count);
}
-static void RGBA_to_BGRA(uint32_t* dst, const void* src, int count) {
+/*not static*/ inline void RGBA_to_BGRA(uint32_t* dst, const void* src, int count) {
RGBA_to_BGRA_portable(dst, src, count);
}
-static void RGB_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void RGB_to_RGB1(uint32_t dst[], const void* src, int count) {
RGB_to_RGB1_portable(dst, src, count);
}
-static void RGB_to_BGR1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void RGB_to_BGR1(uint32_t dst[], const void* src, int count) {
RGB_to_BGR1_portable(dst, src, count);
}
-static void gray_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void gray_to_RGB1(uint32_t dst[], const void* src, int count) {
gray_to_RGB1_portable(dst, src, count);
}
-static void grayA_to_RGBA(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void grayA_to_RGBA(uint32_t dst[], const void* src, int count) {
grayA_to_RGBA_portable(dst, src, count);
}
-static void grayA_to_rgbA(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void grayA_to_rgbA(uint32_t dst[], const void* src, int count) {
grayA_to_rgbA_portable(dst, src, count);
}
-static void inverted_CMYK_to_RGB1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void inverted_CMYK_to_RGB1(uint32_t dst[], const void* src, int count) {
inverted_CMYK_to_RGB1_portable(dst, src, count);
}
-static void inverted_CMYK_to_BGR1(uint32_t dst[], const void* src, int count) {
+/*not static*/ inline void inverted_CMYK_to_BGR1(uint32_t dst[], const void* src, int count) {
inverted_CMYK_to_BGR1_portable(dst, src, count);
}
diff --git a/src/opts/SkUtils_opts.h b/src/opts/SkUtils_opts.h
index d67a777ca8..525623c81b 100644
--- a/src/opts/SkUtils_opts.h
+++ b/src/opts/SkUtils_opts.h
@@ -30,13 +30,13 @@ namespace SK_OPTS_NS {
}
}
- static void memset16(uint16_t buffer[], uint16_t value, int count) {
+ /*not static*/ inline void memset16(uint16_t buffer[], uint16_t value, int count) {
memsetT(buffer, value, count);
}
- static void memset32(uint32_t buffer[], uint32_t value, int count) {
+ /*not static*/ inline void memset32(uint32_t buffer[], uint32_t value, int count) {
memsetT(buffer, value, count);
}
- static void memset64(uint64_t buffer[], uint64_t value, int count) {
+ /*not static*/ inline void memset64(uint64_t buffer[], uint64_t value, int count) {
memsetT(buffer, value, count);
}
diff --git a/src/opts/SkXfermode_opts.h b/src/opts/SkXfermode_opts.h
index c8fe384f09..8f140739b2 100644
--- a/src/opts/SkXfermode_opts.h
+++ b/src/opts/SkXfermode_opts.h
@@ -267,7 +267,7 @@ private:
namespace SK_OPTS_NS {
-static SkXfermode* create_xfermode(SkBlendMode mode) {
+/*not static*/ inline SkXfermode* create_xfermode(SkBlendMode mode) {
switch (mode) {
#define CASE(Xfermode) \
case SkBlendMode::k##Xfermode: return new Sk4pxXfermode<Xfermode>()