From ca95d76659b34e246099e27ef10b7762274d6f8f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 22 Mar 2018 10:09:00 +0100 Subject: [PATCH] lv_conf.h: add LV_COMPILER_VLA_SUPPORTED --- lv_conf_templ.h | 7 +++--- lv_draw/lv_draw.c | 51 ++++++++++++++++++++++++++++++++++++--- lv_themes/lv_theme_mono.c | 2 +- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/lv_conf_templ.h b/lv_conf_templ.h index 9080437bc..fd4618211 100644 --- a/lv_conf_templ.h +++ b/lv_conf_templ.h @@ -81,9 +81,10 @@ #define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/ #define USE_LV_FILESYSTEM 1 /*1: Enable file system (required by images*/ -/*Compiler attributes*/ -#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to tick increment function */ -#define LV_ATTRIBUTE_TASK_HANDLER +/*Compiler settings*/ +#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */ +#define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */ +#define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/ /*================ * THEME USAGE diff --git a/lv_draw/lv_draw.c b/lv_draw/lv_draw.c index b6c9108d1..186d82edf 100644 --- a/lv_draw/lv_draw.c +++ b/lv_draw/lv_draw.c @@ -448,7 +448,15 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, lv_coord_t row; uint32_t act_pos; +#if LV_COMPILER_VLA_SUPPORTED lv_color_t buf[lv_area_get_width(&mask_com)]; +#else +# if LV_HOR_RES > LV_VER_RES + lv_color_t buf[LV_HOR_RES]; +# else + lv_color_t buf[LV_VER_RES]; +# endif +#endif for(row = mask_com.y1; row <= mask_com.y2; row ++) { res = lv_fs_read(&file, buf, useful_data, &br); @@ -1713,8 +1721,15 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask if(radius != 0) radius -= LV_ANTIALIAS; swidth += LV_ANTIALIAS; - +#if LV_COMPILER_VLA_SUPPORTED lv_coord_t curve_x[radius + swidth + 1]; /*Stores the 'x' coordinates of a quarter circle.*/ +#else +# if LV_HOR_RES > LV_VER_RES + lv_coord_t curve_x[LV_HOR_RES]; +# else + lv_coord_t curve_x[LV_VER_RES]; +# endif +#endif memset(curve_x, 0, sizeof(curve_x)); lv_point_t circ; lv_coord_t circ_tmp; @@ -1727,15 +1742,30 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask int16_t line; int16_t filter_width = 2 * swidth + 1; +#if LV_COMPILER_VLA_SUPPORTED uint32_t line_1d_blur[filter_width]; - +#else +# if LV_HOR_RES > LV_VER_RES + uint32_t line_1d_blur[LV_HOR_RES]; +# else + uint32_t line_1d_blur[LV_VER_RES]; +# endif +#endif /*1D Blur horizontally*/ for(line = 0; line < filter_width; line++) { line_1d_blur[line] = (uint32_t)((uint32_t)(filter_width - line) * (style->body.opa * 2) << SHADOW_OPA_EXTRA_PRECISION) / (filter_width * filter_width); } uint16_t col; +#if LV_COMPILER_VLA_SUPPORTED lv_opa_t line_2d_blur[radius + swidth]; +#else +# if LV_HOR_RES > LV_VER_RES + lv_opa_t line_2d_blur[LV_HOR_RES]; +# else + lv_opa_t line_2d_blur[LV_VER_RES]; +# endif +#endif lv_point_t point_rt; lv_point_t point_rb; @@ -1845,8 +1875,15 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma radius = lv_draw_cont_radius_corr(radius, width, height); radius += LV_ANTIALIAS * SHADOW_BOTTOM_AA_EXTRA_RADIUS; swidth += LV_ANTIALIAS; - +#if LV_COMPILER_VLA_SUPPORTED lv_coord_t curve_x[radius + 1]; /*Stores the 'x' coordinates of a quarter circle.*/ +#else +# if LV_HOR_RES > LV_VER_RES + lv_coord_t curve_x[LV_HOR_RES]; +# else + lv_coord_t curve_x[LV_VER_RES]; +# endif +#endif lv_point_t circ; lv_coord_t circ_tmp; lv_circ_init(&circ, &circ_tmp, radius); @@ -1857,7 +1894,15 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma } int16_t col; + #if LV_COMPILER_VLA_SUPPORTED lv_opa_t line_1d_blur[swidth]; +#else +# if LV_HOR_RES > LV_VER_RES + lv_opa_t line_1d_blur[LV_HOR_RES]; +# else + lv_opa_t line_1d_blur[LV_VER_RES]; +# endif +#endif for(col = 0; col < swidth; col++) { line_1d_blur[col] = (uint32_t)((uint32_t)(swidth - col) * style->body.opa / 2) / (swidth); diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index aedd79b1f..4fc020381 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -456,7 +456,7 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t *font) * Get a pointer to the theme * @return pointer to the theme */ -lv_theme_t * lv_theme_get_templ(void) +lv_theme_t * lv_theme_get_mono(void) { return &theme; }