1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_draw: use Variable Length Arrays

This commit is contained in:
Gabor Kiss-Vamosi 2017-12-06 09:48:52 +01:00
parent 1060e3c25a
commit 2cf7ed0d26
5 changed files with 22 additions and 23 deletions

View File

@ -28,12 +28,10 @@
/* Horizontal and vertical resolution of the library.
* Screen resolution multiplied by LV_DOWN_SCALE*/
#define LV_HOR_RES (800 << LV_ANTIALIAS)
#define LV_VER_RES (480 << LV_ANTIALIAS)
#define LV_DPI (100 << LV_ANTIALIAS)
/* Buffered rendering: >= LV_HOR_RES or 0 to disable buffering*/
#define LV_VDB_SIZE (40 * LV_HOR_RES)
/* Buffered rendering: >= lv_disp_hor_res() or 0 to disable buffering*/
#define LV_VDB_SIZE (40 * lv_disp_hor_res())
#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate into RAM)*/
/* Use two Virtual Display buffers (VDB) parallelize rendering and flushing

View File

@ -422,7 +422,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
lv_coord_t row;
uint32_t act_pos;
lv_color_t buf[LV_HOR_RES];
lv_color_t buf[useful_data];
for(row = mask_com.y1; row <= mask_com.y2; row += us_val) {
res = lv_fs_read(&file, buf, useful_data, &br);
@ -1167,6 +1167,7 @@ static void lv_draw_rect_shadow(const lv_area_t * coords, const lv_area_t * mask
static void lv_draw_cont_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
{
lv_coord_t radius = style->body.radius;
lv_coord_t width = lv_area_get_width(coords);
@ -1174,7 +1175,7 @@ static void lv_draw_cont_shadow_full(const lv_area_t * coords, const lv_area_t *
radius = lv_draw_cont_radius_corr(radius, width, height);
lv_coord_t cruve_x[LV_VER_RES] = {LV_COORD_MIN};
lv_coord_t cruve_x[radius + style->body.shadow.width]; /*Stores the 'x' coordinates of a quarter circle.*/
memset(cruve_x, 0, sizeof(cruve_x));
lv_point_t circ;
lv_coord_t circ_tmp;
@ -1186,16 +1187,15 @@ static void lv_draw_cont_shadow_full(const lv_area_t * coords, const lv_area_t *
}
int16_t row;
uint16_t opa_h_result[LV_HOR_RES];
int16_t filter_size = 2 * style->body.shadow.width + 1;
uint16_t opa_h_result[filter_size];
/*TODO recalculate only values are changed*/
for(row = 0; row < filter_size; row++) {
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->body.opa * 2) / (filter_size);
}
uint16_t p;
lv_opa_t opa_v_result[LV_VER_RES];
lv_opa_t opa_v_result[radius + style->body.shadow.width];
lv_point_t point_rt;
lv_point_t point_rb;
@ -1217,7 +1217,6 @@ static void lv_draw_cont_shadow_full(const lv_area_t * coords, const lv_area_t *
ofs_lt.x = coords->x1 + radius;
ofs_lt.y = coords->y1 + radius;
for(row = 0; row < radius + style->body.shadow.width; row++) {
for(p = 0; p < radius + style->body.shadow.width; p++) {
int16_t v;
@ -1315,7 +1314,7 @@ static void lv_draw_cont_shadow_bottom(const lv_area_t * coords, const lv_area_t
radius = lv_draw_cont_radius_corr(radius, width, height);
lv_coord_t cruve_x[LV_VER_RES]; /* TODO Removed = {CORD_MIN};*/
lv_coord_t cruve_x[radius + style->body.shadow.width]; /*Stores the 'x' coordinates of a quarter circle.*/
memset(cruve_x, 0, sizeof(cruve_x));
lv_point_t circ;
lv_coord_t circ_tmp;
@ -1327,8 +1326,8 @@ static void lv_draw_cont_shadow_bottom(const lv_area_t * coords, const lv_area_t
}
int16_t row;
lv_opa_t opa_h_result[LV_HOR_RES];
int16_t filter_size = 2 * style->body.shadow.width + 1;
lv_opa_t opa_h_result[filter_size];
for(row = 0; row < filter_size; row++) {
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->body.opa) / (filter_size);

View File

@ -76,7 +76,7 @@ void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
union_ok = lv_area_union(&masked_area, cords_p, mask_p);
} else {
lv_area_t scr_area;
lv_area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_VER_RES - 1);
lv_area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_HOR_RES - 1);
union_ok = lv_area_union(&masked_area, cords_p, &scr_area);
}

View File

@ -50,7 +50,6 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
* GLOBAL FUNCTIONS
**********************/
/**
* Put a pixel in the Virtual Display Buffer
* @param x pixel x coordinate
@ -95,9 +94,8 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t color, lv_opa_t opa)
{
/*Used to store color maps for blending*/
static lv_color_t color_map[LV_HOR_RES];
static lv_coord_t last_width = 0;
static lv_color_t color_array_tmp[LV_VER_RES]; /*Used by 'sw_color_fill'*/
static lv_coord_t last_width = -1;
lv_area_t res_a;
bool union_ok;
@ -142,16 +140,16 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT &&
lv_disp_is_mem_blend_supported())
{
if(color_map[0].full != color.full || last_width != w) {
if(color_array_tmp[0].full != color.full || last_width != w) {
uint16_t i;
for(i = 0; i < w; i++) {
color_map[i].full = color.full;
color_array_tmp[i].full = color.full;
}
last_width = w;
}
lv_coord_t row;
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_map, w, opa);
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
vdb_buf_tmp += vdb_width;
}
@ -165,17 +163,17 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
else {
/*Use hw blend if present*/
if(lv_disp_is_mem_blend_supported()) {
if(color_map[0].full != color.full || last_width != w) {
if(color_array_tmp[0].full != color.full || last_width != w) {
uint16_t i;
for(i = 0; i < w; i++) {
color_map[i].full = color.full;
color_array_tmp[i].full = color.full;
}
last_width = w;
}
lv_coord_t row;
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_map, w, opa);
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
vdb_buf_tmp += vdb_width;
}

View File

@ -73,6 +73,10 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_color_t recolor, lv_opa_t recolor_opa);
/**
* Reallocate 'color_map_tmp' to the new hor. res. size. It is used in 'sw_fill'
*/
void lv_vdraw_refresh_temp_arrays(void);
/**********************
* MACROS