improve rendering time

This commit is contained in:
Gabor Kiss-Vamosi
2019-12-27 15:39:54 +01:00
parent 302f21cbd5
commit 93f6e48fd4
5 changed files with 63 additions and 38 deletions

View File

@@ -2070,6 +2070,11 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
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;
@@ -2105,6 +2110,12 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
return dsc->cache.border_width == LV_STYLE_CACHE_RADIUS_CIRCLE ? LV_RADIUS_CIRCLE : dsc->cache.radius;
}
break;
case LV_STYLE_BG_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_PART_FULL;
break;
}
}
@@ -2367,6 +2378,14 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_prope
void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop)
{
lv_style_dsc_t * dsc = lv_obj_get_style(obj, type);
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;
}
}
uint8_t state;
lv_style_property_t prop_ori = prop;
@@ -2881,11 +2900,12 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t type, lv_draw_rect_dsc_t
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t type, lv_draw_label_dsc_t * draw_dsc)
{
draw_dsc->color = lv_obj_get_style_color(obj, type, LV_STYLE_TEXT_COLOR);
draw_dsc->letter_space = lv_obj_get_style_value(obj, type, LV_STYLE_LETTER_SPACE);
draw_dsc->font = lv_obj_get_style_ptr(obj, type, LV_STYLE_FONT);
draw_dsc->color = LV_COLOR_WHITE; //lv_obj_get_style_color(obj, type, LV_STYLE_TEXT_COLOR);
draw_dsc->letter_space = 0;//lv_obj_get_style_value(obj, type, LV_STYLE_LETTER_SPACE);
draw_dsc->font = LV_FONT_DEFAULT;//lv_obj_get_style_ptr(obj, type, LV_STYLE_FONT);
draw_dsc->opa = LV_OPA_COVER;
return;
lv_opa_t opa_scale = lv_obj_get_style_opa(obj, type, LV_STYLE_OPA_SCALE);
if(opa_scale < LV_OPA_MAX) {
draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8;
@@ -2956,7 +2976,6 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
}
}
else if(mode == LV_DESIGN_DRAW_POST) {
// const lv_style_t * style_dsc = lv_obj_get_style(obj);
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8);
lv_mem_buf_release(param);
@@ -3202,6 +3221,10 @@ static lv_res_t style_cache_update_core(lv_obj_t * obj, uint8_t type)
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_value(obj, type, LV_STYLE_BORDER_PART);
if(value == LV_BORDER_PART_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, type, 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;

View File

@@ -101,29 +101,29 @@ void lv_style_built_in_init(void)
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_INNER, LV_DPI / 16);
lv_style_init(&lv_style_panel);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_LEFT, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_RIGHT, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_TOP, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_LEFT, LV_DPI / 20);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_RIGHT, LV_DPI / 20);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_TOP, LV_DPI / 20);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 20);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_INNER, LV_DPI / 20);
lv_style_set_value(&lv_style_panel, LV_STYLE_RADIUS, LV_DPI / 16);
lv_style_set_value(&lv_style_panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
lv_style_set_color(&lv_style_panel, LV_STYLE_BG_COLOR, LV_COLOR_SILVER);
lv_style_set_color(&lv_style_panel, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_GRAY);
// lv_style_set_color(&lv_style_panel, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_GRAY);
lv_style_set_color(&lv_style_panel, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
lv_style_init(&lv_style_btn);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_LEFT, LV_DPI / 6);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_RIGHT, LV_DPI / 6);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_LEFT, LV_DPI / 20);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_RIGHT, LV_DPI / 20);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_TOP, LV_DPI / 20);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 20);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_INNER, LV_DPI / 16);
lv_style_set_value(&lv_style_btn, LV_STYLE_RADIUS, LV_DPI / 20);
lv_style_set_value(&lv_style_btn, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
lv_style_set_value(&lv_style_btn, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_COLOR, LV_COLOR_BLUE);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_NAVY);
lv_style_set_color(&lv_style_btn, LV_STYLE_BORDER_COLOR, LV_COLOR_NAVY);
// lv_style_set_value(&lv_style_btn, LV_STYLE_RADIUS, LV_DPI / 20);
// lv_style_set_value(&lv_style_btn, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
// lv_style_set_value(&lv_style_btn, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_COLOR, LV_COLOR_RED);
// lv_style_set_color(&lv_style_btn, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_RED);
// lv_style_set_color(&lv_style_btn, LV_STYLE_BORDER_COLOR, LV_COLOR_NAVY);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_GRAD_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_BLACK);
lv_style_set_color(&lv_style_btn, LV_STYLE_TEXT_COLOR, LV_COLOR_WHITE);

