1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

feat(vg_lite): add matrix assert (#5766)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
_VIFEXTech 2024-03-06 10:11:46 +08:00 committed by GitHub
parent 481dd7b912
commit 2e3b5dc667
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 34 additions and 1 deletions

View File

@ -162,6 +162,7 @@ void lv_draw_vg_lite_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * d
LV_VG_LITE_ASSERT_DEST_BUFFER(&u->target_buffer);
LV_VG_LITE_ASSERT_PATH(vg_lite_path);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw(
@ -184,6 +185,8 @@ void lv_draw_vg_lite_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * d
/* move image to center */
vg_lite_translate(cx - radius_out, cy - radius_out, &matrix);
LV_VG_LITE_ASSERT_MATRIX(&path_matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw_pattern");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw_pattern(
&u->target_buffer,

View File

@ -98,6 +98,7 @@ void lv_draw_vg_lite_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc
LV_VG_LITE_ASSERT_DEST_BUFFER(&u->target_buffer);
LV_VG_LITE_ASSERT_PATH(vg_lite_path);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw(

View File

@ -82,6 +82,7 @@ void lv_draw_vg_lite_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t *
LV_VG_LITE_ASSERT_DEST_BUFFER(&u->target_buffer);
LV_VG_LITE_ASSERT_PATH(vg_lite_path);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
if(dsc->grad.dir != LV_GRAD_DIR_NONE) {
vg_lite_matrix_t grad_matrix;

View File

@ -285,6 +285,7 @@ static void draw_letter_outline(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_
LV_VG_LITE_ASSERT_DEST_BUFFER(&u->target_buffer);
LV_VG_LITE_ASSERT_PATH(vg_lite_path);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw(

View File

@ -194,6 +194,7 @@ void lv_draw_vg_lite_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t *
LV_VG_LITE_ASSERT_DEST_BUFFER(&u->target_buffer);
LV_VG_LITE_ASSERT_PATH(vg_lite_path);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw(

View File

@ -75,6 +75,7 @@ void lv_draw_vg_lite_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle
vg_lite_matrix_t matrix;
vg_lite_identity(&matrix);
lv_vg_lite_matrix_multiply(&matrix, &u->global_matrix);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
if(dsc->bg_grad.dir != LV_GRAD_DIR_NONE) {
vg_lite_matrix_t grad_matrix;

View File

@ -101,6 +101,7 @@ static void task_draw_cb(void * ctx, const lv_vector_path_t * path, const lv_vec
/* transform matrix */
vg_lite_matrix_t matrix;
lv_matrix_to_vg(&matrix, &dsc->matrix);
LV_VG_LITE_ASSERT_MATRIX(&matrix);
/* convert path */
lv_vg_lite_path_t * lv_vg_path = lv_vg_lite_path_get(u, VG_LITE_FP32);
@ -169,6 +170,8 @@ static void task_draw_cb(void * ctx, const lv_vector_path_t * path, const lv_vec
vg_lite_color_t recolor = lv_vg_lite_color(dsc->fill_dsc.img_dsc.recolor, dsc->fill_dsc.img_dsc.recolor_opa, true);
LV_VG_LITE_ASSERT_MATRIX(&pattern_matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw_pattern");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw_pattern(
&u->target_buffer,

View File

@ -130,6 +130,8 @@ void lv_vg_lite_draw_linear_grad(
LV_VG_LITE_ASSERT_DEST_BUFFER(buffer);
LV_VG_LITE_ASSERT_SRC_BUFFER(&gradient->image);
LV_VG_LITE_ASSERT_PATH(path);
LV_VG_LITE_ASSERT_MATRIX(grad_mat_p);
LV_VG_LITE_ASSERT_MATRIX(matrix);
LV_PROFILER_BEGIN_TAG("vg_lite_draw_grad");
LV_VG_LITE_CHECK_ERROR(vg_lite_draw_grad(

View File

@ -297,7 +297,7 @@ void lv_vg_lite_buffer_dump_info(const vg_lite_buffer_t * buffer)
void lv_vg_lite_matrix_dump_info(const vg_lite_matrix_t * matrix)
{
for(int i = 0; i < 3; i++) {
LV_LOG_USER("| %0.2f, %0.2f, %0.2f |",
LV_LOG_USER("| %f, %f, %f |",
(matrix)->m[i][0], (matrix)->m[i][1], (matrix)->m[i][2]);
}
}
@ -904,6 +904,23 @@ bool lv_vg_lite_path_check(const vg_lite_path_t * path)
return true;
}
bool lv_vg_lite_matrix_check(const vg_lite_matrix_t * matrix)
{
if(matrix == NULL) {
LV_LOG_ERROR("matrix is NULL");
return false;
}
vg_lite_matrix_t result;
if(!lv_vg_lite_matrix_inverse(&result, matrix)) {
LV_LOG_ERROR("matrix is not invertible");
lv_vg_lite_matrix_dump_info(matrix);
return false;
}
return true;
}
bool lv_vg_lite_support_blend_normal(void)
{
return vg_lite_query_feature(gcFEATURE_BIT_VG_LVGL_SUPPORT);

View File

@ -54,6 +54,7 @@ extern "C" {
#define LV_VG_LITE_ASSERT_PATH(path) LV_VG_LITE_ASSERT(lv_vg_lite_path_check(path))
#define LV_VG_LITE_ASSERT_SRC_BUFFER(buffer) LV_VG_LITE_ASSERT(lv_vg_lite_buffer_check(buffer, true))
#define LV_VG_LITE_ASSERT_DEST_BUFFER(buffer) LV_VG_LITE_ASSERT(lv_vg_lite_buffer_check(buffer, false))
#define LV_VG_LITE_ASSERT_MATRIX(matrix) LV_VG_LITE_ASSERT(lv_vg_lite_matrix_check(matrix))
#define LV_VG_LITE_ALIGN(number, align_bytes) \
(((number) + ((align_bytes)-1)) & ~((align_bytes)-1))
@ -145,6 +146,8 @@ bool lv_vg_lite_buffer_check(const vg_lite_buffer_t * buffer, bool is_src);
bool lv_vg_lite_path_check(const vg_lite_path_t * path);
bool lv_vg_lite_matrix_check(const vg_lite_matrix_t * matrix);
/* Wrapper */
bool lv_vg_lite_support_blend_normal(void);