From eaa25114adfd123aa18e6a6f8988db5df368f9b9 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Tue, 11 Oct 2022 04:00:41 +0300 Subject: [PATCH] bdk: lvgl: do not do unneeded invalidations A bug was fixed that was causing full parent object invalidations when tapping into a window. Now if the object is already on top the invalidation is skipped and the whole rerender/draw is skipped, saving valuable cpu time. --- bdk/libs/lv_conf.h | 9 ++++++--- bdk/libs/lvgl/lv_core/lv_group.c | 4 ++-- bdk/libs/lvgl/lv_core/lv_indev.c | 4 ++-- bdk/libs/lvgl/lv_misc/lv_ll.c | 7 ++++++- bdk/libs/lvgl/lv_misc/lv_ll.h | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bdk/libs/lv_conf.h b/bdk/libs/lv_conf.h index dbf44bd..89dc555 100644 --- a/bdk/libs/lv_conf.h +++ b/bdk/libs/lv_conf.h @@ -147,10 +147,10 @@ #define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/ /*HAL settings*/ -#define LV_TICK_CUSTOM 1 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */ +#define LV_TICK_CUSTOM 1 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */ #if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE /*Header for the sys time function*/ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (get_tmr_ms()) /*Expression evaluating to current systime in ms*/ +#define LV_TICK_CUSTOM_INCLUDE /*Header for the sys time function*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR ((u32)get_tmr_ms()) /*Expression evaluating to current systime in ms*/ #endif /*LV_TICK_CUSTOM*/ @@ -296,6 +296,9 @@ /*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/ #define USE_LV_MBOX 1 +#if USE_LV_MBOX != 0 +# define LV_MBOX_CLOSE_ANIM_TIME 200 /*ms*/ +#endif /*Text area (dependencies: lv_label, lv_page)*/ #define USE_LV_TA 1 diff --git a/bdk/libs/lvgl/lv_core/lv_group.c b/bdk/libs/lvgl/lv_core/lv_group.c index 3fd4120..cedef7f 100644 --- a/bdk/libs/lvgl/lv_core/lv_group.c +++ b/bdk/libs/lvgl/lv_core/lv_group.c @@ -546,8 +546,8 @@ static void obj_to_foreground(lv_obj_t * obj) /*Move the last_top object to the foreground*/ lv_obj_t * par = lv_obj_get_parent(last_top); /*After list change it will be the new head*/ - lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top); - lv_obj_invalidate(last_top); + if (lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top)) + lv_obj_invalidate(last_top); /*Only invalidate if not top*/ } } diff --git a/bdk/libs/lvgl/lv_core/lv_indev.c b/bdk/libs/lvgl/lv_core/lv_indev.c index 763abf7..d1dc582 100644 --- a/bdk/libs/lvgl/lv_core/lv_indev.c +++ b/bdk/libs/lvgl/lv_core/lv_indev.c @@ -646,8 +646,8 @@ static void indev_proc_press(lv_indev_proc_t * proc) /*Move the last_top object to the foreground*/ lv_obj_t * par = lv_obj_get_parent(last_top); /*After list change it will be the new head*/ - lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top); - lv_obj_invalidate(last_top); + if (lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top)) + lv_obj_invalidate(last_top); /*Only invalidate if not top*/ } /*Send a signal about the press*/ diff --git a/bdk/libs/lvgl/lv_misc/lv_ll.c b/bdk/libs/lvgl/lv_misc/lv_ll.c index 43d8847..5583311 100644 --- a/bdk/libs/lvgl/lv_misc/lv_ll.c +++ b/bdk/libs/lvgl/lv_misc/lv_ll.c @@ -215,9 +215,12 @@ void lv_ll_clear(lv_ll_t * ll_p) * @param ll_ori_p pointer to the original (old) linked list * @param ll_new_p pointer to the new linked list * @param node pointer to a node + * @return head changed */ -void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node) +bool lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node) { + bool changed = ll_new_p->head != node; + lv_ll_rem(ll_ori_p, node); /*Set node as head*/ @@ -232,6 +235,8 @@ void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node) if(ll_new_p->tail == NULL) { /*If there is no tail (first node) set the tail too*/ ll_new_p->tail = node; } + + return changed; } /** diff --git a/bdk/libs/lvgl/lv_misc/lv_ll.h b/bdk/libs/lvgl/lv_misc/lv_ll.h index 086ba40..5bde7e5 100644 --- a/bdk/libs/lvgl/lv_misc/lv_ll.h +++ b/bdk/libs/lvgl/lv_misc/lv_ll.h @@ -89,8 +89,9 @@ void lv_ll_clear(lv_ll_t * ll_p); * @param ll_ori_p pointer to the original (old) linked list * @param ll_new_p pointer to the new linked list * @param node pointer to a node + * @return head changed */ -void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node); +bool lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node); /** * Return with head node of the linked list