mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
feat(cache): add name for cache instance (#6040)
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
parent
e72f52d0bd
commit
79033500ac
@ -112,6 +112,7 @@ void lv_draw_sdl_init(void)
|
||||
.create_cb = (lv_cache_create_cb_t)sdl_texture_cache_create_cb,
|
||||
.free_cb = (lv_cache_free_cb_t)sdl_texture_cache_free_cb,
|
||||
});
|
||||
lv_cache_set_name(draw_sdl_unit->texture_cache, "SDL_TEXTURE");
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -98,6 +98,7 @@ void lv_vg_lite_grad_init(
|
||||
u->linear_grad_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(linear_grad_item_t),
|
||||
linear_grad_cache_cnt,
|
||||
ops);
|
||||
lv_cache_set_name(u->linear_grad_cache, "LINEAR_GRAD");
|
||||
u->linear_grad_pending = lv_vg_lite_pending_create(sizeof(lv_cache_entry_t *), 4);
|
||||
lv_vg_lite_pending_set_free_cb(u->linear_grad_pending, grad_cache_release_cb, u->linear_grad_cache);
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ lv_result_t lv_freetype_init(uint32_t max_glyph_cnt)
|
||||
.free_cb = (lv_cache_free_cb_t)cache_node_cache_free_cb,
|
||||
};
|
||||
ctx->cache_node_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(lv_freetype_cache_node_t), INT32_MAX, ops);
|
||||
lv_cache_set_name(ctx->cache_node_cache, "FREETYPE_CACHE_NODE");
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define CACHE_NAME "FREETYPE_GLYPH"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -59,6 +61,7 @@ lv_cache_t * lv_freetype_create_glyph_cache(uint32_t cache_size)
|
||||
|
||||
lv_cache_t * glyph_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(lv_freetype_glyph_cache_data_t),
|
||||
cache_size, ops);
|
||||
lv_cache_set_name(glyph_cache, CACHE_NAME);
|
||||
|
||||
return glyph_cache;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define CACHE_NAME "FREETYPE_IMAGE"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -64,6 +66,7 @@ lv_cache_t * lv_freetype_create_draw_data_image(uint32_t cache_size)
|
||||
|
||||
lv_cache_t * draw_data_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(lv_freetype_image_cache_data_t),
|
||||
cache_size, ops);
|
||||
lv_cache_set_name(draw_data_cache, CACHE_NAME);
|
||||
|
||||
return draw_data_cache;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define CACHE_NAME "FREETYPE_OUTLINE"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -66,6 +68,7 @@ lv_cache_t * lv_freetype_create_draw_data_outline(uint32_t cache_size)
|
||||
lv_cache_t * draw_data_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(lv_freetype_outline_node_t),
|
||||
cache_size,
|
||||
glyph_outline_cache_ops);
|
||||
lv_cache_set_name(draw_data_cache, CACHE_NAME);
|
||||
|
||||
return draw_data_cache;
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define CACHE_NAME "TINY_TTF"
|
||||
|
||||
#define STB_RECT_PACK_IMPLEMENTATION
|
||||
#define STBRP_STATIC
|
||||
#define STBTT_STATIC
|
||||
@ -144,6 +147,7 @@ void lv_tiny_ttf_init(void)
|
||||
};
|
||||
|
||||
tiny_ttf_cache = lv_cache_create(&lv_cache_class_lru_rb_count, sizeof(tiny_ttf_cache_data_t), 128, ops);
|
||||
lv_cache_set_name(tiny_ttf_cache, CACHE_NAME);
|
||||
}
|
||||
|
||||
void lv_tiny_ttf_deinit(void)
|
||||
|
9
src/misc/cache/lv_cache.c
vendored
9
src/misc/cache/lv_cache.c
vendored
@ -282,6 +282,15 @@ void lv_cache_set_free_cb(lv_cache_t * cache, lv_cache_free_cb_t free_cb, void *
|
||||
LV_UNUSED(user_data);
|
||||
cache->ops.free_cb = free_cb;
|
||||
}
|
||||
void lv_cache_set_name(lv_cache_t * cache, const char * name)
|
||||
{
|
||||
if(cache == NULL) return;
|
||||
cache->name = name;
|
||||
}
|
||||
const char * lv_cache_get_name(lv_cache_t * cache)
|
||||
{
|
||||
return cache->name;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
|
15
src/misc/cache/lv_cache.h
vendored
15
src/misc/cache/lv_cache.h
vendored
@ -200,6 +200,21 @@ void lv_cache_set_create_cb(lv_cache_t * cache, lv_cache_create_cb_t alloc_cb,
|
||||
* @param user_data A user data pointer.
|
||||
*/
|
||||
void lv_cache_set_free_cb(lv_cache_t * cache, lv_cache_free_cb_t free_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Give a name for a cache object. Only the pointer of the string is saved.
|
||||
* @param cache The cache object pointer to set the name.
|
||||
* @param name The name of the cache.
|
||||
*/
|
||||
void lv_cache_set_name(lv_cache_t * cache, const char * name);
|
||||
|
||||
/**
|
||||
* Get the name of a cache object.
|
||||
* @param cache The cache object pointer to get the name.
|
||||
* @return Returns the name of the cache.
|
||||
*/
|
||||
const char * lv_cache_get_name(lv_cache_t * cache);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
2
src/misc/cache/lv_cache_private.h
vendored
2
src/misc/cache/lv_cache_private.h
vendored
@ -132,6 +132,8 @@ struct _lv_cache_t {
|
||||
lv_cache_ops_t ops; /**< The cache operations struct @lv_cache_ops_t */
|
||||
|
||||
lv_mutex_t lock; /**< The cache lock used to protect the cache in multithreading environments */
|
||||
|
||||
const char * name; /**< The name of the cache */
|
||||
};
|
||||
|
||||
/**
|
||||
|
4
src/misc/cache/lv_image_cache.c
vendored
4
src/misc/cache/lv_image_cache.c
vendored
@ -17,6 +17,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define CACHE_NAME "IMAGE"
|
||||
|
||||
#define img_cache_p (LV_GLOBAL_DEFAULT()->img_cache)
|
||||
|
||||
/**********************
|
||||
@ -59,6 +61,8 @@ lv_result_t lv_image_cache_init(uint32_t size)
|
||||
.create_cb = NULL,
|
||||
.free_cb = (lv_cache_free_cb_t) image_cache_free_cb,
|
||||
});
|
||||
|
||||
lv_cache_set_name(img_cache_p, CACHE_NAME);
|
||||
return img_cache_p != NULL ? LV_RESULT_OK : LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
|
3
src/misc/cache/lv_image_header_cache.c
vendored
3
src/misc/cache/lv_image_header_cache.c
vendored
@ -16,6 +16,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define CACHE_NAME "IMAGE_HEADER"
|
||||
|
||||
#define img_header_cache_p (LV_GLOBAL_DEFAULT()->img_header_cache)
|
||||
|
||||
/**********************
|
||||
@ -59,6 +61,7 @@ lv_result_t lv_image_header_cache_init(uint32_t count)
|
||||
.free_cb = (lv_cache_free_cb_t) image_header_cache_free_cb
|
||||
});
|
||||
|
||||
lv_cache_set_name(img_header_cache_p, CACHE_NAME);
|
||||
return img_header_cache_p != NULL ? LV_RESULT_OK : LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user