perf(demo): use set_text_static in demos to cache them ins SDL and OpenGL renderers

This commit is contained in:
Gabor Kiss-Vamosi 2024-10-11 09:54:53 +02:00 committed by VIFEX
parent d469d65683
commit 926e3df7e3
2 changed files with 37 additions and 42 deletions

View File

@ -243,7 +243,7 @@ static void multiple_labels_cb(void)
for(x = 0; x < hor_cnt; x++) {
lv_obj_t * obj = lv_label_create(lv_screen_active());
if(x == 0) lv_obj_add_flag(obj, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
lv_label_set_text(obj, "Hello LVGL!");
lv_label_set_text_static(obj, "Hello LVGL!");
color_anim(obj);
}
}
@ -252,11 +252,13 @@ static void multiple_labels_cb(void)
static void screen_sized_text_cb(void)
{
const char * txt =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec rhoncus arcu, in consectetur orci. Sed vitae dolor sed nisi ultrices vehicula quis ac dolor. Vivamus hendrerit hendrerit lectus, sed tempus velit suscipit in. Fusce eu tristique arcu. Sed et molestie leo, in lacinia nunc. Quisque semper lorem sed ante feugiat, at molestie risus blandit. Maecenas lobortis urna in diam feugiat porta. Ut facilisis mauris eget nibh posuere aliquet. Proin facilisis egestas magna, id vulputate massa bibendum a. Etiam gravida metus non egestas suscipit. Sed sollicitudin mollis nisi, eu fringilla leo vestibulum posuere. Donec et ex nulla. Phasellus et ornare justo, vel hendrerit justo. Curabitur pulvinar nunc sed tincidunt dignissim. Praesent eleifend lectus velit, id malesuada ante placerat id. Fusce massa erat, egestas vel venenatis eu, tempus nec est.\n\n"
"Phasellus iaculis malesuada molestie. Cras ullamcorper justo a dolor dignissim tincidunt. Mauris euismod risus quis lobortis mollis. Ut vitae placerat massa, aliquet various lectus. Nulla ac ornare purus, quis auctor velit. Donec posuere dolor rhoncus efficitur dictum. Integer venenatis aliquet nunc eu convallis. Nunc quis various velit. Suspendisse enim metus, molestie eget mauris sit amet, euismod volutpat turpis. Duis rhoncus commodo gravida. Pellentesque velit mi, dictum id consequat placerat, condimentum ac elit. Duis aliquet leo eu dolor cursus rhoncus. Quisque aliquam sapien ut purus hendrerit laoreet. Ut venenatis venenatis risus, a vestibulum enim lobortis a. Maecenas auctor tortor lorem, quis laoreet nulla aliquet a. Sed ipsum lorem, facilisis in congue a, dictum ut ligula.\n\n"
"Aliquam id tellus in enim hendrerit mattis. Sed ipsum arcu, feugiat sed eros quis, vulputate facilisis turpis. Quisque venenatis risus massa. Proin lacinia, nunc non ultrices commodo, ligula dolor lobortis lectus, iaculis pulvinar metus orci eu elit. Donec tincidunt lacinia semper. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec vitae odio risus. Donec sodales sed nulla sit amet iaculis. Duis lacinia mauris dictum, fermentum nibh eget, convallis tellus. Sed congue luctus purus non scelerisque. Etiam fermentum lacus mauris, at bibendum nunc aliquam at. Vivamus accumsan vestibulum pharetra. Proin rhoncus nisi purus, vel blandit metus auctor eget. Fusce dictum sed lectus sed aliquam. Praesent lobortis quam sed pretium tincidunt.\n\n"
"Integer vehicula vestibulum eros. Donec facilisis magna a est cursus, sed posuere velit faucibus. In et ultrices lorem. Sed et lacus finibus, vulputate odio et, finibus tellus. Aenean finibus nibh vehicula elementum maximus. Maecenas in luctus tortor, vitae ullamcorper lacus. Ut nulla elit, aliquam at vestibulum ut, pellentesque non justo.\n\n"
"Fusce dignissim turpis massa, eget semper purus semper at. Ut et augue vitae metus laoreet auctor. Morbi tincidunt, neque vel tincidunt interdum, sapien nibh finibus lorem, eu eleifend diam ipsum et eros. Duis iaculis vulputate lacinia. Phasellus id mauris sed magna gravida suscipit. Sed aliquet tincidunt ante ac posuere. In vestibulum quam ultricies, ultricies arcu eu, aliquam sapien. Phasellus sollicitudin velit facilisis, dignissim nisi sed, pellentesque magna.";
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque fringilla, lorem dapibus fringilla feugiat, justo arcu volutpat magna, vitae ultricies metus tortor nec est. Fusce ut tellus arcu. Fusce eu rutrum metus, nec porta felis. Sed sed ligula laoreet, sodales lacus blandit, elementum justo. Sed posuere quam ut pellentesque ullamcorper. In quis consequat magna. Etiam quis turpis nec lorem dictum finibus. Donec mattis enim dolor, consequat lacinia nisi scelerisque id. Nulla euismod, purus sit amet accumsan tempus, lorem lectus euismod dolor, sit amet facilisis nisl quam elementum nisi. Curabitur et massa eget lorem lacinia scelerisque eget vitae felis. Nulla facilisi.\n\n"
"Vivamus auctor sit amet ante id rhoncus. Duis a dolor neque. Mauris eu ornare tortor. Vivamus consequat, ipsum a volutpat congue, sem libero laoreet nulla, malesuada efficitur leo orci a est. Donec tincidunt nulla nibh, quis pretium mi fermentum quis. Fusce a mattis libero. Curabitur in felis suscipit, ultrices diam imperdiet, vestibulum arcu. Praesent id faucibus turpis. Pellentesque sed massa tincidunt, interdum purus tempus, pellentesque risus. Fusce feugiat magna eget nisl eleifend efficitur. Mauris ut convallis justo. Integer malesuada rutrum orci non tincidunt.\n\n"
"Nullam aliquet leo sit amet volutpat tincidunt. Mauris ac accumsan nibh. Morbi accumsan commodo leo, at hendrerit massa hendrerit et. Aliquam nec sodales ex. Morbi at aliquet sem. Sed at magna ut felis mollis dictum ut ac orci. Nunc id lorem lacus. Vivamus id accumsan dolor, sed suscipit nulla. Pellentesque dictum erat non bibendum tempor. Fusce arcu risus, eleifend in lacus a, iaculis fermentum sapien. Praesent sodales libero vitae massa suscipit tincidunt. Aliquam quis arcu urna. Nunc sit amet mi leo.\n\n"
"Aliquam erat volutpat. Sed viverra pharetra ipsum, sed various arcu various nec. Curabitur rutrum odio et pretium fermentum. Maecenas vitae ligula nisi. Maecenas nec dapibus erat. Suspendisse vel accumsan erat. Proin congue diam at turpis accumsan eleifend.\n\n"
"Etiam suscipit metus magna, in vulputate magna cursus eget. Donec vel rhoncus turpis. Phasellus vitae enim quis sapien pharetra aliquam quis a quam. In mauris nulla, euismod quis orci et, interdum finibus lorem. Aenean quis dolor eget est ultricies consectetur eu nec metus. Nullam at pulvinar elit. Aenean blandit faucibus sodales. Vivamus vel porta enim, et pharetra libero. Donec aliquet pretium erat viverra fermentum. Fusce sit amet porta mi. Nullam non elit ex. In luctus, nunc id iaculis ullamcorper, eros quam eleifend elit, quis dictum sem justo eu eros. Nulla vitae faucibus lectus. Nunc blandit, mi eget suscipit scelerisque, lorem nunc tincidunt tellus, eget gravida libero metus sed nunc.\n\n"
"Morbi erat libero, commodo sit amet turpis eget, efficitur pulvinar dolor. Pellentesque vehicula, velit eget auctor scelerisque, sem risus aliquam lectus, sit amet dapibus massa ex non magna. Donec magna leo, laoreet quis erat vitae, consequat aliquet tellus. Etiam vitae lectus erat. Mauris interdum feugiat aliquet. Nunc justo augue, mattis id finibus eu, sagittis id enim. Vivamus malesuada mauris sed nibh luctus, porta bibendum quam ornare. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Vivamus malesuada magna nec diam tempus, laoreet imperdiet magna faucibus. Aliquam erat volutpat.\n\n"
"Aenean mattis lobortis quam in venenatis. Sed euismod convallis lectus vel euismod. Vestibulum consequat luctus neque. Quisque consequat bibendum neque eget mollis. Vivamus viverra vehicula eros vel dapibus. Nullam id lectus aliquam, sagittis mi efficitur, interdum mauris. Nunc at felis lobortis, lobortis erat a, euismod augue. In id purus malesuada, tempus magna at, porta mi. Sed tristique nunc eget placerat luctus. Pellentesque posuere non purus vitae malesuada. Curabitur hendrerit dolor metus, nec posuere orci placerat ac.\n\n";
lv_obj_t * scr = lv_screen_active();
int32_t hor_res = lv_display_get_horizontal_resolution(NULL);
@ -267,13 +269,9 @@ static void screen_sized_text_cb(void)
lv_obj_t * obj = lv_label_create(scr);
lv_obj_set_width(obj, lv_pct(100));
lv_label_set_text(obj, txt);
lv_label_set_text_static(obj, txt);
lv_obj_update_layout(obj);
if(lv_obj_get_height(obj) < ver_res * 2) {
lv_label_set_text_fmt(obj, "%s\n\n%s", txt, txt);
lv_obj_update_layout(obj);
}
scroll_anim(scr, lv_obj_get_scroll_bottom(scr));
}
@ -831,12 +829,12 @@ static lv_obj_t * card_create(void)
lv_image_set_src(child, &img_benchmark_avatar);
child = lv_label_create(panel);
lv_label_set_text(child, "John Smith");
lv_label_set_text_static(child, "John Smith");
lv_obj_set_style_text_font(child, &lv_font_montserrat_24, 0);
lv_obj_set_pos(child, 100, 0);
child = lv_label_create(panel);
lv_label_set_text(child, "A DIY enthusiast");
lv_label_set_text_static(child, "A DIY enthusiast");
lv_obj_set_style_text_font(child, &lv_font_montserrat_14, 0);
lv_obj_set_pos(child, 100, 30);
@ -844,7 +842,7 @@ static lv_obj_t * card_create(void)
lv_obj_set_pos(child, 100, 50);
child = lv_label_create(child);
lv_label_set_text(child, "Connect");
lv_label_set_text_static(child, "Connect");
return panel;
}

