From a7454fbb46a5fb829a785a3d27c3877179e67b87 Mon Sep 17 00:00:00 2001 From: schlenkibus Date: Tue, 7 Apr 2026 11:50:56 +0200 Subject: [PATCH] fix: replace imprecise bit-shifts in OPA_MIX with accurate rounding Replaces bit-shift division in LV_OPA_MIX2 and LV_OPA_MIX3 with accurate math. This prevents "fully opaque" vector elements from rendering with an alpha of 254/252, fixing color bleed against backgrounds. --- src/misc/lv_color.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/misc/lv_color.h b/src/misc/lv_color.h index 0116de1e1922..c339080c92e2 100644 --- a/src/misc/lv_color.h +++ b/src/misc/lv_color.h @@ -234,8 +234,8 @@ typedef enum { #define LV_COLOR_MAKE(r8, g8, b8) {b8, g8, r8} -#define LV_OPA_MIX2(a1, a2) ((lv_opa_t)(((int32_t)(a1) * (a2)) >> 8)) -#define LV_OPA_MIX3(a1, a2, a3) ((lv_opa_t)(((int32_t)(a1) * (a2) * (a3)) >> 16)) +#define LV_OPA_MIX2(a1, a2) ((lv_opa_t)((((uint32_t)(a1) * (a2)) + 128) / 255)) +#define LV_OPA_MIX3(a1, a2, a3) ((lv_opa_t)((uint32_t)(a1) * (a2) * (a3) / 65025)) /********************** * GLOBAL PROTOTYPES