style invalidation fixes

This commit is contained in:
Gabor Kiss-Vamosi
2020-09-23 18:50:57 +02:00
parent f01bfcb6f6
commit f3085bf191
4 changed files with 54 additions and 36 deletions

View File

@@ -778,6 +778,9 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
} }
} }
if(cmp_res == _LV_STYLE_STATE_CMP_VISUAL_DIFF) {
_lv_obj_invalidate_style_cache(obj, part, LV_STYLE_PROP_ALL);
}
} }
if(cmp_res == _LV_STYLE_STATE_CMP_DIFF) _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); if(cmp_res == _LV_STYLE_STATE_CMP_DIFF) _lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);

View File

@@ -92,7 +92,6 @@ static _lv_style_state_cmp_t style_snapshot_compare(style_snapshot_t * shot1, st
static bool style_prop_is_cacheable(lv_style_property_t prop); static bool style_prop_is_cacheable(lv_style_property_t prop);
static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop); static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop);
static void update_style_cache_children(lv_obj_t * obj); static void update_style_cache_children(lv_obj_t * obj);
static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
#endif #endif
static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v); static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v);
static void fade_in_anim_ready(lv_anim_t * a); static void fade_in_anim_ready(lv_anim_t * a);
@@ -307,6 +306,44 @@ void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis)
} }
#if LV_STYLE_CACHE_LEVEL > 0
/**
* Mark the object and all of it's children's style lists as invalid.
* The cache will be updated when a cached property asked nest time
* @param obj pointer to an object
*/
void _lv_obj_invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
if(style_prop_is_cacheable(prop) == false) return;
if(part != LV_OBJ_PART_ALL) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) return;
list->valid_cache = 0;
}
else {
for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) break;
list->valid_cache = 0;
}
for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) break;
list->valid_cache = 0;
}
}
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child) {
update_style_cache_children(child);
child = lv_obj_get_child(obj, child);
}
}
#endif /*LV_STYLE_CACHE_LEVEL >= 1*/
/** /**
* Get a style property of a part of an object in the object's current state. * Get a style property of a part of an object in the object's current state.
* If there is a running transitions it is taken into account * If there is a running transitions it is taken into account
@@ -798,7 +835,7 @@ void _lv_obj_refresh_style(lv_obj_t * obj, uint8_t part, lv_style_property_t pro
{ {
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
#if LV_STYLE_CACHE_LEVEL >= 1 #if LV_STYLE_CACHE_LEVEL >= 1
invalidate_style_cache(obj, part, prop); _lv_obj_invalidate_style_cache(obj, part, prop);
#endif #endif
/*If a real style refresh is required*/ /*If a real style refresh is required*/
@@ -1481,40 +1518,6 @@ static void update_style_cache_children(lv_obj_t * obj)
} }
/**
* Mark the object and all of it's children's style lists as invalid.
* The cache will be updated when a cached property asked nest time
* @param obj pointer to an object
*/
static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
if(style_prop_is_cacheable(prop) == false) return;
if(part != LV_OBJ_PART_ALL) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) return;
list->valid_cache = 0;
}
else {
for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) break;
list->valid_cache = 0;
}
for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) {
lv_style_list_t * list = _lv_obj_get_style_list(obj, part);
if(list == NULL) break;
list->valid_cache = 0;
}
}
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child) {
update_style_cache_children(child);
child = lv_obj_get_child(obj, child);
}
}
#endif /*LV_STYLE_CACHE_LEVEL >= 1*/ #endif /*LV_STYLE_CACHE_LEVEL >= 1*/

View File

@@ -127,6 +127,17 @@ lv_style_list_t * _lv_obj_get_style_list(const lv_obj_t * obj, uint8_t part);
*/ */
void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis); void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis);
#if LV_STYLE_CACHE_LEVEL > 0
/**
* Mark the object and all of it's children's style lists as invalid.
* The cache will be updated when a cached property asked nest time
* @param obj pointer to an object
*/
void _lv_obj_invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
#endif
/** /**
* Get a style property of a part of an object in the object's current state. * Get a style property of a part of an object in the object's current state.
* If there is a running transitions it is taken into account * If there is a running transitions it is taken into account

View File

@@ -78,6 +78,7 @@ lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy)
lv_label_set_text_static(cb, "Check box"); lv_label_set_text_static(cb, "Check box");
lv_theme_apply(cb, LV_THEME_CHECKBOX); lv_theme_apply(cb, LV_THEME_CHECKBOX);
lv_obj_add_flag(cb, LV_OBJ_FLAG_CLICKABLE); lv_obj_add_flag(cb, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_flag(cb, LV_OBJ_FLAG_CHECKABLE);
} }
else { else {