feat(vg_lite): add grad cache size config and auto release cache (#5731)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
_VIFEXTech
2024-03-04 10:17:04 +08:00
committed by GitHub
parent 54198c925b
commit 133aee3fca
4 changed files with 30 additions and 2 deletions

View File

@@ -389,6 +389,13 @@ menu "LVGL configuration"
which usually improves performance,
but does not guarantee the same rendering quality as the software.
config LV_VG_LITE_GRAD_CACHE_SIZE
int "VG-Lite gradient image maximum cache number."
default 32
depends on LV_USE_DRAW_VG_LITE
help
The memory usage of a single gradient image is 4K bytes.
config LV_USE_GPU_SDL
bool "Use SDL renderer API"
default n

View File

@@ -187,6 +187,11 @@
* but does not guarantee the same rendering quality as the software. */
#define LV_VG_LITE_USE_BOX_SHADOW 0
/* VG-Lite gradient image maximum cache number.
* NOTE: The memory usage of a single gradient image is 4K bytes.
*/
#define LV_VG_LITE_GRAD_CACHE_SIZE 32
#endif
/*=======================

View File

@@ -17,8 +17,6 @@
* DEFINES
*********************/
#define LV_VG_LITE_GRAD_CACHE_SIZE 16
/**********************
* TYPEDEFS
**********************/
@@ -180,6 +178,13 @@ static vg_lite_linear_gradient_t * lv_vg_lite_linear_grad_get(struct _lv_draw_vg
lv_cache_entry_t * cache_node_entry = lv_cache_acquire(u->grad_cache, &search_key, NULL);
if(cache_node_entry == NULL) {
/* check if the cache is full */
size_t free_size = lv_cache_get_free_size(u->grad_cache, NULL);
if(free_size == 0) {
LV_LOG_INFO("grad cache is full, release all pending cache entries");
lv_vg_lite_finish(u);
}
cache_node_entry = lv_cache_acquire_or_create(u->grad_cache, &search_key, NULL);
if(cache_node_entry == NULL) {
LV_LOG_ERROR("grad cache creating failed");

View File

@@ -495,6 +495,17 @@
#endif
#endif
/* VG-Lite gradient image maximum cache number.
* NOTE: The memory usage of a single gradient image is 4K bytes.
*/
#ifndef LV_VG_LITE_GRAD_CACHE_SIZE
#ifdef CONFIG_LV_VG_LITE_GRAD_CACHE_SIZE
#define LV_VG_LITE_GRAD_CACHE_SIZE CONFIG_LV_VG_LITE_GRAD_CACHE_SIZE
#else
#define LV_VG_LITE_GRAD_CACHE_SIZE 32
#endif
#endif
#endif
/*=======================