1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

reimplement style caching

This commit is contained in:
Gabor Kiss-Vamosi 2020-01-08 21:31:05 +01:00
parent 02f4dd764f
commit 1b94cf6851
13 changed files with 561 additions and 584 deletions

View File

@ -53,9 +53,7 @@ typedef struct _lv_event_temp_data
**********************/
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
static void refresh_children_style_cache(lv_obj_t * obj);
static void refresh_children_style(lv_obj_t * obj);
static lv_res_t style_cache_update_core(lv_obj_t * obj, uint8_t part);
static void delete_children(lv_obj_t * obj);
static void base_dir_refr_children(lv_obj_t * obj);
static void lv_event_mark_deleted(lv_obj_t * obj);
@ -162,7 +160,6 @@ void lv_deinit(void)
*/
lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
{
lv_obj_t * new_obj = NULL;
/*Create a screen*/
@ -178,6 +175,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
memset(new_obj, 0x00, sizeof(lv_obj_t));
/*Set coordinates to full screen size*/
new_obj->coords.x1 = 0;
new_obj->coords.y1 = 0;
@ -194,6 +193,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
memset(new_obj, 0x00, sizeof(lv_obj_t));
new_obj->coords.y1 = parent->coords.y1;
new_obj->coords.y2 = parent->coords.y1 + LV_OBJ_DEF_HEIGHT;
if(lv_obj_get_base_dir(new_obj) == LV_BIDI_DIR_RTL) {
@ -205,7 +206,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
}
}
new_obj->par = parent;
new_obj->parent = parent;
lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
@ -218,9 +219,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
memset(&new_obj->ext_click_pad, 0, sizeof(new_obj->ext_click_pad));
#endif
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
new_obj->ext_click_pad_hor = 0;
new_obj->ext_click_pad_ver = 0;
#endif
@ -255,6 +254,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->top = 0;
new_obj->protect = LV_PROTECT_NONE;
new_obj->parent_event = 0;
new_obj->state = 0;
#if LV_USE_BIDI
if(parent == NULL) new_obj->base_dir = LV_BIDI_BASE_DIR_DEF;
@ -265,6 +265,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->ext_attr = NULL;
lv_style_dsc_init(&new_obj->style_dsc);
if(parent != NULL) {
@ -280,17 +281,16 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
lv_area_copy(&new_obj->ext_click_pad, &copy->ext_click_pad);
#endif
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
new_obj->ext_click_pad_hor = copy->ext_click_pad_hor;
new_obj->ext_click_pad_ver = copy->ext_click_pad_ver;
#endif
/*Set free data*/
/*Set user data*/
#if LV_USE_USER_DATA
memcpy(&new_obj->user_data, &copy->user_data, sizeof(lv_obj_user_data_t));
#endif
/*Copy realign*/
#if LV_USE_OBJ_REALIGN
new_obj->realign.align = copy->realign.align;
@ -517,7 +517,7 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
LV_ASSERT_OBJ(parent, LV_OBJX_NAME);
if(obj->par == NULL) {
if(obj->parent == NULL) {
LV_LOG_WARN("Can't set the parent of a screen");
return;
}
@ -529,7 +529,7 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
lv_obj_invalidate(obj);
lv_obj_t * old_par = obj->par;
lv_obj_t * old_par = obj->parent;
lv_point_t old_pos;
old_pos.y = lv_obj_get_y(obj);
@ -541,8 +541,8 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
old_pos.x = old_par->coords.x2 - obj->coords.x2;
}
lv_ll_chg_list(&obj->par->child_ll, &parent->child_ll, obj, true);
obj->par = parent;
lv_ll_chg_list(&obj->parent->child_ll, &parent->child_ll, obj, true);
obj->parent = parent;
if(new_base_dir != LV_BIDI_DIR_RTL) {
@ -623,7 +623,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
/*Convert x and y to absolute coordinates*/
lv_obj_t * par = obj->par;
lv_obj_t * par = obj->parent;
x = x + par->coords.x1;
y = y + par->coords.y1;
@ -1230,8 +1230,8 @@ void lv_obj_refresh_style(lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
/*Re-cache all children's styles first*/
refresh_children_style_cache(obj);
// /*Re-cache all children's styles first*/
// lv_obj_update_style_cache(obj);
/*Send style change signals*/
refresh_children_style(obj);
@ -1527,8 +1527,8 @@ lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t
}
if(obj) {
if(obj->parent_event && obj->par) {
lv_res_t res = lv_event_send(obj->par, event, data);
if(obj->parent_event && obj->parent) {
lv_res_t res = lv_event_send(obj->parent, event, data);
if(res != LV_RES_OK) {
return LV_RES_INV;
}
@ -1659,7 +1659,7 @@ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
const lv_obj_t * scr;
if(obj->par == NULL)
if(obj->parent == NULL)
scr = obj; /*`obj` is a screen*/
else
scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/
@ -1691,7 +1691,7 @@ lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->par;
return obj->parent;
}
/**
@ -2032,107 +2032,6 @@ lv_style_dsc_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t part)
lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_dsc_t * dsc = lv_obj_get_style(obj, part);
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_PAD_LEFT:
if(dsc->cache.pad_left != LV_STYLE_CACHE_PAD_SKIPPED) {
return dsc->cache.pad_left;
}
break;
case LV_STYLE_PAD_RIGHT:
if(dsc->cache.pad_right != LV_STYLE_CACHE_PAD_SKIPPED) {
return dsc->cache.pad_right;
}
break;
case LV_STYLE_PAD_TOP:
if(dsc->cache.pad_top != LV_STYLE_CACHE_PAD_SKIPPED) {
return dsc->cache.pad_top;
}
break;
case LV_STYLE_PAD_BOTTOM:
if(dsc->cache.pad_bottom != LV_STYLE_CACHE_PAD_SKIPPED) {
return dsc->cache.pad_bottom;
}
break;
case LV_STYLE_PAD_INNER:
if(dsc->cache.pad_inner!= LV_STYLE_CACHE_PAD_SKIPPED) {
return dsc->cache.pad_inner;
}
break;
case LV_STYLE_BG_GRAD_DIR:
return dsc->cache.bg_grad_dir;
break;
case LV_STYLE_BORDER_WIDTH:
if(dsc->cache.border_width != LV_STYLE_CACHE_WIDTH_SKIPPED) {
return dsc->cache.border_width;
}
break;
case LV_STYLE_LINE_WIDTH:
if(dsc->cache.line_width != LV_STYLE_CACHE_WIDTH_SKIPPED) {
return dsc->cache.line_width;
}
break;
case LV_STYLE_LETTER_SPACE:
if(dsc->cache.letter_space != LV_STYLE_CACHE_WIDTH_SKIPPED) {
return dsc->cache.letter_space;
}
break;
case LV_STYLE_LINE_SPACE:
if(dsc->cache.line_space != LV_STYLE_CACHE_WIDTH_SKIPPED) {
return dsc->cache.line_space;
}
break;
case LV_STYLE_SHADOW_WIDTH:
if(dsc->cache.shadow_width == 0) {
return 0;
}
break;
case LV_STYLE_BG_BLEND_MODE:
if(dsc->cache.bg_blend_mode == LV_STYLE_CACHE_BLEND_MODE_NORMAL) {
return LV_BLEND_MODE_NORMAL;
}
break;
case LV_STYLE_BORDER_BLEND_MODE:
if(dsc->cache.border_blend_mode == LV_STYLE_CACHE_BLEND_MODE_NORMAL) {
return LV_BLEND_MODE_NORMAL;
}
break;
case LV_STYLE_TEXT_BLEND_MODE:
if(dsc->cache.text_blend_mode == LV_STYLE_CACHE_BLEND_MODE_NORMAL) {
return LV_BLEND_MODE_NORMAL;
}
break;
case LV_STYLE_LINE_BLEND_MODE:
if(dsc->cache.line_blend_mode == LV_STYLE_CACHE_BLEND_MODE_NORMAL) {
return LV_BLEND_MODE_NORMAL;
}
break;
case LV_STYLE_IMAGE_BLEND_MODE:
if(dsc->cache.image_blend_mode == LV_STYLE_CACHE_BLEND_MODE_NORMAL) {
return LV_BLEND_MODE_NORMAL;
}
break;
case LV_STYLE_SHADOW_BLEND_MODE:
if(dsc->cache.shadow_blend_mode == LV_STYLE_CACHE_BLEND_MODE_NORMAL) {
return LV_BLEND_MODE_NORMAL;
}
break;
case LV_STYLE_RADIUS:
if(dsc->cache.radius != LV_STYLE_CACHE_RADIUS_SKIPPED) {
return dsc->cache.radius == LV_STYLE_CACHE_RADIUS_CIRCLE ? LV_RADIUS_CIRCLE : dsc->cache.radius;
}
break;
case LV_STYLE_CLIP_CORNER:
return dsc->cache.clip_corner;
break;
case LV_STYLE_BORDER_PART:
if(dsc->cache.border_part == LV_STYLE_CACHE_BORDER_PART_FULL) return LV_BORDER_SIDE_FULL;
break;
}
}
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
@ -2140,44 +2039,16 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style
int16_t weight = -1;
lv_style_int_t value;
lv_res_t res = LV_RES_INV;
const lv_obj_t * parent = obj;
while(parent) {
lv_style_dsc_t * dsc = lv_obj_get_style(parent, part);
if(dsc == NULL) continue;
uint8_t state = lv_obj_get_state(parent, part);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_goal = state;
int16_t weight_act;
lv_style_int_t value_act;
weight_act = lv_style_get_int(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_int(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
}
res = lv_style_dsc_get_int(dsc, prop, &value);
if(res == LV_RES_OK) return value;
if(attr.bits.inherit == 0) break;
@ -2191,9 +2062,6 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style
parent = lv_obj_get_parent(parent);
}
if(weight >= 0) return value;
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_BORDER_PART:
@ -2214,46 +2082,17 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight = -1;
lv_color_t value;
lv_res_t res = LV_RES_INV;
const lv_obj_t * parent = obj;
while(parent) {
lv_style_dsc_t * dsc = lv_obj_get_style(parent, part);
if(dsc == NULL) continue;
uint8_t state = lv_obj_get_state(parent, part);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_goal = state;
int16_t weight_act;
lv_color_t value_act;
weight_act = lv_style_get_color(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_color(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
}
res = lv_style_dsc_get_color(dsc, prop, &value);
if(res == LV_RES_OK) return value;
if(attr.bits.inherit == 0) break;
@ -2267,8 +2106,6 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
parent = lv_obj_get_parent(parent);
}
if(weight >= 0) return value;
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
@ -2285,91 +2122,22 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_dsc_t * dsc = lv_obj_get_style(obj, part);
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_BG_OPA:
if(dsc->cache.bg_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.bg_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_BORDER_OPA:
if(dsc->cache.border_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.border_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_TEXT_OPA:
if(dsc->cache.text_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.text_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_SHADOW_OPA:
if(dsc->cache.shadow_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.shadow_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_LINE_OPA:
if(dsc->cache.line_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.line_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_IMAGE_OPA:
if(dsc->cache.image_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.image_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_OVERLAY_OPA:
if(dsc->cache.overlay_opa == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.overlay_opa == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
case LV_STYLE_OPA_SCALE:
if(dsc->cache.opa_scale == LV_STYLE_CACHE_OPA_COVER) return LV_OPA_COVER;
if(dsc->cache.opa_scale == LV_STYLE_CACHE_OPA_TRANSP) return LV_OPA_TRANSP;
break;
}
}
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight = -1;
lv_opa_t value;
lv_res_t res = LV_RES_INV;
const lv_obj_t * parent = obj;
while(parent) {
lv_style_dsc_t * dsc = lv_obj_get_style(parent, part);
if(dsc == NULL) continue;
uint8_t state = lv_obj_get_state(parent, part);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_goal = state;
int16_t weight_act;
lv_opa_t value_act;
weight_act = lv_style_get_opa(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_opa(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
}
res = lv_style_dsc_get_opa(dsc, prop, &value);
if(res == LV_RES_OK) return value;
if(attr.bits.inherit == 0) break;
@ -2383,9 +2151,6 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prope
parent = lv_obj_get_parent(parent);
}
if(weight >= 0) return value;
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_OVERLAY_OPA:
@ -2400,59 +2165,22 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prope
void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_dsc_t * dsc = lv_obj_get_style(obj, part);
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_FONT:
if(dsc->cache.font == LV_STYLE_CACHE_FONT_DEFAULT) return LV_FONT_DEFAULT;
break;
}
}
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight = -1;
void * value;
lv_res_t res = LV_RES_INV;
const lv_obj_t * parent = obj;
while(parent) {
lv_style_dsc_t * dsc = lv_obj_get_style(parent, part);
if(dsc == NULL) continue;
uint8_t state = lv_obj_get_state(parent, part);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_goal = state;
int16_t weight_act;
void * value_act;
weight_act = lv_style_get_ptr(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_ptr(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal && weight_act > weight) {
return value_act;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
value = value_act;
}
}
res = lv_style_dsc_get_ptr(dsc, prop, &value);
if(res == LV_RES_OK) return value;
if(attr.bits.inherit == 0) break;
@ -2466,7 +2194,6 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
parent = lv_obj_get_parent(parent);
}
if(weight >= 0) return value;
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
@ -2482,9 +2209,15 @@ void lv_obj_update_style_cache(lv_obj_t * obj)
{
uint8_t part_sub;
for(part_sub = 0; part_sub != _LV_OBJ_PART_ALL; part_sub++) {
for(part_sub = 0; part_sub != _LV_OBJ_PART_REAL_LAST; part_sub++) {
lv_res_t res;
res = style_cache_update_core(obj, part_sub);
res = lv_style_cache_update(lv_obj_get_style(obj, part_sub));
if(res == LV_RES_INV) break;
}
for(part_sub = _LV_OBJ_PART_REAL_LAST; part_sub != _LV_OBJ_PART_ALL; part_sub++) {
lv_res_t res;
res = lv_style_cache_update(lv_obj_get_style(obj, part_sub));
if(res == LV_RES_INV) break;
}
}
@ -2927,6 +2660,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
if(draw_dsc->bg_grad_dir != LV_GRAD_DIR_NONE) {
draw_dsc->bg_grad_color = lv_obj_get_style_color(obj, part, LV_STYLE_BG_GRAD_COLOR);
}
draw_dsc->bg_blend_mode = lv_obj_get_style_int(obj, part, LV_STYLE_BG_BLEND_MODE);
}
draw_dsc->border_width = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_WIDTH);
@ -2936,6 +2670,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->border_part = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_PART);
draw_dsc->border_color = lv_obj_get_style_color(obj, part, LV_STYLE_BORDER_COLOR);
}
draw_dsc->bg_blend_mode = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_BLEND_MODE);
}
draw_dsc->pattern_src = lv_obj_get_style_ptr(obj, part, LV_STYLE_PATTERN_IMAGE);
@ -2943,17 +2678,20 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->pattern_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_PATTERN_OPA);
if(draw_dsc->pattern_opa > LV_OPA_MIN) {
draw_dsc->pattern_repeate = lv_obj_get_style_int(obj, part, LV_STYLE_PATTERN_REPEATE) & 0x1U;
draw_dsc->pattern_recolor = lv_obj_get_style_color(obj, part, LV_STYLE_PATTERN_RECOLOR);
draw_dsc->pattern_recolor_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_PATTERN_RECOLOR_OPA);
if(lv_img_src_get_type(draw_dsc->pattern_src) == LV_IMG_SRC_SYMBOL) {
draw_dsc->pattern_recolor = lv_obj_get_style_color(obj, part, LV_STYLE_PATTERN_RECOLOR);
draw_dsc->pattern_font = lv_obj_get_style_ptr(obj, part, LV_STYLE_FONT);
} else if(draw_dsc->pattern_recolor_opa > LV_OPA_MIN ) {
draw_dsc->pattern_recolor = lv_obj_get_style_color(obj, part, LV_STYLE_PATTERN_RECOLOR);
}
}
}
draw_dsc->overlay_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_OVERLAY_OPA);
draw_dsc->overlay_color = lv_obj_get_style_color(obj, part, LV_STYLE_OVERLAY_COLOR);
if(draw_dsc->overlay_opa > LV_OPA_MIN) {
draw_dsc->overlay_color = lv_obj_get_style_color(obj, part, LV_STYLE_OVERLAY_COLOR);
}
draw_dsc->shadow_width = lv_obj_get_style_int(obj, part, LV_STYLE_SHADOW_WIDTH);
if(draw_dsc->shadow_width) {
draw_dsc->shadow_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_SHADOW_OPA);
@ -3015,7 +2753,9 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t *
draw_dsc->recolor = lv_obj_get_style_color(obj, part, LV_STYLE_IMAGE_RECOLOR);
draw_dsc->overlay_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_OVERLAY_OPA);
draw_dsc->overlay_color = lv_obj_get_style_color(obj, part, LV_STYLE_OVERLAY_COLOR);
if(draw_dsc->overlay_opa > LV_OPA_MIN) {
draw_dsc->overlay_color = lv_obj_get_style_color(obj, part, LV_STYLE_OVERLAY_COLOR);
}
draw_dsc->blend_mode = lv_obj_get_style_int(obj, part, LV_STYLE_IMAGE_BLEND_MODE);
}
@ -3200,18 +2940,6 @@ static void report_style_mod_core(void * style, lv_obj_t * obj)
static void refresh_children_style_cache(lv_obj_t * obj)
{
lv_obj_update_style_cache(obj);
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child != NULL) {
lv_obj_update_style_cache(child);
child = lv_obj_get_child(obj, child);
}
}
/**
* Recursively refresh the style of the children. Go deeper until a not NULL style is found
* because the NULL styles are inherited from the parent
@ -3235,158 +2963,6 @@ static void refresh_children_style(lv_obj_t * obj)
}
}
static lv_res_t style_cache_update_core(lv_obj_t * obj, uint8_t part)
{
lv_style_dsc_t * dsc = lv_obj_get_style(obj, part);
if(dsc == NULL) return LV_RES_INV;
if(!dsc->cache.enabled) return LV_RES_OK;
dsc->cache.enabled = 0;
lv_style_int_t value;
lv_opa_t opa;
const void * ptr;
value = lv_obj_get_style_int(obj, part, LV_STYLE_LETTER_SPACE);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.letter_space = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_PAD_LEFT);
if(value >= LV_STYLE_CACHE_PAD_SKIPPED || value < 0) value = LV_STYLE_CACHE_PAD_SKIPPED;
dsc->cache.pad_left = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_PAD_RIGHT);
if(value >= LV_STYLE_CACHE_PAD_SKIPPED || value < 0) value = LV_STYLE_CACHE_PAD_SKIPPED;
dsc->cache.pad_right= value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_PAD_TOP);
if(value >= LV_STYLE_CACHE_PAD_SKIPPED || value < 0) value = LV_STYLE_CACHE_PAD_SKIPPED;
dsc->cache.pad_top= value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_PAD_BOTTOM);
if(value >= LV_STYLE_CACHE_PAD_SKIPPED || value < 0) value = LV_STYLE_CACHE_PAD_SKIPPED;
dsc->cache.pad_bottom = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_PAD_INNER);
if(value >= LV_STYLE_CACHE_PAD_SKIPPED || value < 0) value = LV_STYLE_CACHE_PAD_SKIPPED;
dsc->cache.pad_inner = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_BG_GRAD_DIR);
dsc->cache.bg_grad_dir = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_WIDTH);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.border_width = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_LINE_WIDTH);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.line_width = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_LETTER_SPACE);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.letter_space = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_LINE_SPACE);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.line_space = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_SHADOW_WIDTH);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.shadow_width = value;
value = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_WIDTH);
if(value >= LV_STYLE_CACHE_WIDTH_SKIPPED || value < 0) value = LV_STYLE_CACHE_WIDTH_SKIPPED;
dsc->cache.border_width = value;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_BG_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.bg_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.bg_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.bg_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_BORDER_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.border_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.border_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.border_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_TEXT_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.text_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.text_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.text_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_IMAGE_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.image_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.image_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.image_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_LINE_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.line_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.line_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.line_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_SHADOW_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.shadow_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.shadow_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.shadow_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_OVERLAY_OPA);
if(opa >= LV_OPA_MAX) dsc->cache.overlay_opa = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.overlay_opa = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.overlay_opa = LV_STYLE_CACHE_OPA_SKIPPED;
opa = lv_obj_get_style_opa(obj, part, LV_STYLE_OPA_SCALE);
if(opa >= LV_OPA_MAX) dsc->cache.opa_scale = LV_STYLE_CACHE_OPA_COVER;
else if(opa <= LV_OPA_MIN) dsc->cache.opa_scale = LV_STYLE_CACHE_OPA_TRANSP;
else dsc->cache.opa_scale = LV_STYLE_CACHE_OPA_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_BG_BLEND_MODE);
if(value == LV_BLEND_MODE_NORMAL) dsc->cache.bg_blend_mode = LV_STYLE_CACHE_BLEND_MODE_NORMAL;
else dsc->cache.bg_blend_mode = LV_STYLE_CACHE_BLEND_MODE_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_BLEND_MODE);
if(value == LV_BLEND_MODE_NORMAL) dsc->cache.border_blend_mode = LV_STYLE_CACHE_BLEND_MODE_NORMAL;
else dsc->cache.border_blend_mode = LV_STYLE_CACHE_BLEND_MODE_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_TEXT_BLEND_MODE);
if(value == LV_BLEND_MODE_NORMAL) dsc->cache.text_blend_mode = LV_STYLE_CACHE_BLEND_MODE_NORMAL;
else dsc->cache.text_blend_mode = LV_STYLE_CACHE_BLEND_MODE_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_LINE_BLEND_MODE);
if(value == LV_BLEND_MODE_NORMAL) dsc->cache.line_blend_mode = LV_STYLE_CACHE_BLEND_MODE_NORMAL;
else dsc->cache.line_blend_mode = LV_STYLE_CACHE_BLEND_MODE_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_IMAGE_BLEND_MODE);
if(value == LV_BLEND_MODE_NORMAL) dsc->cache.image_blend_mode = LV_STYLE_CACHE_BLEND_MODE_NORMAL;
else dsc->cache.image_blend_mode = LV_STYLE_CACHE_BLEND_MODE_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_SHADOW_BLEND_MODE);
if(value == LV_BLEND_MODE_NORMAL) dsc->cache.shadow_blend_mode = LV_STYLE_CACHE_BLEND_MODE_NORMAL;
else dsc->cache.shadow_blend_mode = LV_STYLE_CACHE_BLEND_MODE_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_RADIUS);
if(value == LV_RADIUS_CIRCLE) dsc->cache.radius = LV_STYLE_CACHE_RADIUS_CIRCLE;
else if(value < LV_STYLE_CACHE_RADIUS_SKIPPED) dsc->cache.radius = value;
else dsc->cache.radius = LV_STYLE_CACHE_RADIUS_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_PART);
if(value == LV_BORDER_SIDE_FULL) dsc->cache.border_part = LV_STYLE_CACHE_BORDER_PART_FULL;
else dsc->cache.border_part = LV_STYLE_CACHE_BORDER_PART_SKIPPED;
ptr = lv_obj_get_style_ptr(obj, part, LV_STYLE_FONT);
if(ptr == LV_FONT_DEFAULT) dsc->cache.font = LV_STYLE_CACHE_FONT_DEFAULT;
else dsc->cache.font = LV_STYLE_CACHE_FONT_SKIPPED;
value = lv_obj_get_style_int(obj, part, LV_STYLE_CLIP_CORNER);
dsc->cache.clip_corner = value;
dsc->cache.enabled = 1;
return LV_RES_OK;
}
/**
* Called by 'lv_obj_del' to delete the children objects
* @param obj pointer to an object (all of its children will be deleted)

View File

@ -213,7 +213,7 @@ typedef uint8_t lv_obj_state_t;
typedef struct _lv_obj_t
{
struct _lv_obj_t * par; /**< Pointer to the parent object*/
struct _lv_obj_t * parent; /**< Pointer to the parent object*/
lv_ll_t child_ll; /**< Linked list to store the children objects*/
lv_area_t coords; /**< Coordinates of the object (x1, y1, x2, y2)*/

View File

@ -91,63 +91,67 @@ void lv_style_dsc_init(lv_style_dsc_t * style_dsc)
lv_style_init(&style_dsc->local);
style_dsc->classes = NULL;
style_dsc->class_cnt = 0;
memset(&style_dsc->cache, 0x00, sizeof(lv_style_cache_t));
memset(&style_dsc->cache, 0xff, sizeof(lv_style_cache_t));
style_dsc->cache.enabled = 1;
}
void lv_style_dsc_add_class(lv_style_dsc_t * style_dsc, lv_style_t * class)
void lv_style_dsc_add_class(lv_style_dsc_t * dsc, lv_style_t * class)
{
/* Do not allocate memory for the first class.
* It can be simply stored as a pointer.*/
if(style_dsc->class_cnt == 0) {
style_dsc->classes = (lv_style_t**)class;
style_dsc->class_cnt = 1;
if(dsc->class_cnt == 0) {
dsc->classes = (lv_style_t**)class;
dsc->class_cnt = 1;
} else {
lv_style_t ** new_classes;
if(style_dsc->class_cnt == 1) new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (style_dsc->class_cnt + 1));
else new_classes = lv_mem_realloc(style_dsc->classes, sizeof(lv_style_t *) * (style_dsc->class_cnt + 1));
if(dsc->class_cnt == 1) new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (dsc->class_cnt + 1));
else new_classes = lv_mem_realloc(dsc->classes, sizeof(lv_style_t *) * (dsc->class_cnt + 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_dsc_add_class: couldn't add the class");
return;
}
if(style_dsc->class_cnt == 1) new_classes[0] = (lv_style_t*)style_dsc->classes;
new_classes[style_dsc->class_cnt] = class;
if(dsc->class_cnt == 1) new_classes[0] = (lv_style_t*)dsc->classes;
new_classes[dsc->class_cnt] = class;
style_dsc->class_cnt++;
style_dsc->classes = new_classes;
dsc->class_cnt++;
dsc->classes = new_classes;
}
lv_style_cache_update(dsc);
}
void lv_style_dsc_remove_class(lv_style_dsc_t * style_dsc, lv_style_t * class)
void lv_style_dsc_remove_class(lv_style_dsc_t * dsc, lv_style_t * class)
{
if(style_dsc->class_cnt == 0) return;
if(style_dsc->class_cnt == 1) {
if((lv_style_t*)style_dsc->classes == class) {
style_dsc->classes = NULL;
style_dsc->class_cnt = 0;
if(dsc->class_cnt == 0) return;
if(dsc->class_cnt == 1) {
if((lv_style_t*)dsc->classes == class) {
dsc->classes = NULL;
dsc->class_cnt = 0;
}
} else {
lv_style_t ** new_classes = lv_mem_realloc(style_dsc->classes, sizeof(lv_style_t *) * (style_dsc->class_cnt - 1));
lv_style_t ** new_classes = lv_mem_realloc(dsc->classes, sizeof(lv_style_t *) * (dsc->class_cnt - 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_dsc_remove_class: couldn't remove the class");
return;
}
uint8_t i,j;
for(i = 0, j = 0; i < style_dsc->class_cnt; i++) {
if(style_dsc->classes[i] == class) continue;
new_classes[j] = style_dsc->classes[i];
for(i = 0, j = 0; i < dsc->class_cnt; i++) {
if(dsc->classes[i] == class) continue;
new_classes[j] = dsc->classes[i];
j++;
}
style_dsc->class_cnt--;
style_dsc->classes = new_classes;
dsc->class_cnt--;
dsc->classes = new_classes;
}
lv_style_cache_update(dsc);
}
void lv_style_dsc_reset(lv_style_dsc_t * style_dsc)
@ -156,6 +160,7 @@ void lv_style_dsc_reset(lv_style_dsc_t * style_dsc)
style_dsc->classes = NULL;
style_dsc->class_cnt = 0;
lv_style_reset(&style_dsc->local);
memset(&style_dsc->cache, 0xff, sizeof(lv_style_cache_t));
}
@ -358,6 +363,369 @@ int16_t lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, voi
return attr_act.bits.state & attr_goal.bits.state;
}
}
uint32_t prop_fooled[256];
lv_res_t lv_style_dsc_get_int(lv_style_dsc_t * dsc, lv_style_property_t prop, lv_style_int_t * value)
{
if(dsc == NULL) return LV_RES_INV;
lv_res_t res = LV_RES_OK;
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_BG_BLEND_MODE:
res = dsc->cache.bg_blend_mode;
break;
case LV_STYLE_BORDER_BLEND_MODE:
res = dsc->cache.border_blend_mode;
break;
case LV_STYLE_IMAGE_BLEND_MODE:
res = dsc->cache.image_blend_mode;
break;
case LV_STYLE_TEXT_BLEND_MODE:
res = dsc->cache.text_blend_mode;
break;
case LV_STYLE_LINE_BLEND_MODE:
res = dsc->cache.line_blend_mode;
break;
case LV_STYLE_SHADOW_BLEND_MODE:
res = dsc->cache.shadow_blend_mode;
break;
case LV_STYLE_PATTERN_BLEND_MODE:
res = dsc->cache.pattern_blend_mode;
break;
case LV_STYLE_CLIP_CORNER:
res = dsc->cache.clip_corner;
break;
case LV_STYLE_LETTER_SPACE:
res = dsc->cache.letter_space;
break;
case LV_STYLE_LINE_SPACE:
res = dsc->cache.line_space;
break;
case LV_STYLE_BORDER_PART:
res = dsc->cache.border_part;
break;
case LV_STYLE_BORDER_WIDTH:
res = dsc->cache.border_width;
break;
case LV_STYLE_SHADOW_WIDTH:
res = dsc->cache.shadow_width;
break;
}
}
if(res == LV_RES_INV) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
int16_t weight_act;
int16_t weight = -1;
lv_style_int_t value_act;
weight_act = lv_style_get_int(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_int(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
}
if(weight >= 0) {
prop_fooled[prop&0xFF]++;
return LV_RES_OK;
}
else return LV_RES_INV;
}
lv_res_t lv_style_dsc_get_color(lv_style_dsc_t * dsc, lv_style_property_t prop, lv_color_t * value)
{
if(dsc == NULL) return LV_RES_INV;
lv_res_t res = LV_RES_OK;
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_TEXT_COLOR:
res = dsc->cache.text_color;
break;
}
}
if(res == LV_RES_INV) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
int16_t weight_act;
int16_t weight = -1;
lv_color_t value_act;
weight_act = lv_style_get_color(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_color(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
}
if(weight >= 0) {
prop_fooled[prop&0xFF]++;
return LV_RES_OK;
}
else return LV_RES_INV;
}
lv_res_t lv_style_dsc_get_opa(lv_style_dsc_t * dsc, lv_style_property_t prop, lv_opa_t * value)
{
if(dsc == NULL) return LV_RES_INV;
lv_res_t res = LV_RES_OK;
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_OPA_SCALE:
res = dsc->cache.opa_scale;
break;
case LV_STYLE_BG_OPA:
res = dsc->cache.bg_opa;
break;
case LV_STYLE_BORDER_OPA:
res = dsc->cache.border_opa;
break;
case LV_STYLE_IMAGE_OPA:
res = dsc->cache.image_opa;
break;
case LV_STYLE_IMAGE_RECOLOR:
res = dsc->cache.image_recolor_opa;
break;
case LV_STYLE_TEXT_OPA:
res = dsc->cache.text_opa;
break;
case LV_STYLE_LINE_OPA:
res = dsc->cache.line_opa;
break;
case LV_STYLE_SHADOW_OPA:
res = dsc->cache.shadow_opa;
break;
case LV_STYLE_OVERLAY_OPA:
res = dsc->cache.overlay_opa;
break;
case LV_STYLE_PATTERN_OPA:
res = dsc->cache.pattern_opa;
break;
}
}
if(res == LV_RES_INV) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
int16_t weight_act;
int16_t weight = -1;
lv_opa_t value_act;
weight_act = lv_style_get_opa(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_opa(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
}
if(weight >= 0) {
prop_fooled[prop&0xFF]++;
return LV_RES_OK;
}
else return LV_RES_INV;
}
lv_res_t lv_style_dsc_get_ptr(lv_style_dsc_t * dsc, lv_style_property_t prop, void ** value)
{
if(dsc == NULL) return LV_RES_INV;
lv_res_t res = LV_RES_OK;
if(dsc->cache.enabled) {
switch(prop & (~LV_STYLE_STATE_MASK)) {
case LV_STYLE_PATTERN_IMAGE:
res = dsc->cache.pattern_image;
break;
case LV_STYLE_FONT:
res = dsc->cache.font;
break;
}
}
if(res == LV_RES_INV) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
int16_t weight_act;
int16_t weight = -1;
void * value_act;
weight_act = lv_style_get_ptr(&dsc->local, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
weight_act = lv_style_get_ptr(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*value = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*value = value_act;
}
}
if(weight >= 0) {
prop_fooled[prop&0xFF]++;
return LV_RES_OK;
}
else return LV_RES_INV;
}
lv_res_t lv_style_cache_update(lv_style_dsc_t * dsc)
{
if(dsc == NULL) return LV_RES_INV;
if(!dsc->cache.enabled) return LV_RES_OK;
dsc->cache.enabled = 0;
lv_style_int_t value;
lv_opa_t opa;
void * ptr;
lv_color_t color;
dsc->cache.bg_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_BG_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.border_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_BORDER_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.image_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_IMAGE_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.text_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_TEXT_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.line_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_LINE_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.shadow_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_SHADOW_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.pattern_blend_mode = lv_style_dsc_get_int(dsc, LV_STYLE_PATTERN_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.clip_corner = lv_style_dsc_get_int(dsc, LV_STYLE_PATTERN_BLEND_MODE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.letter_space = lv_style_dsc_get_int(dsc, LV_STYLE_LETTER_SPACE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.line_space = lv_style_dsc_get_int(dsc, LV_STYLE_LINE_SPACE | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.border_part = lv_style_dsc_get_int(dsc, LV_STYLE_BORDER_PART | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.border_width = lv_style_dsc_get_int(dsc, LV_STYLE_BORDER_WIDTH | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.shadow_width = lv_style_dsc_get_int(dsc, LV_STYLE_SHADOW_WIDTH | LV_STYLE_STATE_ALL, &value) & 0x1U;
dsc->cache.opa_scale = lv_style_dsc_get_opa(dsc, LV_STYLE_OPA_SCALE | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.bg_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_BG_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.border_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_BORDER_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.image_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_IMAGE_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.image_recolor_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_IMAGE_RECOLOR_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.text_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_TEXT_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.line_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_LINE_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.shadow_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_SHADOW_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.overlay_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_OVERLAY_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.pattern_opa = lv_style_dsc_get_opa(dsc, LV_STYLE_PATTERN_OPA | LV_STYLE_STATE_ALL, &opa) & 0x1U;
dsc->cache.text_color = lv_style_dsc_get_color(dsc, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_ALL, &color) & 0x1U;
dsc->cache.font = lv_style_dsc_get_ptr(dsc, LV_STYLE_FONT | LV_STYLE_STATE_ALL, &ptr) & 0x1U;
dsc->cache.pattern_image = lv_style_dsc_get_ptr(dsc, LV_STYLE_PATTERN_IMAGE | LV_STYLE_STATE_ALL, &ptr) & 0x1U;
dsc->cache.enabled = 1;
return LV_RES_OK;
}
#if LV_USE_ANIMATION
@ -396,6 +764,8 @@ void lv_style_anim_set_styles(lv_anim_t * a, lv_style_t * to_anim, const lv_styl
* STATIC FUNCTIONS
**********************/
static uint32_t cnt = 0;
static uint32_t stat[256];
static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop)
{
uint8_t id_to_find = prop & 0xFF;
@ -405,8 +775,33 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
int16_t weight = -1;
int16_t id_guess = -1;
if(id_to_find == (LV_STYLE_RADIUS & 0xFF)) {
volatile uint8_t i = 0;
}
cnt++;
if(cnt > 100000) {
cnt = 0;
uint32_t i;
printf("\nQuerry:\n");
for(i = 0; i < 256; i++) {
if(stat[i]) printf("%02x: %d\n", i, stat[i]);
}
memset(stat, 0x00, sizeof(stat));
printf("\nFooled:\n");
for(i = 0; i < 256; i++) {
if(prop_fooled[i]) printf("%02x: %d\n", i, prop_fooled[i]);
}
memset(prop_fooled, 0x00, sizeof(stat));
printf("\n");
}
size_t i = 0;
while(i < style->size) {
stat[id_to_find]++;
lv_style_attr_t attr_act;
attr_act.full = style->map[i + 1];
if(style->map[i] == id_to_find) {

View File

@ -84,13 +84,13 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_PAD_RIGHT, 0x1, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PAD_INNER, 0x1, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_BLEND_MODE, 0x2, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_COLOR_STOP, 0x2, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_STOP, 0x2, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_DIR, 0x2, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_COLOR, 0x2, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_COLOR, 0x2, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_OPA, 0x2, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_BLEND_MODE, 0x2, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_COLOR_STOP, 0x2, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_STOP, 0x2, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_DIR, 0x2, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_COLOR, 0x2, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_COLOR, 0x2, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_OPA, 0x2, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BORDER_WIDTH, 0x3, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BORDER_PART, 0x3, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
@ -107,9 +107,10 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_REPEATE, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_OPA, 0x5, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR_OPA, 0x5, LV_STYLE_ID_OPA + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_OPA, 0x5, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR_OPA, 0x5, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_IMAGE, 0x5, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_LETTER_SPACE, 0x6, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
@ -188,49 +189,43 @@ typedef int16_t lv_style_int_t;
#define LV_STYLE_CACHE_BORDER_PART_SKIPPED 1
typedef struct {
/*32 bit*/
uint32_t pad_left :6;
uint32_t pad_right :6;
uint32_t pad_top :6;
uint32_t pad_bottom :6;
uint32_t pad_inner :6;
uint32_t bg_grad_dir :2;
/*31 bit*/
uint32_t border_width :3;
uint32_t line_width :3;
uint32_t letter_space :3;
uint32_t line_space :3;
uint32_t shadow_width :1;
uint32_t bg_opa :2;
uint32_t border_opa :2;
uint32_t text_opa :2;
uint32_t image_opa :2;
uint32_t line_opa :2;
uint32_t shadow_opa :2;
uint32_t overlay_opa :2;
uint32_t opa_scale :2;
/*7 props*/
uint32_t bg_blend_mode :1;
uint32_t border_blend_mode :1;
uint32_t text_blend_mode :1;
uint32_t line_blend_mode :1;
uint32_t image_blend_mode :1;
uint32_t shadow_blend_mode :1;
uint32_t text_blend_mode :1;
uint32_t line_blend_mode :1;
uint32_t shadow_blend_mode :1;
uint32_t pattern_blend_mode :1;
/*32 bit*/
uint32_t radius :4;
uint32_t font :1;
uint32_t clip_corner :1;
uint32_t border_part :1;
/*10 props*/
uint32_t opa_scale :1;
uint32_t bg_opa :1;
uint32_t border_opa :1;
uint32_t image_opa :1;
uint32_t image_recolor_opa :1;
uint32_t text_opa :1;
uint32_t line_opa :1;
uint32_t shadow_opa :1;
uint32_t overlay_opa :1;
uint32_t pattern_opa :1;
uint32_t enabled :1;
/*8 props*/
uint32_t clip_corner :1;
uint32_t pattern_image :1;
uint32_t font :1;
uint32_t letter_space :1;
uint32_t line_space :1;
uint32_t text_color :1;
uint32_t border_part :1;
uint32_t border_width :1;
uint32_t shadow_width :1;
uint32_t reserved :23;
/*4 props*/
uint32_t enabled :1;
uint32_t reserved :3;
}lv_style_cache_t;
typedef struct {
lv_style_t local;
lv_style_t ** classes;
@ -310,6 +305,13 @@ int16_t lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, lv_
int16_t lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, lv_color_t * res);
int16_t lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void ** res);
lv_res_t lv_style_dsc_get_int(lv_style_dsc_t * dsc, lv_style_property_t prop, lv_style_int_t * value);
lv_res_t lv_style_dsc_get_color(lv_style_dsc_t * dsc, lv_style_property_t prop, lv_color_t * value);
lv_res_t lv_style_dsc_get_opa(lv_style_dsc_t * dsc, lv_style_property_t prop, lv_opa_t * value);
lv_res_t lv_style_dsc_get_ptr(lv_style_dsc_t * dsc, lv_style_property_t prop, void ** value);
lv_res_t lv_style_cache_update(lv_style_dsc_t * dsc);
#if LV_USE_ANIMATION
/**

View File

@ -114,7 +114,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
/* Do not cache the button style because it's independent from the object's style.
* (Therefore it can't be cached)*/
ext->style_btn.cache.enabled = 0;
// ext->style_btn.cache.enabled = 0;
_ot(new_btnm, LV_BTNM_PART_BTN, BTNM_BTN);
}
/*Copy an existing object*/
@ -622,7 +622,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
/*The state changes without re-caching the styles, disable the use of cache*/
btnm->style_dsc.cache.enabled = 0;
// btnm->style_dsc.cache.enabled = 0;
uint8_t state_ori = btnm->state;
btnm->state = 0;
lv_draw_rect_dsc_init(&draw_rect_rel_dsc);
@ -643,7 +643,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_ina_dsc);
btnm->state = state_ori;
btnm->style_dsc.cache.enabled = 1;
// btnm->style_dsc.cache.enabled = 1;
lv_style_int_t padding_top = lv_obj_get_style_int(btnm, LV_BTNM_PART_BG, LV_STYLE_PAD_TOP);
lv_style_int_t padding_bottom = lv_obj_get_style_int(btnm, LV_BTNM_PART_BG, LV_STYLE_PAD_BOTTOM);
@ -684,7 +684,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
/*Focused and/or pressed + checked or released button*/
else {
/*The state changes without re-caching the styles, disable the use of cache*/
btnm->style_dsc.cache.enabled = 0;
// btnm->style_dsc.cache.enabled = 0;
if(tgl_state) btnm->state = LV_OBJ_STATE_CHECKED;
if(ext->btn_id_pr == btn_i) btnm->state |= LV_OBJ_STATE_PRESSED;
@ -697,7 +697,7 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
draw_label_dsc_act = &draw_label_tmp_dsc;
btnm->state = state_ori;
btnm->style_dsc.cache.enabled = 1;
// btnm->style_dsc.cache.enabled = 1;
}
lv_style_int_t border_part_ori = draw_rect_dsc_act->border_part;

View File

@ -128,11 +128,11 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
/*Different styles will be used from the styles while rendering so disable caching*/
ext->style_date_nums.cache.enabled = 0;
ext->style_day_names.cache.enabled = 0;
ext->style_header.cache.enabled = 0;
ext->style_today_box.cache.enabled = 0;
ext->style_week_box.cache.enabled = 0;
// ext->style_date_nums.cache.enabled = 0;
// ext->style_day_names.cache.enabled = 0;
// ext->style_header.cache.enabled = 0;
// ext->style_today_box.cache.enabled = 0;
// ext->style_week_box.cache.enabled = 0;
lv_style_dsc_reset(&new_calendar->style_dsc);
lv_style_dsc_add_class(&new_calendar->style_dsc, lv_theme_get_style(LV_THEME_CALENDAR_BG));
@ -707,7 +707,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
/*Add the left arrow*/
/*The state changes without re-caching the styles, disable the use of cache*/
calendar->style_dsc.cache.enabled = 0;
// calendar->style_dsc.cache.enabled = 0;
lv_obj_state_t state_ori = calendar->state;
if(ext->btn_pressing < 0) calendar->state |= LV_OBJ_STATE_PRESSED;
@ -732,7 +732,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label(&header_area, mask, &label_dsc, LV_SYMBOL_RIGHT, NULL);
calendar->state = state_ori; /*Restore the state*/
calendar->style_dsc.cache.enabled = 1;
// calendar->style_dsc.cache.enabled = 1;
}
/**
@ -806,7 +806,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
lv_style_int_t wb_bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_WEEK_BOX, LV_STYLE_PAD_BOTTOM);
/*The state changes without re-caching the styles, disable the use of cache*/
calendar->style_dsc.cache.enabled = 0;
// calendar->style_dsc.cache.enabled = 0;
lv_obj_state_t state_ori = calendar->state;
lv_draw_label_dsc_t wb_label_dsc;
@ -830,7 +830,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
ina_label_dsc.flag = LV_TXT_FLAG_CENTER;
pr_label_dsc.flag = LV_TXT_FLAG_CENTER;
calendar->state = 0;
// calendar->state = 0;
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_WEEK_BOX, &wb_label_dsc);
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_TODAY_BOX, &tb_label_dsc);
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE_NUMS, &normal_label_dsc);
@ -845,7 +845,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE_NUMS, &pr_label_dsc);
calendar->state = state_ori;
calendar->style_dsc.cache.enabled = 1;
// calendar->style_dsc.cache.enabled = 1;
lv_draw_label_dsc_t * act_label_dsc = &ina_label_dsc;

View File

@ -542,7 +542,7 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(img, LV_IMG_PART_MAIN, &label_dsc);
label_dsc.color = lv_obj_get_style_color(img, LV_IMG_PART_MAIN, LV_STYLE_OVERLAY_COLOR);
label_dsc.color = lv_obj_get_style_color(img, LV_IMG_PART_MAIN, LV_STYLE_IMAGE_RECOLOR);
lv_draw_label(&coords, clip_area, &label_dsc, ext->src, NULL);
} else {
/*Trigger the error handler of image drawer*/
@ -565,10 +565,11 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
uint8_t ** type_p = param;
lv_style_dsc_t ** style_dsc_p = param;
*style_dsc_p = lv_img_get_style(img, **type_p);
return LV_RES_OK;
lv_get_style_info_t * info = param;
info->result = lv_img_get_style(img, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(img, sign, param);
}
/* Include the ancient signal function */

View File

@ -218,7 +218,6 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - pad);
}
if(label_signal == NULL) label_signal = lv_obj_get_signal_cb(label);
lv_label_set_body_draw(label, true);
}
@ -688,9 +687,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
uint8_t ** type_p = param;
lv_style_dsc_t ** style_dsc_p = param;
*style_dsc_p = lv_list_get_style(list, **type_p);
lv_get_style_info_t * info = param;
info->result = lv_list_get_style(list, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_page_signal(list, sign, param);
return LV_RES_OK;
}

