fix(decoder): do not put image to cache if args say no (#5111)
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
@@ -386,6 +386,8 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
break;
|
||||
}
|
||||
|
||||
if(dsc->args.no_cache) return LV_RES_OK;
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
if(res == LV_RESULT_OK) {
|
||||
lv_image_cache_data_t search_key;
|
||||
@@ -421,11 +423,10 @@ static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t *
|
||||
{
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
#else
|
||||
decoder_draw_buf_free((lv_draw_buf_t *)dsc->decoded);
|
||||
#endif
|
||||
if(dsc->args.no_cache || LV_CACHE_DEF_SIZE == 0)
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
else
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
}
|
||||
|
||||
static void decoder_cache_free(lv_image_cache_data_t * cached_data, void * user_data)
|
||||
|
||||
@@ -302,7 +302,7 @@ lv_result_t lv_bin_decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
}
|
||||
dsc->decoded = adjusted;
|
||||
|
||||
if(use_directly) return LV_RESULT_OK; /*Do not put image to cache if it can be used directly.*/
|
||||
if(use_directly || dsc->args.no_cache) return LV_RESULT_OK; /*Do not put image to cache if it can be used directly.*/
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
|
||||
|
||||
@@ -162,6 +162,8 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
|
||||
dsc->decoded = decoded;
|
||||
|
||||
if(dsc->args.no_cache) return LV_RES_OK;
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_image_cache_data_t search_key;
|
||||
search_key.src_type = dsc->src_type;
|
||||
@@ -189,11 +191,10 @@ static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t *
|
||||
{
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
#else
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
#endif
|
||||
if(dsc->args.no_cache || LV_CACHE_DEF_SIZE == 0)
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
else
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
}
|
||||
|
||||
static uint8_t * alloc_file(const char * filename, uint32_t * size)
|
||||
|
||||
@@ -153,6 +153,8 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
|
||||
dsc->decoded = decoded;
|
||||
|
||||
if(dsc->args.no_cache) return LV_RES_OK;
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_image_cache_data_t search_key;
|
||||
search_key.src_type = dsc->src_type;
|
||||
@@ -180,11 +182,10 @@ static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t *
|
||||
{
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
#else
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
#endif
|
||||
if(dsc->args.no_cache || LV_CACHE_DEF_SIZE == 0)
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
else
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
}
|
||||
|
||||
static uint8_t * alloc_file(const char * filename, uint32_t * size)
|
||||
|
||||
@@ -212,6 +212,8 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
|
||||
dsc->decoded = decoded;
|
||||
|
||||
if(dsc->args.no_cache) return LV_RES_OK;
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_image_cache_data_t search_key;
|
||||
search_key.src_type = dsc->src_type;
|
||||
@@ -239,11 +241,10 @@ static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t *
|
||||
{
|
||||
LV_UNUSED(decoder);
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
#else
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
#endif
|
||||
if(dsc->args.no_cache || LV_CACHE_DEF_SIZE == 0)
|
||||
lv_draw_buf_destroy((lv_draw_buf_t *)dsc->decoded);
|
||||
else
|
||||
lv_cache_release(dsc->cache, dsc->cache_entry, NULL);
|
||||
}
|
||||
|
||||
static lv_draw_buf_t * decode_png_data(const void * png_data, size_t png_data_size)
|
||||
|
||||
Reference in New Issue
Block a user