aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts/SkSwizzler_opts.h
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/SkSwizzler_opts.h
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/SkSwizzler_opts.h')
-rw-r--r--src/opts/SkSwizzler_opts.h60
1 files changed, 30 insertions, 30 deletions
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);
}