1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00
This commit is contained in:
Gabor Kiss-Vamosi 2019-06-26 16:50:10 +02:00
parent f806f8c526
commit ce29102dcf
6 changed files with 22 additions and 19 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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);

View File

@ -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)*/

View File

@ -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) {