Various fix for gc module (#2102)
* fix(gc): remove the unused variables from gc * fix(gc): correct typo(from _lv_img_defoder_ll to _lv_img_decoder_ll) * fix(gc): change _lv_drv_ll to _lv_fsdrv_ll since only instances fo lv_fs_drv_t can be added to this list * fix(gc): Iterate the root variables only when they are really used to save the memory space * fix(image cache): move cache_temp to gc.h and rename it to _lv_img_cache_single
This commit is contained in:
@@ -33,9 +33,6 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if LV_IMG_CACHE_DEF_SIZE == 0
|
||||
static lv_img_cache_entry_t cache_temp;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -124,7 +121,7 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)
|
||||
}
|
||||
|
||||
#else
|
||||
cached_src = &cache_temp;
|
||||
cached_src = &LV_GC_ROOT(_lv_img_cache_single);
|
||||
#endif
|
||||
/*Open the image and measure the time to open*/
|
||||
uint32_t t_start = lv_tick_get();
|
||||
|
||||
@@ -54,7 +54,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
|
||||
* */
|
||||
void _lv_img_decoder_init(void)
|
||||
{
|
||||
_lv_ll_init(&LV_GC_ROOT(_lv_img_defoder_ll), sizeof(lv_img_decoder_t));
|
||||
_lv_ll_init(&LV_GC_ROOT(_lv_img_decoder_ll), sizeof(lv_img_decoder_t));
|
||||
|
||||
lv_img_decoder_t * decoder;
|
||||
|
||||
@@ -85,7 +85,7 @@ lv_res_t lv_img_decoder_get_info(const void * src, lv_img_header_t * header)
|
||||
|
||||
lv_res_t res = LV_RES_INV;
|
||||
lv_img_decoder_t * d;
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_img_defoder_ll), d) {
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_img_decoder_ll), d) {
|
||||
res = LV_RES_INV;
|
||||
if(d->info_cb) {
|
||||
res = d->info_cb(d, src, header);
|
||||
@@ -132,7 +132,7 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
|
||||
lv_res_t res = LV_RES_INV;
|
||||
|
||||
lv_img_decoder_t * d;
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_img_defoder_ll), d) {
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_img_decoder_ll), d) {
|
||||
/*Info an Open callbacks are required*/
|
||||
if(d->info_cb == NULL || d->open_cb == NULL) continue;
|
||||
|
||||
@@ -200,7 +200,7 @@ void lv_img_decoder_close(lv_img_decoder_dsc_t * dsc)
|
||||
lv_img_decoder_t * lv_img_decoder_create(void)
|
||||
{
|
||||
lv_img_decoder_t * decoder;
|
||||
decoder = _lv_ll_ins_head(&LV_GC_ROOT(_lv_img_defoder_ll));
|
||||
decoder = _lv_ll_ins_head(&LV_GC_ROOT(_lv_img_decoder_ll));
|
||||
LV_ASSERT_MALLOC(decoder);
|
||||
if(decoder == NULL) return NULL;
|
||||
|
||||
@@ -215,7 +215,7 @@ lv_img_decoder_t * lv_img_decoder_create(void)
|
||||
*/
|
||||
void lv_img_decoder_delete(lv_img_decoder_t * decoder)
|
||||
{
|
||||
_lv_ll_remove(&LV_GC_ROOT(_lv_img_defoder_ll), decoder);
|
||||
_lv_ll_remove(&LV_GC_ROOT(_lv_img_decoder_ll), decoder);
|
||||
lv_mem_free(decoder);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,10 +188,12 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t *
|
||||
*/
|
||||
void _lv_font_clean_up_fmt_txt(void)
|
||||
{
|
||||
#if LV_USE_FONT_COMPRESSED
|
||||
if(LV_GC_ROOT(_lv_font_decompr_buf)) {
|
||||
lv_mem_free(LV_GC_ROOT(_lv_font_decompr_buf));
|
||||
LV_GC_ROOT(_lv_font_decompr_buf) = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -48,7 +48,7 @@ static const char * lv_fs_get_real_path(const char * path);
|
||||
|
||||
void _lv_fs_init(void)
|
||||
{
|
||||
_lv_ll_init(&LV_GC_ROOT(_lv_drv_ll), sizeof(lv_fs_drv_t));
|
||||
_lv_ll_init(&LV_GC_ROOT(_lv_fsdrv_ll), sizeof(lv_fs_drv_t));
|
||||
}
|
||||
|
||||
bool lv_fs_is_ready(char letter)
|
||||
@@ -287,7 +287,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
|
||||
{
|
||||
/*Save the new driver*/
|
||||
lv_fs_drv_t * new_drv;
|
||||
new_drv = _lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll));
|
||||
new_drv = _lv_ll_ins_head(&LV_GC_ROOT(_lv_fsdrv_ll));
|
||||
LV_ASSERT_MALLOC(new_drv);
|
||||
if(new_drv == NULL) return;
|
||||
|
||||
@@ -298,7 +298,7 @@ lv_fs_drv_t * lv_fs_get_drv(char letter)
|
||||
{
|
||||
lv_fs_drv_t * drv;
|
||||
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_drv_ll), drv) {
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_fsdrv_ll), drv) {
|
||||
if(drv->letter == letter) {
|
||||
return drv;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ char * lv_fs_get_letters(char * buf)
|
||||
lv_fs_drv_t * drv;
|
||||
uint8_t i = 0;
|
||||
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_drv_ll), drv) {
|
||||
_LV_LL_READ(&LV_GC_ROOT(_lv_fsdrv_ll), drv) {
|
||||
buf[i] = drv->letter;
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -24,25 +24,36 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#if LV_IMG_CACHE_DEF_SIZE
|
||||
# define LV_IMG_CACHE_DEF 1
|
||||
#else
|
||||
# define LV_IMG_CACHE_DEF 0
|
||||
#endif
|
||||
|
||||
#define LV_ITERATE_ROOTS(f) \
|
||||
f(lv_ll_t, _lv_timer_ll) /*Linked list to store the lv_tmr-s*/ \
|
||||
f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \
|
||||
f(lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \
|
||||
f(lv_ll_t, _lv_drv_ll) \
|
||||
f(lv_ll_t, _lv_file_ll) \
|
||||
f(lv_ll_t, _lv_anim_ll) \
|
||||
f(lv_ll_t, _lv_group_ll) \
|
||||
f(lv_ll_t, _lv_img_defoder_ll) \
|
||||
f(lv_ll_t, _lv_obj_style_trans_ll) \
|
||||
f(lv_img_cache_entry_t*, _lv_img_cache_array) \
|
||||
f(lv_timer_t*, _lv_timer_act) \
|
||||
f(lv_mem_buf_arr_t , lv_mem_buf) \
|
||||
f(_lv_draw_mask_saved_arr_t , _lv_draw_mask_list) \
|
||||
f(void * , _lv_theme_default_styles) \
|
||||
f(void * , _lv_theme_mono_styles) \
|
||||
f(void * , _lv_theme_empty_styles) \
|
||||
f(uint8_t *, _lv_font_decompr_buf) \
|
||||
#define LV_DISPATCH(f, t, n) f(t, n)
|
||||
#define LV_DISPATCH_COND(f, t, n, m, v) LV_CONCAT3(LV_DISPATCH, m, v)(f, t, n)
|
||||
|
||||
#define LV_DISPATCH00(f, t, n) LV_DISPATCH(f, t, n)
|
||||
#define LV_DISPATCH01(f, t, n)
|
||||
#define LV_DISPATCH10(f, t, n)
|
||||
#define LV_DISPATCH11(f, t, n) LV_DISPATCH(f, t, n)
|
||||
|
||||
#define LV_ITERATE_ROOTS(f) \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_timer_ll) /*Linked list to store the lv_timers*/ \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_disp_ll) /*Linked list of display device*/ \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_fsdrv_ll) \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_anim_ll) \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_group_ll) \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_img_decoder_ll) \
|
||||
LV_DISPATCH(f, lv_ll_t, _lv_obj_style_trans_ll) \
|
||||
LV_DISPATCH_COND(f, lv_img_cache_entry_t*, _lv_img_cache_array, LV_IMG_CACHE_DEF, 1) \
|
||||
LV_DISPATCH_COND(f, lv_img_cache_entry_t, _lv_img_cache_single, LV_IMG_CACHE_DEF, 0) \
|
||||
LV_DISPATCH(f, lv_timer_t*, _lv_timer_act) \
|
||||
LV_DISPATCH(f, lv_mem_buf_arr_t , lv_mem_buf) \
|
||||
LV_DISPATCH_COND(f, _lv_draw_mask_saved_arr_t , _lv_draw_mask_list, LV_DRAW_COMPLEX, 1) \
|
||||
LV_DISPATCH(f, void * , _lv_theme_default_styles) \
|
||||
LV_DISPATCH_COND(f, uint8_t *, _lv_font_decompr_buf, LV_USE_FONT_COMPRESSED, 1)
|
||||
|
||||
#define LV_DEFINE_ROOT(root_type, root_name) root_type root_name;
|
||||
#define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT)
|
||||
|
||||
Reference in New Issue
Block a user