Optimize CMYK->RGBA (BGRA) transform for jpeg decodes
Swizzle Bench Runtime
Nexus 6P 0.14x
Dell Venue 8 0.12x
CMYK Jpeg Decode Runtime
Nexus 6P 0.81x
Dell Venue 8 0.85x
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1676773003
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Review URL: https://codereview.chromium.org/1676773003
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index debcd45..f9f2120 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -592,6 +592,21 @@
}
}
+static void fast_swizzle_cmyk_to_n32(
+ void* dst, const uint8_t* src, int width, int bpp, int deltaSrc, int offset,
+ const SkPMColor ctable[]) {
+
+ // This function must not be called if we are sampling. If we are not
+ // sampling, deltaSrc should equal bpp.
+ SkASSERT(deltaSrc == bpp);
+
+#ifdef SK_PMCOLOR_IS_RGBA
+ SkOpts::inverted_CMYK_to_RGB1((uint32_t*) dst, src + offset, width);
+#else
+ SkOpts::inverted_CMYK_to_BGR1((uint32_t*) dst, src + offset, width);
+#endif
+}
+
static void swizzle_cmyk_to_565(
void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
@@ -811,6 +826,7 @@
break;
case kRGB_565_SkColorType:
proc = &swizzle_rgb_to_565;
+ break;
default:
break;
}
@@ -844,6 +860,7 @@
switch (dstInfo.colorType()) {
case kN32_SkColorType:
proc = &swizzle_cmyk_to_n32;
+ fastProc = &fast_swizzle_cmyk_to_n32;
break;
case kRGB_565_SkColorType:
proc = &swizzle_cmyk_to_565;