Skip to content

Commit

Permalink
perf(vg_lite): optimize label drawing efficiency (lvgl#6853)
Browse files Browse the repository at this point in the history
Signed-off-by: pengyiqiang <[email protected]>
Co-authored-by: pengyiqiang <[email protected]>
  • Loading branch information
FASTSHIFT and pengyiqiang authored Sep 18, 2024
1 parent eecb3c7 commit b8f3d1e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/draw/vg_lite/lv_draw_vg_lite_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@

#define PATH_QUALITY VG_LITE_HIGH
#define PATH_DATA_COORD_FORMAT VG_LITE_S16

#if LV_VG_LITE_FLUSH_MAX_COUNT > 0
#define PATH_FLUSH_COUNT_MAX 0
#else
/* When using IDLE Flush mode, reduce the number of flushes */
#define PATH_FLUSH_COUNT_MAX 8
#endif

#define FT_F26DOT6_SHIFT 6

/** After converting the font reference size, it is also necessary to scale the 26dot6 data
Expand Down Expand Up @@ -137,6 +145,12 @@ static void draw_letter_cb(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * gly
if(fill_draw_dsc && fill_area) {
lv_draw_vg_lite_fill(draw_unit, fill_draw_dsc, fill_area);
}

/* Flush in time to avoid accumulation of drawing commands */
u->letter_count++;
if(u->letter_count > PATH_FLUSH_COUNT_MAX) {
lv_vg_lite_flush(u);
}
}

static void draw_letter_bitmap(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_dsc_t * dsc)
Expand Down Expand Up @@ -289,9 +303,6 @@ static void draw_letter_outline(lv_draw_vg_lite_unit_t * u, const lv_draw_glyph_
&draw_matrix, VG_LITE_BLEND_SRC_OVER, lv_vg_lite_color(dsc->color, dsc->opa, true)));
LV_PROFILER_END_TAG("vg_lite_draw");

/* Flush in time to avoid accumulation of drawing commands */
lv_vg_lite_flush(u);

LV_PROFILER_END;
}

Expand Down
1 change: 1 addition & 0 deletions src/draw/vg_lite/lv_draw_vg_lite_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct _lv_draw_vg_lite_unit_t {
lv_cache_t * stroke_cache;

uint16_t flush_count;
uint16_t letter_count;
vg_lite_buffer_t target_buffer;
vg_lite_matrix_t global_matrix;
struct _lv_vg_lite_path_t * global_path;
Expand Down
2 changes: 2 additions & 0 deletions src/draw/vg_lite/lv_vg_lite_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ void lv_vg_lite_flush(struct _lv_draw_vg_lite_unit_t * u)
LV_PROFILER_BEGIN;

u->flush_count++;
u->letter_count = 0;

#if LV_VG_LITE_FLUSH_MAX_COUNT
if(u->flush_count < LV_VG_LITE_FLUSH_MAX_COUNT) {
Expand Down Expand Up @@ -1212,6 +1213,7 @@ void lv_vg_lite_finish(struct _lv_draw_vg_lite_unit_t * u)
/* Clear image decoder dsc reference */
lv_vg_lite_pending_remove_all(u->image_dsc_pending);
u->flush_count = 0;
u->letter_count = 0;
LV_PROFILER_END;
}

Expand Down

0 comments on commit b8f3d1e

Please sign in to comment.