From 7f87812c30ac5e4c3329911aec2ce52050a9abbb Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 24 Jun 2020 19:43:36 -0700 Subject: libpayload: cbgfx: Replace bilinear resampling with Lanczos This patch improves the image resampling (scaling) code in CBGFX to use the Lanczos algorithm that is widely considered the "best" resampling algorithm (e.g. also the first choice in Python's PIL library). It is of course much more elaborate and therefore slower than bilinear resampling, but a lot of the difference can be made up with optimizations, and the resulting code was found to still produce acceptable speeds for existing Chrome OS UI use cases (on an Arm Cortex-A55 device, time to scale an image to 1101x593 went from ~88ms to ~275ms, a little over 3x slowdown). Nevertheless, if this should be too slow for anyone there's also an option to tune it down a little, but still much better than bilinear (same operation was ~170ms with this). Example images (scaled up by a factor of 7): Old (bilinear): https://i.imgur.com/ytr2n4Z.png New (Lanczos a=3): https://i.imgur.com/f0vKluM.png Signed-off-by: Julius Werner Change-Id: Idde6f61865bfac2801ee4fff40ac64e4ebddff1a Reviewed-on: https://review.coreboot.org/c/coreboot/+/42792 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu Reviewed-by: Hung-Te Lin --- payloads/libpayload/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'payloads/libpayload/Kconfig') diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig index 7e506d9100..b5dc9a3c8b 100644 --- a/payloads/libpayload/Kconfig +++ b/payloads/libpayload/Kconfig @@ -334,6 +334,19 @@ config FONT_SCALE_FACTOR By default (value of 0), the scale factor is automatically calculated to ensure at least 130 columns (when possible). +config CBGFX_FAST_RESAMPLE + bool "CBGFX: use faster (less pretty) image scaling" + default n + help + When payloads use the CBGFX library to draw .BMPs on the screen, + they will be resampled with an anti-aliasing filter to scale to the + requested output size. The default implementation should normally be + fast enough, but if desired this option can make it about 50-100% + faster at the cost of quality. (It changes the 'a' parameter in the + Lanczos resampling algorithm from 3 to 2.) + + Only affects .BMPs that aren't already provided at the right size. + config PC_I8042 bool "A common PC i8042 driver" default y if PC_KEYBOARD || PC_MOUSE -- cgit v1.2.3