diff --git a/Kconfig b/Kconfig index 595a7f84f..d72785396 100644 --- a/Kconfig +++ b/Kconfig @@ -183,6 +183,13 @@ menu "LVGL configuration" it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks. "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers and can't be drawn in chunks. + config LV_DRAW_THREAD_STACK_SIZE + int "Stack size of draw thread in bytes" + default 8192 + depends on LV_USE_OS > 0 + help + If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. + config LV_USE_DRAW_SW bool "Enable software rendering" default y @@ -197,11 +204,6 @@ menu "LVGL configuration" > 1 requires an operating system enabled in `LV_USE_OS` > 1 means multiply threads will render the screen in parallel - config LV_DRAW_THREAD_STACKSIZE - int "stack size of draw thread in byte" - default 32768 - depends on LV_USE_OS > 0 - config LV_USE_DRAW_ARM2D_SYNC bool "Enable Arm's 2D image processing library (Arm-2D) for all Cortex-M processors" default n diff --git a/lv_conf_template.h b/lv_conf_template.h index a2150738e..f46f86da0 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -113,6 +113,11 @@ /*The target buffer size for simple layer chunks.*/ #define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/ +/* The stack size of the drawing thread. + * NOTE: If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. + */ +#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /*[bytes]*/ + #define LV_USE_DRAW_SW 1 #if LV_USE_DRAW_SW == 1 /* Set the number of draw unit. @@ -150,9 +155,6 @@ #endif #endif -/* Set stack size of drawing thread. Unit is byte. If Thorvg is enabled, 128kB is required tested on simulator.*/ -#define LV_DRAW_THREAD_STACKSIZE 32768 - /* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ #define LV_USE_DRAW_VGLITE 0 diff --git a/scripts/lv_conf_internal_gen.py b/scripts/lv_conf_internal_gen.py index 0769625a6..ec823eb0b 100755 --- a/scripts/lv_conf_internal_gen.py +++ b/scripts/lv_conf_internal_gen.py @@ -197,6 +197,17 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN); #define LV_USE_THORVG (LV_USE_THORVG_INTERNAL || LV_USE_THORVG_EXTERNAL) #endif +#if LV_USE_OS + #if (LV_USE_FREETYPE || LV_USE_THORVG) && LV_DRAW_THREAD_STACK_SIZE < (32 * 1024) + #warning "Increase LV_DRAW_THREAD_STACK_SIZE to at least 32KB for FreeType or ThorVG." + #endif + + #if defined(LV_DRAW_THREAD_STACKSIZE) && !defined(LV_DRAW_THREAD_STACK_SIZE) + #warning "LV_DRAW_THREAD_STACKSIZE was renamed to LV_DRAW_THREAD_STACK_SIZE. Please update lv_conf.h or run menuconfig again." + #define LV_DRAW_THREAD_STACK_SIZE LV_DRAW_THREAD_STACKSIZE + #endif +#endif + /*If running without lv_conf.h add typedefs with default value*/ #ifdef LV_CONF_SKIP #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/ diff --git a/src/draw/sw/lv_draw_sw.c b/src/draw/sw/lv_draw_sw.c index fc4025c25..5960c6e37 100644 --- a/src/draw/sw/lv_draw_sw.c +++ b/src/draw/sw/lv_draw_sw.c @@ -143,7 +143,7 @@ void lv_draw_sw_init(void) draw_sw_unit->base_unit.delete_cb = LV_USE_OS ? lv_draw_sw_delete : NULL; #if LV_USE_OS - lv_thread_init(&draw_sw_unit->thread, LV_THREAD_PRIO_HIGH, render_thread_cb, LV_DRAW_THREAD_STACKSIZE, draw_sw_unit); + lv_thread_init(&draw_sw_unit->thread, LV_THREAD_PRIO_HIGH, render_thread_cb, LV_DRAW_THREAD_STACK_SIZE, draw_sw_unit); #endif } diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index d464a92b3..edf6507a5 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -305,6 +305,17 @@ #endif #endif +/* The stack size of the drawing thread. + * NOTE: If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. + */ +#ifndef LV_DRAW_THREAD_STACK_SIZE + #ifdef CONFIG_LV_DRAW_THREAD_STACK_SIZE + #define LV_DRAW_THREAD_STACK_SIZE CONFIG_LV_DRAW_THREAD_STACK_SIZE + #else + #define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /*[bytes]*/ + #endif +#endif + #ifndef LV_USE_DRAW_SW #ifdef _LV_KCONFIG_PRESENT #ifdef CONFIG_LV_USE_DRAW_SW @@ -408,15 +419,6 @@ #endif #endif -/* Set stack size of drawing thread. Unit is byte. If Thorvg is enabled, 128kB is required tested on simulator.*/ -#ifndef LV_DRAW_THREAD_STACKSIZE - #ifdef CONFIG_LV_DRAW_THREAD_STACKSIZE - #define LV_DRAW_THREAD_STACKSIZE CONFIG_LV_DRAW_THREAD_STACKSIZE - #else - #define LV_DRAW_THREAD_STACKSIZE 32768 - #endif -#endif - /* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ #ifndef LV_USE_DRAW_VGLITE #ifdef CONFIG_LV_USE_DRAW_VGLITE @@ -3314,6 +3316,17 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN); #define LV_USE_THORVG (LV_USE_THORVG_INTERNAL || LV_USE_THORVG_EXTERNAL) #endif +#if LV_USE_OS + #if (LV_USE_FREETYPE || LV_USE_THORVG) && LV_DRAW_THREAD_STACK_SIZE < (32 * 1024) + #warning "Increase LV_DRAW_THREAD_STACK_SIZE to at least 32KB for FreeType or ThorVG." + #endif + + #if defined(LV_DRAW_THREAD_STACKSIZE) && !defined(LV_DRAW_THREAD_STACK_SIZE) + #warning "LV_DRAW_THREAD_STACKSIZE was renamed to LV_DRAW_THREAD_STACK_SIZE. Please update lv_conf.h or run menuconfig again." + #define LV_DRAW_THREAD_STACK_SIZE LV_DRAW_THREAD_STACKSIZE + #endif +#endif + /*If running without lv_conf.h add typedefs with default value*/ #ifdef LV_CONF_SKIP #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/ diff --git a/tests/src/lv_test_conf_full.h b/tests/src/lv_test_conf_full.h index c1ed2f1b1..ab1c1a04f 100644 --- a/tests/src/lv_test_conf_full.h +++ b/tests/src/lv_test_conf_full.h @@ -1,6 +1,6 @@ #define LV_MEM_SIZE (32 * 1024 * 1024) #define LV_DRAW_SW_SHADOW_CACHE_SIZE 8 -#define LV_DRAW_THREAD_STACKSIZE (128 * 1024) /*Increase stack size to 128kB in order to run Thorvg*/ +#define LV_DRAW_THREAD_STACK_SIZE (64 * 1024) /*Increase stack size to 64KB in order to run ThorVG*/ #define LV_USE_LOG 1 #define LV_LOG_LEVEL LV_LOG_LEVEL_TRACE #define LV_LOG_PRINTF 1