diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2016-03-25 13:55:11 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-03-25 14:28:45 +0000 |
commit | 9a8263baae8edf9114a7c3bbddbc5f920326a057 (patch) | |
tree | 0d1f96c4b0bb29add20afdf2bf6a30e084af9d2e | |
parent | 0480f13c021148cde25d2152b503d696130f7163 (diff) | |
download | mupdf-9a8263baae8edf9114a7c3bbddbc5f920326a057.tar.xz |
Optimise fz_paint_solid_color_5
-rw-r--r-- | source/fitz/draw-paint.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c index 9c3b952d..b3e4ef32 100644 --- a/source/fitz/draw-paint.c +++ b/source/fitz/draw-paint.c @@ -165,6 +165,52 @@ fz_paint_solid_color_5(byte * restrict dp, int w, byte *color) return; if (sa == 256) { +#ifdef ARCH_UNALIGNED_OK + if (w > 4) + { + if (isbigendian()) + { + const uint32_t a = *(uint32_t*)color; + const uint32_t b = 0xFF000000|(a>>8); + const uint32_t c = 0x00FF0000|(a>>16)|(a<<24); + const uint32_t d = 0x0000FF00|(a>>24)|(a<<16); + const uint32_t e = 0x000000FF|(a<<8); + w -= 3; + do + { + ((uint32_t *)(void *)dp)[0] = a; + ((uint32_t *)(void *)dp)[1] = b; + ((uint32_t *)(void *)dp)[2] = c; + ((uint32_t *)(void *)dp)[3] = d; + ((uint32_t *)(void *)dp)[4] = e; + dp += 20; + w -= 4; + } + while (w > 0); + } + else + { + const uint32_t a = *(uint32_t*)color; + const uint32_t b = 0x000000FF|(a<<8); + const uint32_t c = 0x0000FF00|(a<<16)|(a>>24); + const uint32_t d = 0x00FF0000|(a<<24)|(a>>16); + const uint32_t e = 0xFF000000|(a>>8); + w -= 3; + do + { + ((uint32_t *)(void *)dp)[0] = a; + ((uint32_t *)(void *)dp)[1] = b; + ((uint32_t *)(void *)dp)[2] = c; + ((uint32_t *)(void *)dp)[3] = d; + ((uint32_t *)(void *)dp)[4] = e; + dp += 20; + w -= 4; + } + while (w > 0); + } + w += 3; + } +#endif while (w--) { dp[0] = color[0]; |