mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-30 23:51:54 +08:00
fix(benchmark): follow API changes
This commit is contained in:
@@ -3,11 +3,11 @@
|
|||||||
#if LV_USE_DEMO_BENCHMARK
|
#if LV_USE_DEMO_BENCHMARK
|
||||||
|
|
||||||
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LV_ATTRIBUTE_IMG_IMG_COGWHEEL_INDEXED16
|
#ifndef LV_ATTRIBUTE_IMG_IMG_COGWHEEL_INDEXED16
|
||||||
#define LV_ATTRIBUTE_IMG_IMG_COGWHEEL_INDEXED16
|
#define LV_ATTRIBUTE_IMG_IMG_COGWHEEL_INDEXED16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_IMG_COGWHEEL_INDEXED16 uint8_t img_benchmark_cogwheel_indexed16_map[] = {
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_IMG_COGWHEEL_INDEXED16 uint8_t img_benchmark_cogwheel_indexed16_map[] = {
|
||||||
@@ -135,7 +135,7 @@ const lv_img_dsc_t img_benchmark_cogwheel_indexed16 = {
|
|||||||
.header.w = 100,
|
.header.w = 100,
|
||||||
.header.h = 100,
|
.header.h = 100,
|
||||||
.data_size = 5064,
|
.data_size = 5064,
|
||||||
.header.cf = LV_IMG_CF_INDEXED_4BIT,
|
.header.cf = LV_COLOR_FORMAT_I4,
|
||||||
.data = img_benchmark_cogwheel_indexed16_map,
|
.data = img_benchmark_cogwheel_indexed16_map,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -94,13 +94,14 @@ LV_IMG_DECLARE(img_benchmark_cogwheel_alpha256);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void benchmark_init(void);
|
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 show_scene_report(void);
|
||||||
static void calc_scene_statistics(void);
|
static void calc_scene_statistics(void);
|
||||||
static lv_res_t load_next_scene(void);
|
static lv_res_t load_next_scene(void);
|
||||||
static void next_scene_timer_cb(lv_timer_t * timer);
|
static void next_scene_timer_cb(lv_timer_t * timer);
|
||||||
static void single_scene_finsih_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 dummy_flush_cb(lv_disp_t * drv, const lv_area_t * area, lv_color_t * colors);
|
||||||
static void generate_report(void);
|
static void generate_report(void);
|
||||||
|
|
||||||
@@ -751,23 +752,11 @@ static void benchmark_init(void)
|
|||||||
{
|
{
|
||||||
lv_disp_t * disp = lv_disp_get_default();
|
lv_disp_t * disp = lv_disp_get_default();
|
||||||
|
|
||||||
/*Measure the time from render start to last flush_cb call*/
|
lv_disp_add_event(disp, benchmark_event_cb, LV_EVENT_ALL, NULL);
|
||||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER) {
|
flush_cb_ori = disp->flush_cb;
|
||||||
disp->driver->render_start_cb = render_start_cb;
|
disp->flush_cb = dummy_flush_cb;
|
||||||
flush_cb_ori = disp->driver->flush_cb;
|
|
||||||
disp->driver->flush_cb = dummy_flush_cb;
|
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_ONLY) {
|
||||||
}
|
|
||||||
/*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;
|
|
||||||
if(disp->refr_timer) {
|
if(disp->refr_timer) {
|
||||||
disp_ori_timer_period = disp->refr_timer->period;
|
disp_ori_timer_period = disp->refr_timer->period;
|
||||||
lv_timer_set_period(disp->refr_timer, 2);
|
lv_timer_set_period(disp->refr_timer, 2);
|
||||||
@@ -800,6 +789,28 @@ static void benchmark_init(void)
|
|||||||
lv_obj_update_layout(scr);
|
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)
|
static void show_scene_report(void)
|
||||||
{
|
{
|
||||||
if(scene_act < 0) return;
|
if(scene_act < 0) return;
|
||||||
@@ -874,48 +885,32 @@ static void single_scene_finsih_timer_cb(lv_timer_t * timer)
|
|||||||
LV_UNUSED(timer);
|
LV_UNUSED(timer);
|
||||||
calc_scene_statistics();
|
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();
|
lv_disp_t * disp = lv_disp_get_default();
|
||||||
disp->driver->flush_cb = flush_cb_ori;
|
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();
|
show_scene_report();
|
||||||
lv_obj_clean(scene_bg);
|
lv_obj_clean(scene_bg);
|
||||||
lv_obj_invalidate(lv_scr_act());
|
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)
|
static void dummy_flush_cb(lv_disp_t * drv, const lv_area_t * area, lv_color_t * colors)
|
||||||
{
|
{
|
||||||
LV_UNUSED(area);
|
LV_UNUSED(area);
|
||||||
LV_UNUSED(colors);
|
LV_UNUSED(colors);
|
||||||
|
|
||||||
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER) {
|
if(mode == LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER) {
|
||||||
bool last = lv_disp_flush_is_last(drv);
|
|
||||||
flush_cb_ori(drv, area, colors);
|
flush_cb_ori(drv, area, colors);
|
||||||
|
|
||||||
|
/*Measure the time since render start after flushing*/
|
||||||
|
bool last = lv_disp_flush_is_last(drv);
|
||||||
if(last) {
|
if(last) {
|
||||||
uint32_t t = lv_tick_elaps(render_start_time);
|
uint32_t t = lv_tick_elaps(render_start_time);
|
||||||
if(scene_with_opa) {
|
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) {
|
else if(mode == LV_DEMO_BENCHMARK_MODE_REAL) {
|
||||||
bool last = lv_disp_flush_is_last(drv);
|
bool last = lv_disp_flush_is_last(drv);
|
||||||
flush_cb_ori(drv, area, colors);
|
flush_cb_ori(drv, area, colors);
|
||||||
|
|
||||||
|
/*Measure the time since the previous last flush (full render)*/
|
||||||
if(last) {
|
if(last) {
|
||||||
/*Skip the first call as last_flush_cb_call comes from the previous scene */
|
/*Skip the first call as last_flush_cb_call comes from the previous scene */
|
||||||
if(last_flush_cb_call != 0) {
|
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) {
|
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);
|
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)
|
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) {
|
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) {
|
if(disp->refr_timer) {
|
||||||
lv_timer_set_period(disp->refr_timer, disp_ori_timer_period);
|
lv_timer_set_period(disp->refr_timer, disp_ori_timer_period);
|
||||||
}
|
}
|
||||||
lv_timer_set_period(lv_anim_get_timer(), anim_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_sum = 0;
|
||||||
uint32_t weight_normal_sum = 0;
|
uint32_t weight_normal_sum = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user