From cd35a9a25c877d6ab447cbb55fc98d1867305142 Mon Sep 17 00:00:00 2001 From: Erik Tagirov <162967732+etag4048@users.noreply.github.com> Date: Tue, 24 Jun 2025 11:52:47 +0200 Subject: [PATCH] fix(draw_sw): fix ARGB8888PM case where the color of dest and src is the same but opa is different. (#8454) --- demos/render/lv_demo_render.c | 1 - .../lv_draw_sw_blend_to_argb8888_premultiplied.c | 12 ++++++++---- .../draw/test_render_to_argb8888_premultiplied.c | 8 ++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/demos/render/lv_demo_render.c b/demos/render/lv_demo_render.c index 30c2ca72c8..2c22d5b1d1 100644 --- a/demos/render/lv_demo_render.c +++ b/demos/render/lv_demo_render.c @@ -327,7 +327,6 @@ static lv_obj_t * image_obj_create(lv_obj_t * parent, int32_t col, int32_t row, return obj; } -#include static void image_core_cb(lv_obj_t * parent, bool recolor, uint32_t startAt) { diff --git a/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888_premultiplied.c b/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888_premultiplied.c index c0b3031653..71aacc1fea 100644 --- a/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888_premultiplied.c +++ b/src/draw/sw/blend/lv_draw_sw_blend_to_argb8888_premultiplied.c @@ -302,7 +302,8 @@ static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_ds *darker color when blending the same color to the background.*/ if(dest_buf_c32[x].red != color_argb.red || dest_buf_c32[x].green != color_argb.green || - dest_buf_c32[x].blue != color_argb.blue) { + dest_buf_c32[x].blue != color_argb.blue || + dest_buf_c32[x].alpha != color_argb.alpha) { color_argb.red = (color_argb.red * color_argb.alpha) >> 8; color_argb.green = (color_argb.green * color_argb.alpha) >> 8; @@ -334,7 +335,8 @@ static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_ds *darker color when blending the same color to the background.*/ if(dest_buf_c32[x].red != color_argb.red || dest_buf_c32[x].green != color_argb.green || - dest_buf_c32[x].blue != color_argb.blue) { + dest_buf_c32[x].blue != color_argb.blue || + dest_buf_c32[x].alpha != color_argb.alpha) { color_argb.alpha = alpha; color_argb.red = (color_argb.red * color_argb.alpha) >> 8; color_argb.green = (color_argb.green * color_argb.alpha) >> 8; @@ -366,7 +368,8 @@ static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_ds *darker color when blending the same color to the background.*/ if(dest_buf_c32[x].red != color_argb.red || dest_buf_c32[x].green != color_argb.green || - dest_buf_c32[x].blue != color_argb.blue) { + dest_buf_c32[x].blue != color_argb.blue || + dest_buf_c32[x].alpha != color_argb.alpha) { color_argb.alpha = alpha; color_argb.red = (color_argb.red * color_argb.alpha) >> 8; color_argb.green = (color_argb.green * color_argb.alpha) >> 8; @@ -399,7 +402,8 @@ static void LV_ATTRIBUTE_FAST_MEM argb8888_image_blend(lv_draw_sw_blend_image_ds *darker color when blending the same color to the background.*/ if(dest_buf_c32[x].red != color_argb.red || dest_buf_c32[x].green != color_argb.green || - dest_buf_c32[x].blue != color_argb.blue) { + dest_buf_c32[x].blue != color_argb.blue || + dest_buf_c32[x].alpha != color_argb.alpha) { color_argb.alpha = alpha; color_argb.red = (color_argb.red * color_argb.alpha) >> 8; color_argb.green = (color_argb.green * color_argb.alpha) >> 8; diff --git a/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c b/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c index 93fdcf0ad0..188f361470 100644 --- a/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c +++ b/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c @@ -26,8 +26,12 @@ void test_render_to_argb8888_premultiplied(void) uint32_t i; for(i = 0; i < LV_DEMO_RENDER_SCENE_NUM; i++) { - /*Skip test with transformed indexed images if they are not loaded to RAM*/ - if(LV_BIN_DECODER_RAM_LOAD == 0 && + /* + * Skip test with transformed indexed images if they are not loaded to RAM + * also skip normal_3 and recolor_3 on VGLite + * because RGB565A8 and I8 are not supported + */ + if((LV_BIN_DECODER_RAM_LOAD == 0 || LV_USE_DRAW_VGLITE == 0) && (i == LV_DEMO_RENDER_SCENE_IMAGE_NORMAL_3 || i == LV_DEMO_RENDER_SCENE_IMAGE_RECOLOR_3)) continue;