fix(refresh): do not redraw the whole object if only part's style changes on a new state

This commit is contained in:
Gabor Kiss-Vamosi
2021-03-19 16:01:26 +01:00
parent ac3fa78718
commit 666653efe7
11 changed files with 26 additions and 17 deletions

View File

@@ -76,27 +76,27 @@ void lv_port_disp_init(void)
*/
/* Example for 1) */
static lv_draw_buf_t draw_buf_dsc_1;
static lv_disp_draw_buf_t draw_buf_dsc_1;
static lv_color_t buf_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
lv_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
/* Example for 2) */
static lv_draw_buf_t draw_buf_dsc_2;
static lv_disp_draw_buf_t draw_buf_dsc_2;
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; /*An other buffer for 10 rows*/
lv_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_1, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_1, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
/* Example for 3) */
static lv_draw_buf_t draw_buf_dsc_3;
static lv_disp_draw_buf_t draw_buf_dsc_3;
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*A screen sized buffer*/
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*An other screen sized buffer*/
lv_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES * LV_VER_RES_MAX); /*Initialize the display buffer*/
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES * LV_VER_RES_MAX); /*Initialize the display buffer*/
/*-----------------------------------
* Register the display in LVGL
*----------------------------------*/
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
/*Set up the functions to access to your display*/

View File

@@ -84,7 +84,7 @@ void lv_port_fs_init(void)
*--------------------------------------------------*/
/*Add a simple drive to open images*/
lv_fs_drv_t fs_drv;
static lv_fs_drv_t fs_drv;
lv_fs_drv_init(&fs_drv);
/*Set up fields...*/

View File

@@ -80,7 +80,7 @@ void lv_port_indev_init(void)
* You should shape them according to your hardware
*/
lv_indev_drv_t indev_drv;
static lv_indev_drv_t indev_drv;
/*------------------
* Touchpad

View File

@@ -18,10 +18,13 @@ static void btnm_event_handler(lv_obj_t * obj, lv_event_t event)
void lv_example_textarea_1(void)
{
lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL);
// lv_textarea_set_one_line(ta, true);
lv_textarea_set_text(ta, "asd");
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/
// lv_obj_set_style_text_align(ta, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER);
lv_obj_set_style_text_align(lv_textarea_get_label(ta), LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER);
static const char * btnm_map[] = {"1", "2", "3", "\n",
"4", "5", "6", "\n",
"7", "8", "9", "\n",

View File

@@ -4,7 +4,7 @@
*/
#ifndef LV_OBJ_STYLE_H
#define LV_OB_STYLE_H
#define LV_OBJ_STYLE_H
#ifdef __cplusplus
extern "C" {

View File

@@ -671,7 +671,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
lv_color_t * color_buf = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp);
lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp);
int32_t disp_buf_width = lv_area_get_width(&draw_buf->area);
lv_color_t * disp_buf_buf_tmp = draw_buf->buf_act;

View File

@@ -92,6 +92,9 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
/*Handle compressed bitmap*/
else {
#if LV_USE_FONT_COMPRESSED
static size_t last_buf_size = 0;
if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) last_buf_size = 0;
uint32_t gsize = gdsc->box_w * gdsc->box_h;
if(gsize == 0) return NULL;
@@ -112,11 +115,12 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
break;
}
if(lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) {
if(last_buf_size < buf_size) {
uint8_t * tmp = lv_mem_realloc(LV_GC_ROOT(_lv_font_decompr_buf), buf_size);
LV_ASSERT_MALLOC(tmp);
if(tmp == NULL) return NULL;
LV_GC_ROOT(_lv_font_decompr_buf) = tmp;
last_buf_size = buf_size;
}
bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false;

View File

@@ -66,7 +66,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
/**
* Initialize a display buffer
* @param draw_buf pointer `lv_draw_buf_t` variable to initialize
* @param draw_buf pointer `lv_disp_draw_buf_t` variable to initialize
* @param buf1 A buffer to be used by LVGL to draw the image.
* Always has to specified and can't be NULL.
* Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]`

View File

@@ -194,7 +194,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver);
/**
* Initialize a display buffer
* @param draw_buf pointer `lv_draw_buf_t` variable to initialize
* @param draw_buf pointer `lv_disp_draw_buf_t` variable to initialize
* @param buf1 A buffer to be used by LVGL to draw the image.
* Always has to specified and can't be NULL.
* Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]`

View File

@@ -203,7 +203,7 @@ typedef enum {
LV_STYLE_TEXT_LETTER_SPACE = 90 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TEXT_LINE_SPACE = 91 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TEXT_DECOR = 92 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR,
/*Group 6*/
LV_STYLE_CONTENT_TEXT = 96 | LV_STYLE_PROP_EXT_DRAW,

View File

@@ -127,6 +127,7 @@ minimal_16bit_swap = {
"LV_FONT_UNSCII_8":1,
"LV_USE_FONT_SUBPX": 1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
@@ -147,6 +148,7 @@ full_32bit = {
"LV_USE_LOG":1,
"LV_LOG_PRINTF":1,
"LV_USE_FONT_SUBPX": 1,
"LV_FONT_SUBPX_BGR":1,
"LV_USE_PERF_MONITOR":1,
@@ -188,7 +190,7 @@ full_32bit = {
"LV_FONT_UNSCII_8":1,
"LV_FONT_UNSCII_16":1,
"LV_FONT_FMT_TXT_LARGE":1,
"LV_FONT_FMT_TXT_LARGE":1,
"LV_USE_FONT_COMPRESSED":1,
"LV_USE_BIDI": 1,
"LV_USE_ARABIC_PERSIAN_CHARS":1,