fix(benchmark): follow API changes
This commit is contained in:
@@ -94,13 +94,14 @@ LV_IMG_DECLARE(img_benchmark_cogwheel_alpha256);
|
||||
#endif
|
||||
|
||||
static void benchmark_init(void);
|
||||
static void benchmark_event_cb(lv_event_t * e);
|
||||
static void benchmark_event_remove(void);
|
||||
|
||||
static void show_scene_report(void);
|
||||
static void calc_scene_statistics(void);
|
||||
static lv_res_t load_next_scene(void);
|
||||
static void next_scene_timer_cb(lv_timer_t * timer);
|
||||
static void single_scene_finsih_timer_cb(lv_timer_t * timer);
|
||||
static void monitor_cb(lv_disp_t * drv, uint32_t time, uint32_t px);
|
||||
static void render_start_cb(lv_disp_t * drv);
|
||||
static void dummy_flush_cb(lv_disp_t * drv, const lv_area_t * area, lv_color_t * colors);
|
||||
static void generate_report(void);
|
||||
|
||||
@@ -751,23 +752,11 @@ static void benchmark_init(void)
|
||||
{
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
|
||||
/*Measure the time from render start to last flush_cb call*/
|
||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER) {
|
||||
disp->driver->render_start_cb = render_start_cb;
|
||||
flush_cb_ori = disp->driver->flush_cb;
|
||||
disp->driver->flush_cb = dummy_flush_cb;
|
||||
}
|
||||
/*Measure the time between last flush_cb calls*/
|
||||
else if(mode == LV_DEMO_BENCHMARK_MODE_REAL) {
|
||||
flush_cb_ori = disp->driver->flush_cb;
|
||||
disp->driver->flush_cb = dummy_flush_cb;
|
||||
}
|
||||
/*Measure the time in monitor_cb*/
|
||||
else if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY) {
|
||||
disp->driver->render_start_cb = render_start_cb;
|
||||
disp->driver->monitor_cb = monitor_cb;
|
||||
flush_cb_ori = disp->driver->flush_cb;
|
||||
disp->driver->flush_cb = dummy_flush_cb;
|
||||
lv_disp_add_event(disp, benchmark_event_cb, LV_EVENT_ALL, NULL);
|
||||
flush_cb_ori = disp->flush_cb;
|
||||
disp->flush_cb = dummy_flush_cb;
|
||||
|
||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY) {
|
||||
if(disp->refr_timer) {
|
||||
disp_ori_timer_period = disp->refr_timer->period;
|
||||
lv_timer_set_period(disp->refr_timer, 2);
|
||||
@@ -800,6 +789,28 @@ static void benchmark_init(void)
|
||||
lv_obj_update_layout(scr);
|
||||
}
|
||||
|
||||
static void benchmark_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_RENDER_START) {
|
||||
render_start_time = lv_tick_get();
|
||||
}
|
||||
}
|
||||
|
||||
static void benchmark_event_remove(void)
|
||||
{
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_disp_get_event_count(disp); i++) {
|
||||
lv_event_dsc_t * dsc = lv_disp_get_event_dsc(disp, i);
|
||||
if(lv_event_dsc_get_cb(dsc) == benchmark_event_cb) {
|
||||
lv_disp_remove_event(disp, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void show_scene_report(void)
|
||||
{
|
||||
if(scene_act < 0) return;
|
||||
@@ -874,48 +885,32 @@ static void single_scene_finsih_timer_cb(lv_timer_t * timer)
|
||||
LV_UNUSED(timer);
|
||||
calc_scene_statistics();
|
||||
|
||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY || mode == LV_DEMO_BENCHMARK_MODE_REAL) {
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
disp->driver->flush_cb = flush_cb_ori;
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
disp->flush_cb = flush_cb_ori;
|
||||
|
||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY) {
|
||||
if(disp->refr_timer) {
|
||||
lv_timer_set_period(disp->refr_timer, disp_ori_timer_period);
|
||||
}
|
||||
lv_timer_set_period(lv_anim_get_timer(), anim_ori_timer_period);
|
||||
}
|
||||
|
||||
benchmark_event_remove();
|
||||
show_scene_report();
|
||||
lv_obj_clean(scene_bg);
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
}
|
||||
|
||||
static void monitor_cb(lv_disp_t * drv, uint32_t time, uint32_t px)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
LV_UNUSED(px);
|
||||
|
||||
time = lv_tick_elaps(render_start_time);
|
||||
|
||||
if(scene_with_opa) {
|
||||
scenes[scene_act].refr_cnt_opa ++;
|
||||
scenes[scene_act].time_sum_opa += time;
|
||||
}
|
||||
else {
|
||||
scenes[scene_act].refr_cnt_normal ++;
|
||||
scenes[scene_act].time_sum_normal += time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void render_start_cb(lv_disp_t * drv)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
render_start_time = lv_tick_get();
|
||||
}
|
||||
|
||||
static void dummy_flush_cb(lv_disp_t * drv, const lv_area_t * area, lv_color_t * colors)
|
||||
{
|
||||
LV_UNUSED(area);
|
||||
LV_UNUSED(colors);
|
||||
|
||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER) {
|
||||
bool last = lv_disp_flush_is_last(drv);
|
||||
flush_cb_ori(drv, area, colors);
|
||||
|
||||
/*Measure the time since render start after flushing*/
|
||||
bool last = lv_disp_flush_is_last(drv);
|
||||
if(last) {
|
||||
uint32_t t = lv_tick_elaps(render_start_time);
|
||||
if(scene_with_opa) {
|
||||
@@ -931,6 +926,8 @@ static void dummy_flush_cb(lv_disp_t * drv, const lv_area_t * area, lv_color_t *
|
||||
else if(mode == LV_DEMO_BENCHMARK_MODE_REAL) {
|
||||
bool last = lv_disp_flush_is_last(drv);
|
||||
flush_cb_ori(drv, area, colors);
|
||||
|
||||
/*Measure the time since the previous last flush (full render)*/
|
||||
if(last) {
|
||||
/*Skip the first call as last_flush_cb_call comes from the previous scene */
|
||||
if(last_flush_cb_call != 0) {
|
||||
@@ -948,23 +945,37 @@ static void dummy_flush_cb(lv_disp_t * drv, const lv_area_t * area, lv_color_t *
|
||||
}
|
||||
}
|
||||
else if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY) {
|
||||
/*Just bypass*/
|
||||
/*Just bypass the driver and measure the pure rendering time*/
|
||||
lv_disp_flush_ready(drv);
|
||||
|
||||
bool last = lv_disp_flush_is_last(drv);
|
||||
if(last) {
|
||||
uint32_t t = lv_tick_elaps(render_start_time);
|
||||
if(scene_with_opa) {
|
||||
scenes[scene_act].refr_cnt_opa ++;
|
||||
scenes[scene_act].time_sum_opa += t;
|
||||
}
|
||||
else {
|
||||
scenes[scene_act].refr_cnt_normal ++;
|
||||
scenes[scene_act].time_sum_normal += t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_report(void)
|
||||
{
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
disp->flush_cb = flush_cb_ori;
|
||||
|
||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY) {
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
disp->driver->flush_cb = flush_cb_ori;
|
||||
if(disp->refr_timer) {
|
||||
lv_timer_set_period(disp->refr_timer, disp_ori_timer_period);
|
||||
}
|
||||
lv_timer_set_period(lv_anim_get_timer(), anim_ori_timer_period);
|
||||
}
|
||||
|
||||
benchmark_event_remove();
|
||||
|
||||
uint32_t weight_sum = 0;
|
||||
uint32_t weight_normal_sum = 0;
|
||||
|
||||
Reference in New Issue
Block a user