View File

@ -207,7 +207,7 @@ void lv_demo_widgets(void)
lv_obj_align_to(label, logo, LV_ALIGN_OUT_RIGHT_TOP, 10, 0);
label = lv_label_create(tab_bar);
lv_label_set_text(label, "Widgets demo");
lv_label_set_text_static(label, "Widgets demo");
lv_obj_add_flag(label, LV_OBJ_FLAG_IGNORE_LAYOUT);
lv_obj_add_style(label, &style_text_muted, 0);
lv_obj_align_to(label, logo, LV_ALIGN_OUT_RIGHT_BOTTOM, 10, 0);
@ -255,33 +255,33 @@ static void profile_create(lv_obj_t * parent)
lv_image_set_src(avatar, &img_demo_widgets_avatar);
lv_obj_t * name = lv_label_create(panel1);
lv_label_set_text(name, "Elena Smith");
lv_label_set_text_static(name, "Elena Smith");
lv_obj_add_style(name, &style_title, 0);
lv_obj_t * dsc = lv_label_create(panel1);
lv_obj_add_style(dsc, &style_text_muted, 0);
lv_label_set_text(dsc, "This is a short description of me. Take a look at my profile!");
lv_label_set_text_static(dsc, "This is a short description of me. Take a look at my profile!");
lv_label_set_long_mode(dsc, LV_LABEL_LONG_WRAP);
lv_obj_t * email_icn = lv_label_create(panel1);
lv_obj_add_style(email_icn, &style_icon, 0);
lv_label_set_text(email_icn, LV_SYMBOL_ENVELOPE);
lv_label_set_text_static(email_icn, LV_SYMBOL_ENVELOPE);
lv_obj_t * email_label = lv_label_create(panel1);
lv_label_set_text(email_label, "elena@smith.com");
lv_label_set_text_static(email_label, "elena@smith.com");
lv_obj_t * call_icn = lv_label_create(panel1);
lv_obj_add_style(call_icn, &style_icon, 0);
lv_label_set_text(call_icn, LV_SYMBOL_CALL);
lv_label_set_text_static(call_icn, LV_SYMBOL_CALL);
lv_obj_t * call_label = lv_label_create(panel1);
lv_label_set_text(call_label, "+79 246 123 4567");
lv_label_set_text_static(call_label, "+79 246 123 4567");
lv_obj_t * log_out_btn = lv_button_create(panel1);
lv_obj_set_height(log_out_btn, LV_SIZE_CONTENT);
lv_obj_t * label = lv_label_create(log_out_btn);
lv_label_set_text(label, "Log out");
lv_label_set_text_static(label, "Log out");
lv_obj_center(label);
lv_obj_t * invite_btn = lv_button_create(panel1);
@ -289,7 +289,7 @@ static void profile_create(lv_obj_t * parent)
lv_obj_set_height(invite_btn, LV_SIZE_CONTENT);
label = lv_label_create(invite_btn);
lv_label_set_text(label, "Invite");
lv_label_set_text_static(label, "Invite");
lv_obj_center(label);
/*Create a keyboard*/
@ -301,11 +301,11 @@ static void profile_create(lv_obj_t * parent)
lv_obj_set_height(panel2, LV_SIZE_CONTENT);
lv_obj_t * panel2_title = lv_label_create(panel2);
lv_label_set_text(panel2_title, "Your profile");
lv_label_set_text_static(panel2_title, "Your profile");
lv_obj_add_style(panel2_title, &style_title, 0);
lv_obj_t * user_name_label = lv_label_create(panel2);
lv_label_set_text(user_name_label, "User name");
lv_label_set_text_static(user_name_label, "User name");
lv_obj_add_style(user_name_label, &style_text_muted, 0);
lv_obj_t * user_name = lv_textarea_create(panel2);
@ -314,7 +314,7 @@ static void profile_create(lv_obj_t * parent)
lv_obj_add_event_cb(user_name, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_t * password_label = lv_label_create(panel2);
lv_label_set_text(password_label, "Password");
lv_label_set_text_static(password_label, "Password");
lv_obj_add_style(password_label, &style_text_muted, 0);
lv_obj_t * password = lv_textarea_create(panel2);
@ -324,14 +324,14 @@ static void profile_create(lv_obj_t * parent)
lv_obj_add_event_cb(password, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_t * gender_label = lv_label_create(panel2);
lv_label_set_text(gender_label, "Gender");
lv_label_set_text_static(gender_label, "Gender");
lv_obj_add_style(gender_label, &style_text_muted, 0);
lv_obj_t * gender = lv_dropdown_create(panel2);
lv_dropdown_set_options_static(gender, "Male\nFemale\nOther");
lv_obj_t * birthday_label = lv_label_create(panel2);
lv_label_set_text(birthday_label, "Birthday");
lv_label_set_text_static(birthday_label, "Birthday");
lv_obj_add_style(birthday_label, &style_text_muted, 0);
lv_obj_t * birthdate = lv_textarea_create(panel2);
@ -341,11 +341,11 @@ static void profile_create(lv_obj_t * parent)
/*Create the third panel*/
lv_obj_t * panel3 = lv_obj_create(parent);
lv_obj_t * panel3_title = lv_label_create(panel3);
lv_label_set_text(panel3_title, "Your skills");
lv_label_set_text_static(panel3_title, "Your skills");
lv_obj_add_style(panel3_title, &style_title, 0);
lv_obj_t * experience_label = lv_label_create(panel3);
lv_label_set_text(experience_label, "Experience");
lv_label_set_text_static(experience_label, "Experience");
lv_obj_add_style(experience_label, &style_text_muted, 0);
lv_obj_t * slider1 = lv_slider_create(panel3);
@ -355,13 +355,13 @@ static void profile_create(lv_obj_t * parent)
lv_obj_refresh_ext_draw_size(slider1);
lv_obj_t * team_player_label = lv_label_create(panel3);
lv_label_set_text(team_player_label, "Team player");
lv_label_set_text_static(team_player_label, "Team player");
lv_obj_add_style(team_player_label, &style_text_muted, 0);
lv_obj_t * sw1 = lv_switch_create(panel3);
lv_obj_t * hard_working_label = lv_label_create(panel3);
lv_label_set_text(hard_working_label, "Hard-working");
lv_label_set_text_static(hard_working_label, "Hard-working");
lv_obj_add_style(hard_working_label, &style_text_muted, 0);
lv_obj_t * sw2 = lv_switch_create(panel3);
@ -897,8 +897,6 @@ void shop_create(lv_obj_t * parent)
lv_obj_set_style_text_color(hint, lv_palette_main(LV_PALETTE_GREEN), 0);
chart3 = lv_chart_create(panel1);
// lv_chart_set_axis_tick(chart3, LV_CHART_AXIS_PRIMARY_Y, 0, 0, 6, 1, true, 80);
// lv_chart_set_axis_tick(chart3, LV_CHART_AXIS_PRIMARY_X, 0, 0, 7, 1, true, 50);
lv_chart_set_type(chart3, LV_CHART_TYPE_BAR);
lv_chart_set_div_line_count(chart3, 6, 0);
lv_chart_set_point_count(chart3, 7);
@ -968,7 +966,6 @@ void shop_create(lv_obj_t * parent)
lv_obj_set_width(chart3, LV_PCT(95));
lv_obj_set_height(chart3, LV_VER_RES - 70);
lv_obj_set_style_max_height(chart3, 300, 0);
// lv_chart_set_scale_x(chart3, 512);
lv_obj_set_grid_dsc_array(panel1, grid1_col_dsc, grid1_row_dsc);
lv_obj_set_grid_cell(title, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 0, 1);
@ -1187,7 +1184,7 @@ static lv_obj_t * create_scale_box(lv_obj_t * parent, const char * title, const
lv_obj_set_flex_grow(cont, 1);
lv_obj_t * title_label = lv_label_create(cont);
lv_label_set_text(title_label, title);
lv_label_set_text_static(title_label, title);
lv_obj_add_style(title_label, &style_title, 0);
lv_obj_t * scale = lv_scale_create(cont);
@ -1201,7 +1198,7 @@ static lv_obj_t * create_scale_box(lv_obj_t * parent, const char * title, const
lv_obj_add_style(bullet1, &style_bullet, 0);
lv_obj_set_style_bg_color(bullet1, lv_palette_main(LV_PALETTE_RED), 0);
lv_obj_t * label1 = lv_label_create(cont);
lv_label_set_text(label1, text1);
lv_label_set_text_static(label1, text1);
lv_obj_t * bullet2 = lv_obj_create(cont);
lv_obj_set_size(bullet2, 13, 13);
@ -1209,7 +1206,7 @@ static lv_obj_t * create_scale_box(lv_obj_t * parent, const char * title, const
lv_obj_add_style(bullet2, &style_bullet, 0);
lv_obj_set_style_bg_color(bullet2, lv_palette_main(LV_PALETTE_BLUE), 0);
lv_obj_t * label2 = lv_label_create(cont);
lv_label_set_text(label2, text2);
lv_label_set_text_static(label2, text2);
lv_obj_t * bullet3 = lv_obj_create(cont);
lv_obj_set_size(bullet3, 13, 13);
@ -1217,7 +1214,7 @@ static lv_obj_t * create_scale_box(lv_obj_t * parent, const char * title, const
lv_obj_add_style(bullet3, &style_bullet, 0);
lv_obj_set_style_bg_color(bullet3, lv_palette_main(LV_PALETTE_GREEN), 0);
lv_obj_t * label3 = lv_label_create(cont);
lv_label_set_text(label3, text3);
lv_label_set_text_static(label3, text3);
if(disp_size == DISP_MEDIUM) {
static int32_t grid_col_dsc[] = {LV_GRID_CONTENT, LV_GRID_FR(1), LV_GRID_CONTENT, LV_GRID_FR(8), LV_GRID_TEMPLATE_LAST};
@ -1266,16 +1263,16 @@ static lv_obj_t * create_shop_item(lv_obj_t * parent, const void * img_src, cons
lv_obj_t * label;
label = lv_label_create(cont);
lv_label_set_text(label, name);
lv_label_set_text_static(label, name);
lv_obj_set_grid_cell(label, LV_GRID_ALIGN_START, 2, 1, LV_GRID_ALIGN_END, 0, 1);
label = lv_label_create(cont);
lv_label_set_text(label, category);
lv_label_set_text_static(label, category);
lv_obj_add_style(label, &style_text_muted, 0);
lv_obj_set_grid_cell(label, LV_GRID_ALIGN_START, 2, 1, LV_GRID_ALIGN_START, 1, 1);
label = lv_label_create(cont);
lv_label_set_text(label, price);
lv_label_set_text_static(label, price);
lv_obj_set_grid_cell(label, LV_GRID_ALIGN_END, 3, 1, LV_GRID_ALIGN_END, 0, 1);
return cont;