View File

@ -234,10 +234,10 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
uint8_t ** type_p = param;
lv_style_dsc_t ** style_dsc_p = param;
*style_dsc_p = lv_slider_get_style(slider, **type_p);
return LV_RES_OK;
lv_get_style_info_t * info = param;
info->result = lv_slider_get_style(slider, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(slider, sign, param);
}
/* Include the ancient signal function */

View File

@ -189,10 +189,10 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
uint8_t ** type_p = param;
lv_style_dsc_t ** style_dsc_p = param;
*style_dsc_p = lv_sw_get_style(sw, **type_p);
return LV_RES_OK;
lv_get_style_info_t * info = param;
info->result = lv_sw_get_style(sw, info->part);
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(sw, sign, param);
}
if(sign == LV_SIGNAL_GET_TYPE) {

View File

@ -1381,11 +1381,13 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
if(info->result != NULL) return LV_RES_OK;
else return ancestor_signal(ta, sign, param);
}else if(sign == LV_SIGNAL_GET_STATE) {
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
lv_ta_ext_t * ext = ta->ext_attr;
lv_get_state_info_t * info = param;
if(info->part == LV_TA_PART_PLACEHOLDER) info->result = ext->placeholder ? lv_obj_get_state(ext->placeholder, LV_LABEL_PART_MAIN) : 0;
else info->result = lv_obj_get_state(ta, info->part);
return LV_RES_OK;
if(info->part == LV_TA_PART_PLACEHOLDER) {
info->result = ext->placeholder ? lv_obj_get_state(ext->placeholder, LV_LABEL_PART_MAIN) : 0;
return LV_RES_OK;
}
else return ancestor_signal(ta, sign, param);
}
/* Include the ancient signal function */

