From cd7eccc25ee35fdfc737f20536966b9ae340f886 Mon Sep 17 00:00:00 2001 From: cristian-stoica Date: Thu, 4 Jul 2024 04:59:57 +0300 Subject: [PATCH] fix(nxp): fix rounded corner image in NXP vglite (#6436) Signed-off-by: Ana Grad Co-authored-by: Ana Grad --- src/draw/lv_draw_rect.c | 1 + src/draw/nxp/vglite/lv_draw_vglite_border.c | 20 ++++++++++++-------- src/draw/nxp/vglite/lv_draw_vglite_img.c | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/draw/lv_draw_rect.c b/src/draw/lv_draw_rect.c index 52b4fc2f75ae..1fe7f831362c 100644 --- a/src/draw/lv_draw_rect.c +++ b/src/draw/lv_draw_rect.c @@ -228,6 +228,7 @@ void lv_draw_rect(lv_layer_t * layer, const lv_draw_rect_dsc_t * dsc, const lv_a bg_image_dsc->recolor_opa = dsc->bg_image_recolor_opa; bg_image_dsc->tile = dsc->bg_image_tiled; bg_image_dsc->header = header; + bg_image_dsc->clip_radius = dsc->radius; t->type = LV_DRAW_TASK_TYPE_IMAGE; lv_draw_finalize_task_creation(layer, t); } diff --git a/src/draw/nxp/vglite/lv_draw_vglite_border.c b/src/draw/nxp/vglite/lv_draw_vglite_border.c index 43cc812be491..b156223df1d7 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite_border.c +++ b/src/draw/nxp/vglite/lv_draw_vglite_border.c @@ -142,36 +142,40 @@ static void _vglite_draw_border(const lv_area_t * coords, const lv_area_t * clip uint32_t num_rect = 0; vg_lite_rectangle_t rect[MAX_NUM_RECTANGLES]; + int32_t rect_width = coords->x2 - coords->x1; + int32_t rect_height = coords->y2 - coords->y1; + int32_t shortest_side = LV_MIN(rect_width, rect_height); + int32_t final_radius = LV_MIN(radius, shortest_side / 2); if(border_side & LV_BORDER_SIDE_TOP) { rect[num_rect].x = coords->x1 - ceil(line_width / 2.0f); rect[num_rect].y = coords->y1 - ceil(line_width / 2.0f); rect[num_rect].width = coords->x2 - coords->x1 + line_width; - rect[num_rect].height = line_width; + rect[num_rect].height = final_radius + ceil(line_width / 2.0f); num_rect++; } if(border_side & LV_BORDER_SIDE_LEFT) { rect[num_rect].x = coords->x1 - ceil(line_width / 2.0f); rect[num_rect].y = coords->y1 - ceil(line_width / 2.0f); - rect[num_rect].width = line_width; - rect[num_rect].height = coords->y2 - coords->y1 + line_width; + rect[num_rect].width = final_radius + ceil(line_width / 2.0f); + rect[num_rect].height = coords->y2 - coords->y1 + line_width + 1; num_rect++; } if(border_side & LV_BORDER_SIDE_RIGHT) { - rect[num_rect].x = coords->x2 - ceil(line_width / 2.0f); + rect[num_rect].x = coords->x2 - final_radius + 1; rect[num_rect].y = coords->y1 - ceil(line_width / 2.0f); - rect[num_rect].width = line_width; - rect[num_rect].height = coords->y2 - coords->y1 + line_width; + rect[num_rect].width = final_radius + ceil(line_width / 2.0f); + rect[num_rect].height = coords->y2 - coords->y1 + line_width + 1; num_rect++; } if(border_side & LV_BORDER_SIDE_BOTTOM) { rect[num_rect].x = coords->x1 - ceil(line_width / 2.0f); - rect[num_rect].y = coords->y2 - ceil(line_width / 2.0f); + rect[num_rect].y = coords->y2 - final_radius + 1; rect[num_rect].width = coords->x2 - coords->x1 + line_width; - rect[num_rect].height = line_width; + rect[num_rect].height = final_radius + ceil(line_width / 2.0f); num_rect++; } diff --git a/src/draw/nxp/vglite/lv_draw_vglite_img.c b/src/draw/nxp/vglite/lv_draw_vglite_img.c index 83dcc7d92031..3a8a93eb599d 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite_img.c +++ b/src/draw/nxp/vglite/lv_draw_vglite_img.c @@ -381,7 +381,7 @@ static void _vglite_draw_pattern(const lv_area_t * clip_area, const lv_area_t * /* Path to draw */ int32_t path_data[RECT_PATH_DATA_MAX_SIZE]; uint32_t path_data_size; - vglite_create_rect_path_data(path_data, &path_data_size, 0, coords); + vglite_create_rect_path_data(path_data, &path_data_size, dsc->clip_radius, coords); vg_lite_quality_t path_quality = VG_LITE_MEDIUM; vg_lite_path_t path;