From e467088faa917a69b0a29e92b78dbc862768580d Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 3 Jan 2022 13:41:19 +0100 Subject: [PATCH] lvgl: take opacity into account The callback used for the 32-bit color depth has a slight problem, it doesn't take opacity into account. Correctly mix the colors by using lv_color_mix(). Suggested-by: Gabor Kiss-Vamosi Signed-off-by: Bartosz Golaszewski --- lib/gui/lvgl/lvgl_display_32bit.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/gui/lvgl/lvgl_display_32bit.c b/lib/gui/lvgl/lvgl_display_32bit.c index 293b3f3066b..43ec491d326 100644 --- a/lib/gui/lvgl/lvgl_display_32bit.c +++ b/lib/gui/lvgl/lvgl_display_32bit.c @@ -31,6 +31,13 @@ void lvgl_set_px_cb_32bit(struct _disp_drv_t *disp_drv, lv_color_t color, lv_opa_t opa) { uint32_t *buf_xy = (uint32_t *)(buf + x * 4U + y * 4U * buf_w); - *buf_xy = lv_color_to32(color); + + if (opa == LV_OPA_COVER) { + /* Do not mix if not required */ + *buf_xy = lv_color_to32(color); + } else { + lv_color_t bg_color = *((lv_color_t *)buf_xy); + *buf_xy = lv_color_to32(lv_color_mix(color, bg_color, opa)); + } } #endif