fix(vg_lite): fix rounded rectangle path error (#6726)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
@ -73,13 +73,13 @@ void lv_draw_vg_lite_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc
|
||||
lv_vg_lite_path_append_rect(path,
|
||||
coords->x1, coords->y1,
|
||||
w, h,
|
||||
r_out, r_out);
|
||||
r_out);
|
||||
|
||||
/* inner rect */
|
||||
lv_vg_lite_path_append_rect(path,
|
||||
coords->x1 + border_w, coords->y1 + border_w,
|
||||
w - border_w * 2, h - border_w * 2,
|
||||
r_in, r_in);
|
||||
r_in);
|
||||
|
||||
lv_vg_lite_path_end(path);
|
||||
|
||||
|
@ -72,7 +72,7 @@ void lv_draw_vg_lite_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t *
|
||||
lv_vg_lite_path_t * path = lv_vg_lite_path_get(u, VG_LITE_FP32);
|
||||
lv_vg_lite_path_set_quality(path, dsc->radius == 0 ? VG_LITE_LOW : VG_LITE_HIGH);
|
||||
lv_vg_lite_path_set_bonding_box_area(path, &clip_area);
|
||||
lv_vg_lite_path_append_rect(path, coords->x1, coords->y1, w, h, r, r);
|
||||
lv_vg_lite_path_append_rect(path, coords->x1, coords->y1, w, h, r);
|
||||
lv_vg_lite_path_end(path);
|
||||
|
||||
vg_lite_path_t * vg_lite_path = lv_vg_lite_path_get_path(path);
|
||||
|
@ -140,14 +140,14 @@ void lv_draw_vg_lite_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t *
|
||||
path,
|
||||
coords->x1, coords->y1,
|
||||
width, height,
|
||||
radius, radius);
|
||||
radius);
|
||||
}
|
||||
else {
|
||||
lv_vg_lite_path_append_rect(
|
||||
path,
|
||||
clip_area.x1, clip_area.y1,
|
||||
lv_area_get_width(&clip_area), lv_area_get_height(&clip_area),
|
||||
0, 0);
|
||||
0);
|
||||
}
|
||||
|
||||
lv_vg_lite_path_set_bonding_box_area(path, &clip_area);
|
||||
|
@ -191,7 +191,7 @@ static void draw_letter_bitmap(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_d
|
||||
path,
|
||||
clip_area.x1, clip_area.y1,
|
||||
lv_area_get_width(&clip_area), lv_area_get_height(&clip_area),
|
||||
0, 0);
|
||||
0);
|
||||
lv_vg_lite_path_set_bonding_box_area(path, &clip_area);
|
||||
lv_vg_lite_path_end(path);
|
||||
|
||||
|
@ -113,8 +113,8 @@ void lv_draw_vg_lite_mask_rect(lv_draw_unit_t * draw_unit, const lv_draw_mask_re
|
||||
lv_vg_lite_path_set_bonding_box_area(path, &draw_area);
|
||||
|
||||
/* Use rounded rectangles and normal rectangles of the same size to nest the cropped area */
|
||||
lv_vg_lite_path_append_rect(path, dsc->area.x1, dsc->area.y1, w, h, r, r);
|
||||
lv_vg_lite_path_append_rect(path, dsc->area.x1, dsc->area.y1, w, h, 0, 0);
|
||||
lv_vg_lite_path_append_rect(path, dsc->area.x1, dsc->area.y1, w, h, r);
|
||||
lv_vg_lite_path_append_rect(path, dsc->area.x1, dsc->area.y1, w, h, 0);
|
||||
lv_vg_lite_path_end(path);
|
||||
|
||||
vg_lite_path_t * vg_lite_path = lv_vg_lite_path_get_path(path);
|
||||
|
@ -334,20 +334,19 @@ void lv_vg_lite_path_append_rect(
|
||||
lv_vg_lite_path_t * path,
|
||||
float x, float y,
|
||||
float w, float h,
|
||||
float rx, float ry)
|
||||
float r)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
const float half_w = w * 0.5f;
|
||||
const float half_h = h * 0.5f;
|
||||
const float half_w = w / 2.0f;
|
||||
const float half_h = h / 2.0f;
|
||||
|
||||
/*clamping cornerRadius by minimum size*/
|
||||
if(rx > half_w)
|
||||
rx = half_w;
|
||||
if(ry > half_h)
|
||||
ry = half_h;
|
||||
const float r_max = LV_MIN(half_w, half_h);
|
||||
if(r > r_max)
|
||||
r = r_max;
|
||||
|
||||
/*rectangle*/
|
||||
if(rx == 0 && ry == 0) {
|
||||
if(r <= 0) {
|
||||
lv_vg_lite_path_move_to(path, x, y);
|
||||
lv_vg_lite_path_line_to(path, x + w, y);
|
||||
lv_vg_lite_path_line_to(path, x + w, y + h);
|
||||
@ -358,24 +357,44 @@ void lv_vg_lite_path_append_rect(
|
||||
}
|
||||
|
||||
/*circle*/
|
||||
if(math_equal(rx, half_w) && math_equal(ry, half_h)) {
|
||||
lv_vg_lite_path_append_circle(path, x + (w * 0.5f), y + (h * 0.5f), rx, ry);
|
||||
if(math_equal(r, half_w) && math_equal(r, half_h)) {
|
||||
lv_vg_lite_path_append_circle(path, x + half_w, y + half_h, r, r);
|
||||
LV_PROFILER_END;
|
||||
return;
|
||||
}
|
||||
|
||||
/*rounded rectangle*/
|
||||
float hrx = rx * 0.5f;
|
||||
float hry = ry * 0.5f;
|
||||
lv_vg_lite_path_move_to(path, x + rx, y);
|
||||
lv_vg_lite_path_line_to(path, x + w - rx, y);
|
||||
lv_vg_lite_path_cubic_to(path, x + w - rx + hrx, y, x + w, y + ry - hry, x + w, y + ry);
|
||||
lv_vg_lite_path_line_to(path, x + w, y + h - ry);
|
||||
lv_vg_lite_path_cubic_to(path, x + w, y + h - ry + hry, x + w - rx + hrx, y + h, x + w - rx, y + h);
|
||||
lv_vg_lite_path_line_to(path, x + rx, y + h);
|
||||
lv_vg_lite_path_cubic_to(path, x + rx - hrx, y + h, x, y + h - ry + hry, x, y + h - ry);
|
||||
lv_vg_lite_path_line_to(path, x, y + ry);
|
||||
lv_vg_lite_path_cubic_to(path, x, y + ry - hry, x + rx - hrx, y, x + rx, y);
|
||||
/* Get the control point offset for rounded cases */
|
||||
const float offset = r * PATH_ARC_MAGIC;
|
||||
|
||||
/* Rounded rectangle case */
|
||||
/* Starting point */
|
||||
lv_vg_lite_path_move_to(path, x + r, y);
|
||||
|
||||
/* Top side */
|
||||
lv_vg_lite_path_line_to(path, x + w - r, y);
|
||||
|
||||
/* Top-right corner */
|
||||
lv_vg_lite_path_cubic_to(path, x + w - r + offset, y, x + w, y + r - offset, x + w, y + r);
|
||||
|
||||
/* Right side */
|
||||
lv_vg_lite_path_line_to(path, x + w, y + h - r);
|
||||
|
||||
/* Bottom-right corner*/
|
||||
lv_vg_lite_path_cubic_to(path, x + w, y + h - r + offset, x + w - r + offset, y + h, x + w - r, y + h);
|
||||
|
||||
/* Bottom side */
|
||||
lv_vg_lite_path_line_to(path, x + r, y + h);
|
||||
|
||||
/* Bottom-left corner */
|
||||
lv_vg_lite_path_cubic_to(path, x + r - offset, y + h, x, y + h - r + offset, x, y + h - r);
|
||||
|
||||
/* Left side*/
|
||||
lv_vg_lite_path_line_to(path, x, y + r);
|
||||
|
||||
/* Top-left corner */
|
||||
lv_vg_lite_path_cubic_to(path, x, y + r - offset, x + r - offset, y, x + r, y);
|
||||
|
||||
/* Ending point */
|
||||
lv_vg_lite_path_close(path);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void lv_vg_lite_path_end(lv_vg_lite_path_t * path);
|
||||
void lv_vg_lite_path_append_rect(lv_vg_lite_path_t * path,
|
||||
float x, float y,
|
||||
float w, float h,
|
||||
float rx, float ry);
|
||||
float r);
|
||||
|
||||
void lv_vg_lite_path_append_circle(lv_vg_lite_path_t * path,
|
||||
float cx, float cy,
|
||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 156 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |