lv_draw_label: optimization
This commit is contained in:
@@ -69,15 +69,29 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
|||||||
w = p.x;
|
w = p.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
|
||||||
|
|
||||||
|
|
||||||
/*Init variables for the first line*/
|
/*Init variables for the first line*/
|
||||||
lv_coord_t line_width = 0;
|
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;
|
lv_point_t pos;
|
||||||
pos.x = coords->x1;
|
pos.x = coords->x1;
|
||||||
pos.y = coords->y1;
|
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*/
|
/*Align to middle*/
|
||||||
if(flag & LV_TXT_FLAG_CENTER) {
|
if(flag & LV_TXT_FLAG_CENTER) {
|
||||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
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);
|
lv_rletter_set_background(style->body.main_color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
|
|
||||||
|
|
||||||
/*Write out all lines*/
|
/*Write out all lines*/
|
||||||
while(txt[line_start] != '\0') {
|
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) {
|
while(i < line_end) {
|
||||||
letter = lv_txt_encoded_next(txt, &i);
|
letter = lv_txt_encoded_next(txt, &i);
|
||||||
|
|
||||||
if(pos.y + line_height < mask->y1) continue;
|
|
||||||
|
|
||||||
/*Handle the re-color command*/
|
/*Handle the re-color command*/
|
||||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||||
if(letter == (uint32_t)LV_TXT_COLOR_CMD[0]) {
|
if(letter == (uint32_t)LV_TXT_COLOR_CMD[0]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user