Skip to content

Commit

Permalink
feat(profiler): support different module divisions (lvgl#6834)
Browse files Browse the repository at this point in the history
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: liuhongchao <liuhongchao@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
  • Loading branch information
3 people authored Sep 18, 2024
1 parent 1dd63c7 commit a89cda1
Show file tree
Hide file tree
Showing 44 changed files with 675 additions and 268 deletions.
49 changes: 46 additions & 3 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1411,21 +1411,64 @@ menu "LVGL configuration"
bool "Center"
endchoice

config LV_USE_PROFILER
menuconfig LV_USE_PROFILER
bool "Runtime performance profiler"

if LV_USE_PROFILER

config LV_USE_PROFILER_BUILTIN
bool "Enable the built-in profiler"
depends on LV_USE_PROFILER
default y
config LV_PROFILER_BUILTIN_BUF_SIZE
int "Default profiler trace buffer size in bytes"
depends on LV_USE_PROFILER_BUILTIN
default 16384
config LV_PROFILER_INCLUDE
string "Header to include for the profiler"
depends on LV_USE_PROFILER
default "lvgl/src/misc/lv_profiler_builtin.h"

config LV_PROFILER_LAYOUT
bool "Enable layout profiler"
default y

config LV_PROFILER_REFR
bool "Enable disp refr profiler"
default y

config LV_PROFILER_DRAW
bool "Enable draw profiler"
default y

config LV_PROFILER_INDEV
bool "Enable indev profiler"
default y

config LV_PROFILER_DECODER
bool "Enable decoder profiler"
default y

config LV_PROFILER_FONT
bool "Enable font profiler"
default y

config LV_PROFILER_FS
bool "Enable fs profiler"
default y

config LV_PROFILER_STYLE
bool "Enable style profiler"
default n

config LV_PROFILER_TIMER
bool "Enable timer profiler"
default y

config LV_PROFILER_CACHE
bool "Enable cache profiler"
default y

endif # LV_USE_PROFILER

config LV_USE_MONKEY
bool "Enable Monkey test"
default n
Expand Down
30 changes: 30 additions & 0 deletions lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,36 @@

/** Profiler end point function with custom tag */
#define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG

/*Enable layout profiler*/
#define LV_PROFILER_LAYOUT 1

/*Enable disp refr profiler*/
#define LV_PROFILER_REFR 1

/*Enable draw profiler*/
#define LV_PROFILER_DRAW 1

/*Enable indev profiler*/
#define LV_PROFILER_INDEV 1

/*Enable decoder profiler*/
#define LV_PROFILER_DECODER 1

/*Enable font profiler*/
#define LV_PROFILER_FONT 1

/*Enable fs profiler*/
#define LV_PROFILER_FS 1

/*Enable style profiler*/
#define LV_PROFILER_STYLE 0

/*Enable timer profiler*/
#define LV_PROFILER_TIMER 1

/*Enable cache profiler*/
#define LV_PROFILER_CACHE 1
#endif

/** 1: Enable Monkey test */
Expand Down
4 changes: 2 additions & 2 deletions src/core/lv_obj_pos.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void lv_obj_update_layout(const lv_obj_t * obj)
LV_LOG_TRACE("Already running, returning");
return;
}
LV_PROFILER_BEGIN;
LV_PROFILER_LAYOUT_BEGIN;
update_layout_mutex = true;

lv_obj_t * scr = lv_obj_get_screen(obj);
Expand All @@ -309,7 +309,7 @@ void lv_obj_update_layout(const lv_obj_t * obj)
}

update_layout_mutex = false;
LV_PROFILER_END;
LV_PROFILER_LAYOUT_END;
}

void lv_obj_set_align(lv_obj_t * obj, lv_align_t align)
Expand Down
6 changes: 6 additions & 0 deletions src/core/lv_obj_style.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style

if(!style_refr) return;

LV_PROFILER_STYLE_BEGIN;

lv_obj_invalidate(obj);

lv_part_t part = lv_obj_style_get_selector_part(selector);
Expand Down Expand Up @@ -316,6 +318,8 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style
refresh_children_style(obj);
}
}

LV_PROFILER_STYLE_END;
}

