fix(vg_lite): fix rounded rectangle path error (#6726)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
VIFEX
2024-08-26 17:43:56 +08:00
committed by GitHub
parent 9c4d4ba595
commit 6b8d420170
239 changed files with 50 additions and 31 deletions
+2 -2
View File
@@ -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, lv_vg_lite_path_append_rect(path,
coords->x1, coords->y1, coords->x1, coords->y1,
w, h, w, h,
r_out, r_out); r_out);
/* inner rect */ /* inner rect */
lv_vg_lite_path_append_rect(path, lv_vg_lite_path_append_rect(path,
coords->x1 + border_w, coords->y1 + border_w, coords->x1 + border_w, coords->y1 + border_w,
w - border_w * 2, h - border_w * 2, w - border_w * 2, h - border_w * 2,
r_in, r_in); r_in);
lv_vg_lite_path_end(path); lv_vg_lite_path_end(path);
+1 -1
View File
@@ -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_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_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_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); lv_vg_lite_path_end(path);
vg_lite_path_t * vg_lite_path = lv_vg_lite_path_get_path(path); vg_lite_path_t * vg_lite_path = lv_vg_lite_path_get_path(path);
+2 -2
View File
@@ -140,14 +140,14 @@ void lv_draw_vg_lite_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t *
path, path,
coords->x1, coords->y1, coords->x1, coords->y1,
width, height, width, height,
radius, radius); radius);
} }
else { else {
lv_vg_lite_path_append_rect( lv_vg_lite_path_append_rect(
path, path,
clip_area.x1, clip_area.y1, clip_area.x1, clip_area.y1,
lv_area_get_width(&clip_area), lv_area_get_height(&clip_area), 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_set_bonding_box_area(path, &clip_area);
+1 -1
View File
@@ -191,7 +191,7 @@ static void draw_letter_bitmap(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_d
path, path,
clip_area.x1, clip_area.y1, clip_area.x1, clip_area.y1,
lv_area_get_width(&clip_area), lv_area_get_height(&clip_area), 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_set_bonding_box_area(path, &clip_area);
lv_vg_lite_path_end(path); lv_vg_lite_path_end(path);
+2 -2
View File
@@ -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); 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 */ /* 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, 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, 0);
lv_vg_lite_path_end(path); lv_vg_lite_path_end(path);
vg_lite_path_t * vg_lite_path = lv_vg_lite_path_get_path(path); vg_lite_path_t * vg_lite_path = lv_vg_lite_path_get_path(path);
+41 -22
View File
@@ -334,20 +334,19 @@ void lv_vg_lite_path_append_rect(
lv_vg_lite_path_t * path, lv_vg_lite_path_t * path,
float x, float y, float x, float y,
float w, float h, float w, float h,
float rx, float ry) float r)
{ {
LV_PROFILER_BEGIN; LV_PROFILER_BEGIN;
const float half_w = w * 0.5f; const float half_w = w / 2.0f;
const float half_h = h * 0.5f; const float half_h = h / 2.0f;
/*clamping cornerRadius by minimum size*/ /*clamping cornerRadius by minimum size*/
if(rx > half_w) const float r_max = LV_MIN(half_w, half_h);
rx = half_w; if(r > r_max)
if(ry > half_h) r = r_max;
ry = half_h;
/*rectangle*/ /*rectangle*/
if(rx == 0 && ry == 0) { if(r <= 0) {
lv_vg_lite_path_move_to(path, x, y); 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);
lv_vg_lite_path_line_to(path, x + w, y + h); lv_vg_lite_path_line_to(path, x + w, y + h);
@@ -358,24 +357,44 @@ void lv_vg_lite_path_append_rect(
} }
/*circle*/ /*circle*/
if(math_equal(rx, half_w) && math_equal(ry, half_h)) { if(math_equal(r, half_w) && math_equal(r, half_h)) {
lv_vg_lite_path_append_circle(path, x + (w * 0.5f), y + (h * 0.5f), rx, ry); lv_vg_lite_path_append_circle(path, x + half_w, y + half_h, r, r);
LV_PROFILER_END; LV_PROFILER_END;
return; return;
} }
/*rounded rectangle*/ /* Get the control point offset for rounded cases */
float hrx = rx * 0.5f; const float offset = r * PATH_ARC_MAGIC;
float hry = ry * 0.5f;
lv_vg_lite_path_move_to(path, x + rx, y); /* Rounded rectangle case */
lv_vg_lite_path_line_to(path, x + w - rx, y); /* Starting point */
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_move_to(path, x + r, y);
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); /* Top side */
lv_vg_lite_path_line_to(path, x + rx, y + h); lv_vg_lite_path_line_to(path, x + w - r, y);
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); /* Top-right corner */
lv_vg_lite_path_cubic_to(path, x, y + ry - hry, x + rx - hrx, y, x + rx, y); 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_vg_lite_path_close(path);
LV_PROFILER_END; LV_PROFILER_END;
} }
+1 -1
View File
@@ -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, void lv_vg_lite_path_append_rect(lv_vg_lite_path_t * path,
float x, float y, float x, float y,
float w, float h, float w, float h,
float rx, float ry); float r);
void lv_vg_lite_path_append_circle(lv_vg_lite_path_t * path, void lv_vg_lite_path_append_circle(lv_vg_lite_path_t * path,
float cx, float cy, float cx, float cy,
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Some files were not shown because too many files have changed in this diff Show More