View File

@@ -171,6 +171,10 @@ typedef int16_t lv_style_value_t;
#define LV_STYLE_CACHE_BLEND_MODE_NORMAL 0
#define LV_STYLE_CACHE_BLEND_MODE_SKIPPED 1
#define LV_STYLE_CACHE_BORDER_PART_FULL 0
#define LV_STYLE_CACHE_BORDER_PART_SKIPPED 1
typedef struct {
/*32 bit*/
uint32_t pad_left :6;
@@ -206,6 +210,7 @@ typedef struct {
uint32_t radius :4;
uint32_t font :1;
uint32_t clip_corner :1;
uint32_t border_part :1;
uint32_t enabled :1;

View File

@@ -161,7 +161,7 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
if(rout > short_side >> 1) rout = short_side >> 1;
/*Most simple case: just a plain rectangle*/
if(simple_mode && rout == 0 && dsc->bg_color.full == dsc->bg_grad_color.full) {
if(simple_mode && rout == 0 && (dsc->bg_grad_dir == LV_GRAD_DIR_NONE)) {
lv_blend_fill(clip, &coords_bg,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->bg_blend_mode);

View File

@@ -1044,9 +1044,6 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
return LV_DESIGN_RES_NOT_COVER;
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_area_t coords;
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
lv_style_value_t line_space = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_LINE_SPACE);
lv_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_LETTER_SPACE);
lv_obj_get_coords(label, &coords);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
@@ -1078,12 +1075,22 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
if(align == LV_LABEL_ALIGN_RIGHT) flag |= LV_TXT_FLAG_RIGHT;
lv_draw_label_dsc_t label_draw_dsc;
lv_draw_label_dsc_init(&label_draw_dsc);
label_draw_dsc.sel_start = lv_label_get_text_sel_start(label);
label_draw_dsc.sel_end = lv_label_get_text_sel_end(label);
label_draw_dsc.ofs_x = ext->offset.x;
label_draw_dsc.ofs_y = ext->offset.y;
label_draw_dsc.flag = flag;
lv_obj_init_draw_label_dsc(label, LV_LABEL_STYLE_MAIN, &label_draw_dsc);
/* In ROLL mode the CENTER and RIGHT are pointless so remove them.
* (In addition they will result mis-alignment is this case)*/
if((ext->long_mode == LV_LABEL_LONG_SROLL || ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) &&
(ext->align == LV_LABEL_ALIGN_CENTER || ext->align == LV_LABEL_ALIGN_RIGHT)) {
lv_point_t size;
lv_txt_get_size(&size, ext->text, font, letter_space, line_space,
lv_txt_get_size(&size, ext->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
LV_COORD_MAX, flag);
if(size.x > lv_obj_get_width(label)) {
flag &= ~LV_TXT_FLAG_RIGHT;
@@ -1100,27 +1107,17 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
lv_draw_label_hint_t * hint = NULL;
#endif
lv_draw_label_dsc_t label_draw_dsc;
lv_draw_label_dsc_init(&label_draw_dsc);
label_draw_dsc.sel_start = lv_label_get_text_sel_start(label);
label_draw_dsc.sel_end = lv_label_get_text_sel_end(label);
label_draw_dsc.ofs_x = ext->offset.x;
label_draw_dsc.ofs_y = ext->offset.y;
label_draw_dsc.flag = flag;
lv_obj_init_draw_label_dsc(label, LV_LABEL_STYLE_MAIN, &label_draw_dsc);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
lv_point_t size;
lv_txt_get_size(&size, ext->text, font, letter_space, line_space,
lv_txt_get_size(&size, ext->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
LV_COORD_MAX, flag);
/*Draw the text again next to the original to make an circular effect */
if(size.x > lv_obj_get_width(label)) {
label_draw_dsc.ofs_x = ext->offset.x + size.x +
lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
lv_font_get_glyph_width(label_draw_dsc.font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
label_draw_dsc.ofs_y = ext->offset.y;
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
@@ -1129,7 +1126,7 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
/*Draw the text again below the original to make an circular effect */
if(size.y > lv_obj_get_height(label)) {
label_draw_dsc.ofs_x = ext->offset.x;
label_draw_dsc.ofs_y = ext->offset.y + size.y + lv_font_get_line_height(font);
label_draw_dsc.ofs_y = ext->offset.y + size.y + lv_font_get_line_height(label_draw_dsc.font);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
}