lv_draw_label: optimization

This commit is contained in:
Gabor Kiss-Vamosi
2018-12-21 15:25:45 +01:00
parent 391fda7ba6
commit 7947a991a4

View File

@@ -69,15 +69,29 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
w = p.x;
}
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
/*Init variables for the first line*/
lv_coord_t line_width = 0;
uint32_t line_start = 0;
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
lv_point_t pos;
pos.x = coords->x1;
pos.y = coords->y1;
uint32_t line_start = 0;
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
/*Go the first visible line*/
while(pos.y + line_height < mask->y1) {
/*Go to next line*/
line_start = line_end;
line_end += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, w, flag);
pos.y += line_height;
if(txt[line_start] == '\0') return;
}
printf("\n");
/*Align to middle*/
if(flag & LV_TXT_FLAG_CENTER) {
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
@@ -115,7 +129,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
lv_rletter_set_background(style->body.main_color);
#endif
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
/*Write out all lines*/
while(txt[line_start] != '\0') {
@@ -129,8 +142,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
while(i < line_end) {
letter = lv_txt_encoded_next(txt, &i);
if(pos.y + line_height < mask->y1) continue;
/*Handle the re-color command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(letter == (uint32_t)LV_TXT_COLOR_CMD[0]) {