diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 7bdb3022b..b681e76e1 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -14,7 +14,7 @@ #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_mem.h" #include "../lv_misc/lv_gc.h" -#include "../lv_draw/lv_draw_basic.h" +#include "../lv_draw/lv_draw.h" #if defined(LV_GC_INCLUDE) #include LV_GC_INCLUDE diff --git a/src/lv_draw/lv_draw.c b/src/lv_draw/lv_draw.c index dd8e0ebc5..8057ba326 100644 --- a/src/lv_draw/lv_draw.c +++ b/src/lv_draw/lv_draw.c @@ -38,6 +38,11 @@ static uint32_t draw_buf_size = 0; * GLOBAL FUNCTIONS **********************/ +/** + * Give a buffer with the given to use during drawing. + * Be careful to not use the buffer while other processes are using it. + * @param size the required size + */ void * lv_draw_get_buf(uint32_t size) { if(size <= draw_buf_size) return draw_buf; @@ -58,6 +63,9 @@ void * lv_draw_get_buf(uint32_t size) return draw_buf; } +/** + * Free the draw buffer + */ void lv_draw_free_buf(void) { if(draw_buf) { diff --git a/src/lv_draw/lv_draw.h b/src/lv_draw/lv_draw.h index 0cec906e7..a9fa58d91 100644 --- a/src/lv_draw/lv_draw.h +++ b/src/lv_draw/lv_draw.h @@ -35,8 +35,16 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ +/** + * Give a buffer with the given to use during drawing. + * Be careful to not use the buffer while other processes are using it. + * @param size the required size + */ void * lv_draw_get_buf(uint32_t size); +/** + * Free the draw buffer + */ void lv_draw_free_buf(void); #if LV_ANTIALIAS diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 6185863e1..a4307d295 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -469,11 +469,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas else { lv_coord_t width = lv_area_get_width(&mask_com); -#if LV_COMPILER_VLA_SUPPORTED - uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))]; -#else - uint8_t buf[LV_HOR_RES_MAX * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/ -#endif + uint8_t * buf = lv_draw_get_buf(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1)); /*+1 because of the possible alpha byte*/ + lv_area_t line; lv_area_copy(&line, &mask_com); lv_area_set_height(&line, 1); diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 2f367d546..8e7f3d097 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -265,11 +265,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ /* The pattern stores the points of the line ending. It has the good direction and length. * The worth case is the 45° line where pattern can have 1.41 x `width` points*/ -#if LV_COMPILER_VLA_SUPPORTED - lv_point_t pattern[width * 2]; -#else - lv_point_t pattern[LINE_MAX_WIDTH]; -#endif + + lv_point_t * pattern = lv_draw_get_buf(width * 2 * sizeof(lv_point_t)); lv_coord_t i = 0; /*Create a perpendicular pattern (a small line)*/ diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 3215b61b5..1969a2ec9 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -568,12 +568,9 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l #if LV_USE_FILESYSTEM lv_img_decoder_built_in_data_t * user_data = dsc->user_data; -#if LV_COMPILER_VLA_SUPPORTED - uint8_t fs_buf[w]; -#else uint8_t fs_buf[LV_HOR_RES_MAX]; #endif -#endif + const uint8_t * data_tmp = NULL; if(dsc->src_type == LV_IMG_SRC_VARIABLE) { const lv_img_dsc_t * img_dsc = dsc->src; @@ -658,11 +655,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_img_decoder_built_in_data_t * user_data = dsc->user_data; #if LV_USE_FILESYSTEM -#if LV_COMPILER_VLA_SUPPORTED - uint8_t fs_buf[w]; -#else uint8_t fs_buf[LV_HOR_RES_MAX]; -#endif #endif const uint8_t * data_tmp = NULL; if(dsc->src_type == LV_IMG_SRC_VARIABLE) {