From c81184db454baaec809ed991a1f30a6df4b41855 Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Tue, 20 Feb 2024 09:34:46 +0800 Subject: [PATCH] feat(decoder): do not even try cache if 'no_cache' is set (#5688) Signed-off-by: Xu Xingliang --- src/draw/lv_image_decoder.c | 11 +++++++---- src/draw/lv_image_decoder.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/draw/lv_image_decoder.c b/src/draw/lv_image_decoder.c index 0c96d255d..c1d58558a 100644 --- a/src/draw/lv_image_decoder.c +++ b/src/draw/lv_image_decoder.c @@ -123,10 +123,13 @@ lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src #if LV_CACHE_DEF_SIZE > 0 dsc->cache = img_cache_p; - /* - * Check the cache first - * If the image is found in the cache, just return it.*/ - if(try_cache(dsc) == LV_RESULT_OK) return LV_RESULT_OK; + /*Try cache first, unless we are told to ignore cache.*/ + if(!(args && args->no_cache)) { + /* + * Check the cache first + * If the image is found in the cache, just return it.*/ + if(try_cache(dsc) == LV_RESULT_OK) return LV_RESULT_OK; + } #endif /*Find the decoder that can open the image source, and get the header info in the same time.*/ diff --git a/src/draw/lv_image_decoder.h b/src/draw/lv_image_decoder.h index a8cd0d4d4..d446eacdf 100644 --- a/src/draw/lv_image_decoder.h +++ b/src/draw/lv_image_decoder.h @@ -61,7 +61,7 @@ typedef struct _lv_image_decoder_dsc_t lv_image_decoder_dsc_t; typedef struct _lv_image_decoder_args_t { bool stride_align; /*Whether stride should be aligned*/ bool premultiply; /*Whether image should be premultiplied or not after decoding*/ - bool no_cache; /*Whether this image should be kept out of cache*/ + bool no_cache; /*When set, decoded image won't be put to cache, and decoder open will also ignore cache.*/ bool use_indexed; /*Decoded indexed image as is. Convert to ARGB8888 if false.*/ } lv_image_decoder_args_t;