feat(vg_lite): add profiler instrumentation (#5434)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
_VIFEXTech
2024-01-23 19:17:31 +08:00
committed by GitHub
parent 1a182a70ed
commit 5c9a0cc017
14 changed files with 127 additions and 2 deletions

View File

@@ -80,6 +80,7 @@ void lv_vg_lite_path_deinit(struct _lv_draw_vg_lite_unit_t * unit)
lv_vg_lite_path_t * lv_vg_lite_path_create(vg_lite_format_t data_format)
{
LV_PROFILER_BEGIN;
lv_vg_lite_path_t * path = lv_malloc_zeroed(sizeof(lv_vg_lite_path_t));
LV_ASSERT_MALLOC(path);
path->format_len = lv_vg_lite_path_format_len(data_format);
@@ -91,17 +92,20 @@ lv_vg_lite_path_t * lv_vg_lite_path_create(vg_lite_format_t data_format)
NULL,
0, 0, 0, 0)
== VG_LITE_SUCCESS);
LV_PROFILER_END;
return path;
}
void lv_vg_lite_path_destroy(lv_vg_lite_path_t * path)
{
LV_PROFILER_BEGIN;
LV_ASSERT_NULL(path);
if(path->base.path != NULL) {
lv_free(path->base.path);
path->base.path = NULL;
}
lv_free(path);
LV_PROFILER_END;
}
lv_vg_lite_path_t * lv_vg_lite_path_get(struct _lv_draw_vg_lite_unit_t * unit, vg_lite_format_t data_format)
@@ -205,6 +209,8 @@ bool lv_vg_lite_path_update_bonding_box(lv_vg_lite_path_t * path)
return false;
}
LV_PROFILER_BEGIN;
lv_vg_lite_path_bounds_t bounds;
/* init bounds */
@@ -219,6 +225,8 @@ bool lv_vg_lite_path_update_bonding_box(lv_vg_lite_path_t * path)
/* set bounds */
lv_vg_lite_path_set_bonding_box(path, bounds.min_x, bounds.min_y, bounds.max_x, bounds.max_y);
LV_PROFILER_END;
return true;
}
@@ -323,6 +331,7 @@ void lv_vg_lite_path_append_rect(
float w, float h,
float rx, float ry)
{
LV_PROFILER_BEGIN;
const float half_w = w * 0.5f;
const float half_h = h * 0.5f;
@@ -339,12 +348,15 @@ void lv_vg_lite_path_append_rect(
lv_vg_lite_path_line_to(path, x + w, y + h);
lv_vg_lite_path_line_to(path, x, y + h);
lv_vg_lite_path_close(path);
LV_PROFILER_END;
return;
}
/*circle*/
if(math_equal(rx, half_w) && math_equal(ry, half_h)) {
return 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 + (w * 0.5f), y + (h * 0.5f), rx, ry);
LV_PROFILER_END;
return;
}
/*rounded rectangle*/
@@ -360,6 +372,7 @@ void lv_vg_lite_path_append_rect(
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);
lv_vg_lite_path_close(path);
LV_PROFILER_END;
}
void lv_vg_lite_path_append_circle(
@@ -367,6 +380,7 @@ void lv_vg_lite_path_append_circle(
float cx, float cy,
float rx, float ry)
{
LV_PROFILER_BEGIN;
/* https://learn.microsoft.com/zh-cn/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/beziers */
float rx_kappa = rx * PATH_KAPPA;
float ry_kappa = ry * PATH_KAPPA;
@@ -377,6 +391,7 @@ void lv_vg_lite_path_append_circle(
lv_vg_lite_path_cubic_to(path, cx - rx_kappa, cy + ry, cx - rx, cy + ry_kappa, cx - rx, cy);
lv_vg_lite_path_cubic_to(path, cx - rx, cy - ry_kappa, cx - rx_kappa, cy - ry, cx, cy - ry);
lv_vg_lite_path_close(path);
LV_PROFILER_END;
}
void lv_vg_lite_path_append_arc_right_angle(lv_vg_lite_path_t * path,
@@ -384,6 +399,7 @@ void lv_vg_lite_path_append_arc_right_angle(lv_vg_lite_path_t * path,
float center_x, float center_y,
float end_x, float end_y)
{
LV_PROFILER_BEGIN;
float dx1 = center_x - start_x;
float dy1 = center_y - start_y;
float dx2 = end_x - center_x;
@@ -395,6 +411,7 @@ void lv_vg_lite_path_append_arc_right_angle(lv_vg_lite_path_t * path,
start_x - c * dy1, start_y + c * dx1,
end_x - c * dy2, end_y + c * dx2,
end_x, end_y);
LV_PROFILER_END;
}
void lv_vg_lite_path_append_arc(lv_vg_lite_path_t * path,
@@ -404,9 +421,12 @@ void lv_vg_lite_path_append_arc(lv_vg_lite_path_t * path,
float sweep,
bool pie)
{
LV_PROFILER_BEGIN;
/* just circle */
if(sweep >= 360.0f || sweep <= -360.0f) {
return lv_vg_lite_path_append_circle(path, cx, cy, radius, radius);
lv_vg_lite_path_append_circle(path, cx, cy, radius, radius);
LV_PROFILER_END;
return;
}
start_angle = MATH_RADIANS(start_angle);
@@ -466,6 +486,8 @@ void lv_vg_lite_path_append_arc(lv_vg_lite_path_t * path,
if(pie) {
lv_vg_lite_path_close(path);
}
LV_PROFILER_END;
}
uint8_t lv_vg_lite_vlc_op_arg_len(uint8_t vlc_op)