LVGL v9: Opaque mixing in color converter for ThorVG

Playing around with the new ThorVG adapter provided by v9, we came across a questionable implementation for mixing opaq values:

_lv_color_to_tvg calls the macro LV_OPA_MIX2(a1, a2):

#define LV_OPA_MIX2(a1, a2) (((int32_t)(a1) * (a2)) >> 8)

When both opaque values are at the maximum (255), this formula returns 254. This led to unexpected colour changes during our tests.
If an opaque value is to be applied to one of the colour components R,G,B, multiplication is the correct method. But shouldn’t two opaque values be calculated with their arithmetic mean, i.e. (a1 + a2) >> 1?


hello, please check this:

static inline uint8_t MULTIPLY(uint8_t c, uint8_t a)
return (((c) * (a) + 0xff) >> 8);