diff --git a/src/misc/cache/lv_image_cache.c b/src/misc/cache/lv_image_cache.c index 728224669..61969e0f7 100644 --- a/src/misc/cache/lv_image_cache.c +++ b/src/misc/cache/lv_image_cache.c @@ -13,6 +13,7 @@ * DEFINES *********************/ #define img_cache_p (LV_GLOBAL_DEFAULT()->img_cache) +#define img_header_cache_p (LV_GLOBAL_DEFAULT()->img_header_cache) /********************** * TYPEDEFS **********************/ @@ -38,6 +39,9 @@ **********************/ void lv_image_cache_drop(const void * src) { + /*If user invalidate image, the header cache should be invalidated too.*/ + lv_image_header_cache_drop(src); + #if LV_CACHE_DEF_SIZE > 0 if(src == NULL) { lv_cache_drop_all(img_cache_p, NULL); @@ -54,6 +58,26 @@ void lv_image_cache_drop(const void * src) LV_UNUSED(src); #endif } + +void lv_image_header_cache_drop(const void * src) +{ +#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0 + if(src == NULL) { + lv_cache_drop_all(img_header_cache_p, NULL); + return; + } + + lv_image_header_cache_data_t search_key = { + .src = src, + .src_type = lv_image_src_get_type(src), + }; + + lv_cache_drop(img_header_cache_p, &search_key, NULL); +#else + LV_UNUSED(src); +#endif +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/misc/cache/lv_image_cache.h b/src/misc/cache/lv_image_cache.h index 3b23b3dfb..4c4f4eb0f 100644 --- a/src/misc/cache/lv_image_cache.h +++ b/src/misc/cache/lv_image_cache.h @@ -26,7 +26,20 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ + +/** + * Invalidate image cache. Use NULL to invalidate all images. + * @param src pointer to an image source. + */ void lv_image_cache_drop(const void * src); + +/** + * Invalidate image header cache. Use NULL to invalidate all image headers. + * It's also automatically called when an image is invalidated. + * @param src pointer to an image source. + */ +void lv_image_header_cache_drop(const void * src); + /************************* * GLOBAL VARIABLES *************************/