mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-23 07:46:36 +08:00
fix(bin_decoder): fix the crash when decoder A8 images and flush cache (#7952)
Signed-off-by: yushuailong <yushuailong1@xiaomi.com>
This commit is contained in:
@@ -279,21 +279,14 @@ lv_result_t lv_bin_decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
res = decode_indexed(decoder, dsc);
|
||||
}
|
||||
}
|
||||
else if(LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf)) {
|
||||
if(cf == LV_COLOR_FORMAT_A8) {
|
||||
res = LV_RESULT_OK;
|
||||
use_directly = true;
|
||||
dsc->decoded = (lv_draw_buf_t *)image;
|
||||
else if(LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf) && cf != LV_COLOR_FORMAT_A8) {
|
||||
/*Alpha only image will need decoder data to store pointer to decoded image, to free it when decoder closes*/
|
||||
decoder_data_t * decoder_data = get_decoder_data(dsc);
|
||||
if(decoder_data == NULL) {
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
else {
|
||||
/*Alpha only image will need decoder data to store pointer to decoded image, to free it when decoder closes*/
|
||||
decoder_data_t * decoder_data = get_decoder_data(dsc);
|
||||
if(decoder_data == NULL) {
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
res = decode_alpha_only(decoder, dsc);
|
||||
}
|
||||
res = decode_alpha_only(decoder, dsc);
|
||||
}
|
||||
else {
|
||||
/*In case of uncompressed formats the image stored in the ROM/RAM.
|
||||
|
||||
@@ -160,4 +160,53 @@ void test_bin_decoder_image_dsc_error_handling(void)
|
||||
bin_decoder(NULL, "libs/bin_decoder_empty_image.png");
|
||||
}
|
||||
|
||||
void test_bin_decoder_flush_cache(void)
|
||||
{
|
||||
#if LV_BIN_DECODER_RAM_LOAD == 1
|
||||
LV_IMAGE_DECLARE(test_I1_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_I2_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_I4_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_I8_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_A1_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_A2_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_A4_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_A8_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_RGB565A8_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_RGB565_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_RGB888_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_XRGB8888_NONE_align64);
|
||||
LV_IMAGE_DECLARE(test_ARGB8888_NONE_align64);
|
||||
|
||||
const lv_image_dsc_t * img_dscs[] = {
|
||||
&test_I1_NONE_align64,
|
||||
&test_I2_NONE_align64,
|
||||
&test_I4_NONE_align64,
|
||||
&test_I8_NONE_align64,
|
||||
&test_A1_NONE_align64,
|
||||
&test_A2_NONE_align64,
|
||||
&test_A4_NONE_align64,
|
||||
&test_A8_NONE_align64,
|
||||
&test_RGB565A8_NONE_align64,
|
||||
&test_RGB565_NONE_align64,
|
||||
&test_RGB888_NONE_align64,
|
||||
&test_XRGB8888_NONE_align64,
|
||||
&test_ARGB8888_NONE_align64,
|
||||
};
|
||||
const lv_image_decoder_args_t args = {
|
||||
.no_cache = true,
|
||||
.premultiply = false,
|
||||
.stride_align = false,
|
||||
.use_indexed = true,
|
||||
.flush_cache = true,
|
||||
};
|
||||
|
||||
for(unsigned long i = 0; i < sizeof(img_dscs) / sizeof(img_dscs[0]); i++) {
|
||||
lv_image_decoder_dsc_t decoder_dsc;
|
||||
lv_result_t res = lv_image_decoder_open(&decoder_dsc, img_dscs[i], &args);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, res);
|
||||
lv_image_decoder_close(&decoder_dsc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user