View File

@ -135,6 +135,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_dsc_reset(lv_obj_get_style(ext->content, LV_PAGE_PART_BG));
lv_style_dsc_reset(lv_obj_get_style(ext->content, LV_PAGE_PART_SCRL));
lv_style_dsc_reset(lv_obj_get_style(new_tabview, LV_TABVIEW_PART_INDIC));
lv_style_dsc_reset(lv_obj_get_style(new_tabview, LV_TABVIEW_PART_BTNS));
lv_style_dsc_reset(lv_obj_get_style(new_tabview, LV_TABVIEW_PART_BTNS_BG));
lv_obj_add_style_class(ext->content, LV_PAGE_PART_BG, &lv_style_transp_tight);
_ot(new_tabview, LV_TABVIEW_PART_BG_SCRL, TABVIEW_BG_SCRL);
_ot(new_tabview, LV_TABVIEW_PART_BTNS, TABVIEW_BTNS);

View File

@ -84,7 +84,7 @@ static void basic_init(void)
lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , LV_COLOR_WHITE);
lv_style_init(&transp);
lv_style_set_int(&transp, LV_STYLE_BG_OPA, LV_OPA_TRANSP);
lv_style_set_opa(&transp, LV_STYLE_BG_OPA, LV_OPA_TRANSP);
lv_style_set_int(&transp, LV_STYLE_BORDER_WIDTH, 0);
lv_style_init(&panel);
@ -141,8 +141,6 @@ static void basic_init(void)
lv_style_set_int(&transp_tight, LV_STYLE_PAD_TOP, 0);
lv_style_set_int(&transp_tight, LV_STYLE_PAD_BOTTOM, 0);
lv_style_set_int(&transp_tight, LV_STYLE_PAD_INNER, 0);
}
static void cont_init(void)