mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-22 23:37:43 +08:00
chore(api): prevent API leaks (cache and thread) (#7220)
This commit is contained in:
committed by
GitHub
parent
81612fd153
commit
7bccca027a
@@ -13,6 +13,7 @@
|
||||
#include "assets/spectrum_1.h"
|
||||
#include "assets/spectrum_2.h"
|
||||
#include "assets/spectrum_3.h"
|
||||
#include "../../src/lvgl_private.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_demo_widgets.h"
|
||||
#include "../../src/lvgl_private.h"
|
||||
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../../lv_examples.h"
|
||||
|
||||
#if LV_BUILD_EXAMPLES
|
||||
#include "../../../src/osal/lv_os.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#include "../../../src/lvgl_private.h"
|
||||
|
||||
#if LV_USE_CHART && LV_DRAW_SW_COMPLEX && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ extern "C" {
|
||||
#include "src/misc/lv_iter.h"
|
||||
#include "src/misc/lv_circle_buf.h"
|
||||
#include "src/misc/lv_tree.h"
|
||||
|
||||
#include "src/misc/cache/lv_image_cache.h"
|
||||
|
||||
#include "src/tick/lv_tick.h"
|
||||
|
||||
#include "src/core/lv_obj.h"
|
||||
@@ -113,10 +114,9 @@ extern "C" {
|
||||
|
||||
#include "src/layouts/lv_layout.h"
|
||||
|
||||
#include "src/draw/lv_draw.h"
|
||||
#include "src/draw/lv_draw_buf.h"
|
||||
#include "src/draw/lv_draw_vector.h"
|
||||
#include "src/draw/sw/lv_draw_sw.h"
|
||||
#include "src/draw/sw/lv_draw_sw_utils.h"
|
||||
|
||||
#include "src/themes/lv_theme.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ extern "C" {
|
||||
#include "../misc/lv_timer.h"
|
||||
#include "../misc/lv_event.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
#include "../misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -25,7 +25,6 @@ extern "C" {
|
||||
#include "../misc/lv_profiler.h"
|
||||
#include "../misc/lv_matrix.h"
|
||||
#include "lv_image_decoder.h"
|
||||
#include "../osal/lv_os.h"
|
||||
#include "lv_draw_buf.h"
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -19,6 +19,8 @@ extern "C" {
|
||||
*********************/
|
||||
|
||||
#include "lv_draw.h"
|
||||
#include "../osal/lv_os.h"
|
||||
#include "../misc/cache/lv_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -19,7 +19,6 @@ extern "C" {
|
||||
#include "../misc/lv_fs.h"
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/cache/lv_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -13,8 +13,8 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_image_decoder.h"
|
||||
#include "../misc/cache/lv_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,7 @@ extern "C" {
|
||||
#include "../lv_draw_image.h"
|
||||
#include "../lv_draw_line.h"
|
||||
#include "../lv_draw_arc.h"
|
||||
#include "lv_draw_sw_utils.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -152,56 +153,6 @@ void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_are
|
||||
void lv_draw_sw_vector(lv_draw_unit_t * draw_unit, const lv_draw_vector_task_dsc_t * dsc);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Swap the upper and lower byte of an RGB565 buffer.
|
||||
* Might be required if a 8bit parallel port or an SPI port send the bytes in the wrong order.
|
||||
* The bytes will be swapped in place.
|
||||
* @param buf pointer to buffer
|
||||
* @param buf_size_px number of pixels in the buffer
|
||||
*/
|
||||
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px);
|
||||
|
||||
/**
|
||||
* Invert a draw buffer in the I1 color format.
|
||||
* Conventionally, a bit is set to 1 during blending if the luminance is greater than 127.
|
||||
* Depending on the display controller used, you might want to have different behavior.
|
||||
* The inversion will be performed in place.
|
||||
* @param buf pointer to the buffer to be inverted
|
||||
* @param buf_size size of the buffer in bytes
|
||||
*/
|
||||
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size);
|
||||
|
||||
|
||||
/**
|
||||
* Convert a draw buffer in I1 color format from htiled (row-wise)
|
||||
* to vtiled (column-wise) buffer layout. The conversion assumes that the buffer width
|
||||
* and height is rounded to a multiple of 8.
|
||||
* @param buf pointer to the buffer to be converted
|
||||
* @param buf_size size of the buffer in bytes
|
||||
* @param width width of the buffer
|
||||
* @param height height of the buffer
|
||||
* @param out_buf pointer to the output buffer
|
||||
* @param out_buf_size size of the output buffer in bytes
|
||||
* @param bit_order_lsb bit order of the resulting vtiled buffer
|
||||
*/
|
||||
void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
|
||||
void * out_buf,
|
||||
uint32_t out_buf_size, bool bit_order_lsb);
|
||||
|
||||
/**
|
||||
* Rotate a buffer into another buffer
|
||||
* @param src the source buffer
|
||||
* @param dest the destination buffer
|
||||
* @param src_width source width in pixels
|
||||
* @param src_height source height in pixels
|
||||
* @param src_stride source stride in bytes (number of bytes in a row)
|
||||
* @param dest_stride destination stride in bytes (number of bytes in a row)
|
||||
* @param rotation LV_DISPLAY_ROTATION_0/90/180/270
|
||||
* @param color_format LV_COLOR_FORMAT_RGB565/RGB888/XRGB8888/ARGB8888
|
||||
*/
|
||||
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
|
||||
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format);
|
||||
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @file lv_draw_sw_utils.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_SW_UTILS_H
|
||||
#define LV_DRAW_SW_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
#if LV_USE_DRAW_SW
|
||||
|
||||
#include "../../misc/lv_area.h"
|
||||
#include "../../misc/lv_color.h"
|
||||
#include "../../display/lv_display.h"
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Swap the upper and lower byte of an RGB565 buffer.
|
||||
* Might be required if a 8bit parallel port or an SPI port send the bytes in the wrong order.
|
||||
* The bytes will be swapped in place.
|
||||
* @param buf pointer to buffer
|
||||
* @param buf_size_px number of pixels in the buffer
|
||||
*/
|
||||
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px);
|
||||
|
||||
/**
|
||||
* Invert a draw buffer in the I1 color format.
|
||||
* Conventionally, a bit is set to 1 during blending if the luminance is greater than 127.
|
||||
* Depending on the display controller used, you might want to have different behavior.
|
||||
* The inversion will be performed in place.
|
||||
* @param buf pointer to the buffer to be inverted
|
||||
* @param buf_size size of the buffer in bytes
|
||||
*/
|
||||
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size);
|
||||
|
||||
|
||||
/**
|
||||
* Convert a draw buffer in I1 color format from htiled (row-wise)
|
||||
* to vtiled (column-wise) buffer layout. The conversion assumes that the buffer width
|
||||
* and height is rounded to a multiple of 8.
|
||||
* @param buf pointer to the buffer to be converted
|
||||
* @param buf_size size of the buffer in bytes
|
||||
* @param width width of the buffer
|
||||
* @param height height of the buffer
|
||||
* @param out_buf pointer to the output buffer
|
||||
* @param out_buf_size size of the output buffer in bytes
|
||||
* @param bit_order_lsb bit order of the resulting vtiled buffer
|
||||
*/
|
||||
void lv_draw_sw_i1_convert_to_vtiled(const void * buf, uint32_t buf_size, uint32_t width, uint32_t height,
|
||||
void * out_buf,
|
||||
uint32_t out_buf_size, bool bit_order_lsb);
|
||||
|
||||
/**
|
||||
* Rotate a buffer into another buffer
|
||||
* @param src the source buffer
|
||||
* @param dest the destination buffer
|
||||
* @param src_width source width in pixels
|
||||
* @param src_height source height in pixels
|
||||
* @param src_stride source stride in bytes (number of bytes in a row)
|
||||
* @param dest_stride destination stride in bytes (number of bytes in a row)
|
||||
* @param rotation LV_DISPLAY_ROTATION_0/90/180/270
|
||||
* @param color_format LV_COLOR_FORMAT_RGB565/RGB888/XRGB8888/ARGB8888
|
||||
*/
|
||||
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
|
||||
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format);
|
||||
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_DRAW_SW*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_SW_UTILS_H*/
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <xf86drmMode.h>
|
||||
#include <drm_fourcc.h>
|
||||
|
||||
#include "../../../stdlib/lv_sprintf.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "lv_windows_display.h"
|
||||
#include "lv_windows_input_private.h"
|
||||
#include "../../osal/lv_os.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -19,7 +19,6 @@ extern "C" {
|
||||
#include "lv_symbol_def.h"
|
||||
#include "../draw/lv_draw_buf.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/cache/lv_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../misc/lv_timer_private.h"
|
||||
#include "../../core/lv_obj_class_private.h"
|
||||
#include "lv_gif_private.h"
|
||||
#if LV_USE_GIF
|
||||
#include "../../misc/lv_timer_private.h"
|
||||
#include "../../misc/cache/lv_image_cache.h"
|
||||
#include "../../core/lv_obj_class_private.h"
|
||||
|
||||
#include "gifdec.h"
|
||||
|
||||
|
||||
Vendored
+2
@@ -10,6 +10,7 @@
|
||||
#include "../../stdlib/lv_sprintf.h"
|
||||
#include "../lv_assert.h"
|
||||
#include "lv_cache_entry_private.h"
|
||||
#include "lv_cache_private.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -25,6 +26,7 @@
|
||||
static void cache_drop_internal_no_lock(lv_cache_t * cache, const void * key, void * user_data);
|
||||
static bool cache_evict_one_internal_no_lock(lv_cache_t * cache, void * user_data);
|
||||
static lv_cache_entry_t * cache_add_internal_no_lock(lv_cache_t * cache, const void * key, void * user_data);
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
||||
Vendored
+1
-1
@@ -14,13 +14,13 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_cache_entry.h"
|
||||
#include "lv_cache_private.h"
|
||||
#include "../lv_types.h"
|
||||
|
||||
#include "lv_cache_lru_rb.h"
|
||||
|
||||
#include "lv_image_cache.h"
|
||||
#include "lv_image_header_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
Vendored
+18
@@ -12,6 +12,7 @@
|
||||
#include "lv_cache.h"
|
||||
#include "lv_cache_entry_private.h"
|
||||
#include "lv_cache_private.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -51,11 +52,13 @@ void lv_cache_entry_reset_ref(lv_cache_entry_t * entry)
|
||||
LV_ASSERT_NULL(entry);
|
||||
entry->ref_cnt = 0;
|
||||
}
|
||||
|
||||
void lv_cache_entry_inc_ref(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
entry->ref_cnt++;
|
||||
}
|
||||
|
||||
void lv_cache_entry_dec_ref(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
@@ -65,35 +68,42 @@ void lv_cache_entry_dec_ref(lv_cache_entry_t * entry)
|
||||
entry->ref_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t lv_cache_entry_get_ref(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
return entry->ref_cnt;
|
||||
}
|
||||
|
||||
uint32_t lv_cache_entry_get_node_size(lv_cache_entry_t * entry)
|
||||
{
|
||||
return entry->node_size;
|
||||
}
|
||||
|
||||
void lv_cache_entry_set_node_size(lv_cache_entry_t * entry, uint32_t node_size)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
entry->node_size = node_size;
|
||||
}
|
||||
|
||||
void lv_cache_entry_set_invalid(lv_cache_entry_t * entry, bool is_invalid)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
entry->is_invalid = is_invalid;
|
||||
}
|
||||
|
||||
bool lv_cache_entry_is_invalid(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
return entry->is_invalid;
|
||||
}
|
||||
|
||||
void * lv_cache_entry_get_data(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
return (uint8_t *)entry - entry->node_size;
|
||||
}
|
||||
|
||||
void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
@@ -101,6 +111,7 @@ void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry)
|
||||
lv_cache_entry_inc_ref(entry);
|
||||
return lv_cache_entry_get_data(entry);
|
||||
}
|
||||
|
||||
void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data)
|
||||
{
|
||||
LV_UNUSED(user_data);
|
||||
@@ -113,16 +124,19 @@ void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data)
|
||||
|
||||
lv_cache_entry_dec_ref(entry);
|
||||
}
|
||||
|
||||
lv_cache_entry_t * lv_cache_entry_get_entry(void * data, const uint32_t node_size)
|
||||
{
|
||||
LV_ASSERT_NULL(data);
|
||||
return (lv_cache_entry_t *)((uint8_t *)data + node_size);
|
||||
}
|
||||
|
||||
void lv_cache_entry_set_cache(lv_cache_entry_t * entry, const lv_cache_t * cache)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
entry->cache = cache;
|
||||
}
|
||||
|
||||
const lv_cache_t * lv_cache_entry_get_cache(const lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
@@ -133,6 +147,7 @@ uint32_t lv_cache_entry_get_size(const uint32_t node_size)
|
||||
{
|
||||
return node_size + sizeof(lv_cache_entry_t);
|
||||
}
|
||||
|
||||
lv_cache_entry_t * lv_cache_entry_alloc(const uint32_t node_size, const lv_cache_t * cache)
|
||||
{
|
||||
void * res = lv_malloc_zeroed(lv_cache_entry_get_size(node_size));
|
||||
@@ -145,6 +160,7 @@ lv_cache_entry_t * lv_cache_entry_alloc(const uint32_t node_size, const lv_cache
|
||||
lv_cache_entry_init(entry, cache, node_size);
|
||||
return (lv_cache_entry_t *)((uint8_t *)entry + node_size);
|
||||
}
|
||||
|
||||
void lv_cache_entry_init(lv_cache_entry_t * entry, const lv_cache_t * cache, const uint32_t node_size)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
@@ -155,6 +171,7 @@ void lv_cache_entry_init(lv_cache_entry_t * entry, const lv_cache_t * cache, con
|
||||
entry->ref_cnt = 0;
|
||||
entry->is_invalid = false;
|
||||
}
|
||||
|
||||
void lv_cache_entry_delete(lv_cache_entry_t * entry)
|
||||
{
|
||||
LV_ASSERT_NULL(entry);
|
||||
@@ -162,6 +179,7 @@ void lv_cache_entry_delete(lv_cache_entry_t * entry)
|
||||
void * data = lv_cache_entry_get_data(entry);
|
||||
lv_free(data);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
Vendored
+1
-2
@@ -13,9 +13,8 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../osal/lv_os.h"
|
||||
#include "../lv_types.h"
|
||||
#include "lv_cache_private.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
+2
@@ -16,6 +16,7 @@ extern "C" {
|
||||
#include "../lv_types.h"
|
||||
#include "../../osal/lv_os.h"
|
||||
#include "../lv_profiler.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -35,6 +36,7 @@ void lv_cache_entry_set_invalid(lv_cache_entry_t * entry, bool is_invalid);
|
||||
void lv_cache_entry_set_cache(lv_cache_entry_t * entry, const lv_cache_t * cache);
|
||||
void * lv_cache_entry_acquire_data(lv_cache_entry_t * entry);
|
||||
void lv_cache_entry_release_data(lv_cache_entry_t * entry, void * user_data);
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
|
||||
Vendored
-2
@@ -40,9 +40,7 @@ struct _lv_cache_class_t;
|
||||
struct _lv_cache_entry_t;
|
||||
|
||||
typedef struct _lv_cache_ops_t lv_cache_ops_t;
|
||||
typedef struct _lv_cache_t lv_cache_t;
|
||||
typedef struct _lv_cache_class_t lv_cache_class_t;
|
||||
typedef struct _lv_cache_entry_t lv_cache_entry_t;
|
||||
|
||||
typedef int8_t lv_cache_compare_res_t;
|
||||
typedef bool (*lv_cache_create_cb_t)(void * node, void * user_data);
|
||||
|
||||
@@ -135,6 +135,10 @@ typedef struct _lv_color_filter_dsc_t lv_color_filter_dsc_t;
|
||||
|
||||
typedef struct _lv_event_dsc_t lv_event_dsc_t;
|
||||
|
||||
typedef struct _lv_cache_t lv_cache_t;
|
||||
|
||||
typedef struct _lv_cache_entry_t lv_cache_entry_t;
|
||||
|
||||
typedef struct _lv_fs_file_cache_t lv_fs_file_cache_t;
|
||||
|
||||
typedef struct _lv_fs_path_ex_t lv_fs_path_ex_t;
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../../osal/lv_os.h"
|
||||
#include "../../misc/lv_ll.h"
|
||||
#include "../../misc/lv_types.h"
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ extern "C" {
|
||||
*********************/
|
||||
|
||||
#include "lv_tlsf.h"
|
||||
#include "../../osal/lv_os.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "../../misc/lv_timer.h"
|
||||
#include "../../core/lv_obj_class_private.h"
|
||||
#include "../../misc/cache/lv_image_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
Reference in New Issue
Block a user