void lv_obj_enable_style_refresh(bool en)
Expand Down Expand Up @@ -353,6 +357,7 @@ bool lv_obj_has_style_prop(const lv_obj_t * obj, lv_style_selector_t selector, l
void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value,
lv_style_selector_t selector)
{
LV_PROFILER_STYLE_BEGIN;
lv_style_t * style = get_local_style(obj, selector);
if(selector == LV_PART_MAIN && lv_style_prop_has_flag(prop, LV_STYLE_PROP_FLAG_TRANSFORM)) {
lv_obj_invalidate(obj);
Expand All @@ -371,6 +376,7 @@ void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_
#endif

lv_obj_refresh_style(obj, selector, prop);
LV_PROFILER_STYLE_END;
}

lv_style_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value,
Expand Down
44 changes: 23 additions & 21 deletions src/core/lv_refr.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void lv_refr_set_disp_refreshing(lv_display_t * disp)

void lv_display_refr_timer(lv_timer_t * tmr)
{
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
LV_TRACE_REFR("begin");

if(tmr) {
Expand All @@ -365,26 +365,28 @@ void lv_display_refr_timer(lv_timer_t * tmr)

if(disp_refr == NULL) {
LV_LOG_WARN("No display registered");
LV_PROFILER_REFR_END;
return;
}

lv_draw_buf_t * buf_act = disp_refr->buf_act;
if(!(buf_act && buf_act->data && buf_act->data_size)) {
LV_LOG_WARN("No draw buffer");
LV_PROFILER_REFR_END;
return;
}

lv_display_send_event(disp_refr, LV_EVENT_REFR_START, NULL);

/*Refresh the screen's layout if required*/
LV_PROFILER_BEGIN_TAG("layout");
LV_PROFILER_LAYOUT_BEGIN_TAG("layout");
lv_obj_update_layout(disp_refr->act_scr);
if(disp_refr->prev_scr) lv_obj_update_layout(disp_refr->prev_scr);

lv_obj_update_layout(disp_refr->bottom_layer);
lv_obj_update_layout(disp_refr->top_layer);
lv_obj_update_layout(disp_refr->sys_layer);
LV_PROFILER_END_TAG("layout");
LV_PROFILER_LAYOUT_END_TAG("layout");

/*Do nothing if there is no active screen*/
if(disp_refr->act_scr == NULL) {
Expand Down Expand Up @@ -428,7 +430,7 @@ void lv_display_refr_timer(lv_timer_t * tmr)
lv_display_send_event(disp_refr, LV_EVENT_REFR_READY, NULL);

LV_TRACE_REFR("finished");
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

/**********************
Expand All @@ -440,7 +442,7 @@ void lv_display_refr_timer(lv_timer_t * tmr)
*/
static void lv_refr_join_area(void)
{
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
uint32_t join_from;
uint32_t join_in;
lv_area_t joined_area;
Expand Down Expand Up @@ -471,7 +473,7 @@ static void lv_refr_join_area(void)
}
}
}
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

/**
Expand All @@ -488,7 +490,7 @@ static void refr_sync_areas(void)
/*Do not sync if no sync areas*/
if(lv_ll_is_empty(&disp_refr->sync_areas)) return;

LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
/*With double buffered direct mode synchronize the rendered areas to the other buffer*/
/*We need to wait for ready here to not mess up the active screen*/
wait_for_flushing(disp_refr);
Expand Down Expand Up @@ -549,7 +551,7 @@ static void refr_sync_areas(void)

/*Clear sync areas*/
lv_ll_clear(&disp_refr->sync_areas);
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

/**
Expand All @@ -558,7 +560,7 @@ static void refr_sync_areas(void)
static void refr_invalid_areas(void)
{
if(disp_refr->inv_p == 0) return;
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;

/*Find the last area which will be drawn*/
int32_t i;
Expand Down Expand Up @@ -588,7 +590,7 @@ static void refr_invalid_areas(void)
}

disp_refr->rendering_in_progress = false;
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

/**
Expand All @@ -613,7 +615,7 @@ static void layer_reshape_draw_buf(lv_layer_t * layer, uint32_t stride)
*/
static void refr_area(const lv_area_t * area_p)
{
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
lv_layer_t * layer = disp_refr->layer_head;
layer->draw_buf = disp_refr->buf_act;

Expand Down Expand Up @@ -646,7 +648,7 @@ static void refr_area(const lv_area_t * area_p)
layer->phy_clip_area = *area_p;
refr_area_part(layer);
}
LV_PROFILER_END;
LV_PROFILER_REFR_END;
return;
}

Expand Down Expand Up @@ -694,12 +696,12 @@ static void refr_area(const lv_area_t * area_p)
disp_refr->last_part = 1;
refr_area_part(layer);
}
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

static void refr_area_part(lv_layer_t * layer)
{
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
disp_refr->refreshed_area = layer->_clip_area;

/* In single buffered mode wait here until the buffer is freed.
Expand Down Expand Up @@ -758,7 +760,7 @@ static void refr_area_part(lv_layer_t * layer)
refr_obj_and_children(layer, lv_display_get_layer_sys(disp_refr));

draw_buf_flush(disp_refr);
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

/**
Expand Down Expand Up @@ -815,7 +817,7 @@ static void refr_obj_and_children(lv_layer_t * layer, lv_obj_t * top_obj)
if(top_obj == NULL) top_obj = lv_display_get_screen_active(disp_refr);
if(top_obj == NULL) return; /*Shouldn't happen*/

LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
/*Refresh the top object and its children*/
refr_obj(layer, top_obj);

Expand Down Expand Up @@ -852,7 +854,7 @@ static void refr_obj_and_children(lv_layer_t * layer, lv_obj_t * top_obj)
/*Go a level deeper*/
parent = lv_obj_get_parent(parent);
}
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

static lv_result_t layer_get_area(lv_layer_t * layer, lv_obj_t * obj, lv_layer_type_t layer_type,
Expand Down Expand Up @@ -1190,7 +1192,7 @@ static void draw_buf_flush(lv_display_t * disp)

static void call_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map)
{
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
LV_TRACE_REFR("Calling flush_cb on (%d;%d)(%d;%d) area with %p image pointer",
(int)area->x1, (int)area->y1, (int)area->x2, (int)area->y2, (void *)px_map);

Expand All @@ -1211,12 +1213,12 @@ static void call_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t *
disp->flush_cb(disp, &offset_area, px_map);
lv_display_send_event(disp, LV_EVENT_FLUSH_FINISH, &offset_area);

LV_PROFILER_END;
LV_PROFILER_REFR_END;
}

static void wait_for_flushing(lv_display_t * disp)
{
LV_PROFILER_BEGIN;
LV_PROFILER_REFR_BEGIN;
LV_LOG_TRACE("begin");

lv_display_send_event(disp, LV_EVENT_FLUSH_WAIT_START, NULL);
Expand All @@ -1235,5 +1237,5 @@ static void wait_for_flushing(lv_display_t * disp)
lv_display_send_event(disp, LV_EVENT_FLUSH_WAIT_FINISH, NULL);

LV_LOG_TRACE("end");
LV_PROFILER_END;
LV_PROFILER_REFR_END;
}
Loading

0 comments on commit a89cda1

Please sign in to comment.