feat(vg_lite/vector): add compatible processing for non-scissor support (#5572)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
_VIFEXTech
2024-02-02 18:03:18 +08:00
committed by GitHub
parent 8a272e0950
commit 7a2c696185
3 changed files with 35 additions and 13 deletions

View File

@@ -94,9 +94,6 @@ static void task_draw_cb(void * ctx, const lv_vector_path_t * path, const lv_vec
return;
}
/* set scissor area */
lv_vg_lite_set_scissor_area(&dsc->scissor_area);
/* convert color */
vg_lite_color_t vg_color = lv_color32_to_vg(dsc->fill_dsc.color, dsc->fill_dsc.opa);
@@ -118,6 +115,30 @@ static void task_draw_cb(void * ctx, const lv_vector_path_t * path, const lv_vec
float min_x, min_y, max_x, max_y;
lv_vg_lite_path_get_bonding_box(lv_vg_path, &min_x, &min_y, &max_x, &max_y);
if(vg_lite_query_feature(gcFEATURE_BIT_VG_SCISSOR)) {
/* set scissor area */
lv_vg_lite_set_scissor_area(&dsc->scissor_area);
}
else {
/* calc inverse matrix */
vg_lite_matrix_t result;
if(!lv_vg_lite_matrix_inverse(&result, &matrix)) {
LV_LOG_ERROR("no inverse matrix");
LV_PROFILER_END;
return;
}
/* Reverse the clip area on the source */
lv_point_precise_t p1 = { dsc->scissor_area.x1, dsc->scissor_area.y1 };
lv_point_precise_t p1_res = lv_vg_lite_matrix_transform_point(&result, &p1);
/* vg-lite bounding_box will crop the pixels on the edge, so +1px is needed here */
lv_point_precise_t p2 = { dsc->scissor_area.x2 + 1, dsc->scissor_area.y2 + 1 };
lv_point_precise_t p2_res = lv_vg_lite_matrix_transform_point(&result, &p2);
lv_vg_lite_path_set_bonding_box(lv_vg_path, p1_res.x, p1_res.y, p2_res.x, p2_res.y);
}
switch(dsc->fill_dsc.style) {
case LV_VECTOR_DRAW_STYLE_SOLID: {
/* normal draw shape */
@@ -202,8 +223,10 @@ static void task_draw_cb(void * ctx, const lv_vector_path_t * path, const lv_vec
/* drop path */
lv_vg_lite_path_drop(u, lv_vg_path);
/* disable scissor */
lv_vg_lite_disable_scissor();
if(vg_lite_query_feature(gcFEATURE_BIT_VG_SCISSOR)) {
/* disable scissor */
lv_vg_lite_disable_scissor();
}
LV_PROFILER_END;
}

View File

@@ -1070,17 +1070,17 @@ lv_point_precise_t lv_vg_lite_matrix_transform_point(const vg_lite_matrix_t * ma
void lv_vg_lite_set_scissor_area(const lv_area_t * area)
{
vg_lite_enable_scissor();
vg_lite_set_scissor(
area->x1,
area->y1,
lv_area_get_width(area),
lv_area_get_height(area));
LV_VG_LITE_CHECK_ERROR(vg_lite_enable_scissor());
LV_VG_LITE_CHECK_ERROR(vg_lite_set_scissor(
area->x1,
area->y1,
lv_area_get_width(area),
lv_area_get_height(area)));
}
void lv_vg_lite_disable_scissor(void)
{
vg_lite_disable_scissor();
LV_VG_LITE_CHECK_ERROR(vg_lite_disable_scissor());
}
void lv_vg_lite_flush(lv_draw_unit_t * draw_unit)

View File

@@ -734,7 +734,6 @@ extern "C" {
{
switch(feature) {
case gcFEATURE_BIT_VG_IM_INDEX_FORMAT:
case gcFEATURE_BIT_VG_SCISSOR:
case gcFEATURE_BIT_VG_BORDER_CULLING:
case gcFEATURE_BIT_VG_RGBA2_FORMAT:
case gcFEATURE_BIT_VG_IM_FASTCLAER: