From 0379088110631f9d60d3d01b295efe47d46bdefc Mon Sep 17 00:00:00 2001 From: _VIFEXTech Date: Wed, 17 Jan 2024 21:35:48 +0800 Subject: [PATCH] chore(vg_lite): clean useless function and macro (#5346) Signed-off-by: pengyiqiang Co-authored-by: pengyiqiang --- src/draw/vg_lite/lv_draw_buf_vg_lite.c | 39 -------------------------- src/draw/vg_lite/lv_vg_lite_decoder.c | 4 +-- src/draw/vg_lite/lv_vg_lite_utils.c | 4 +-- src/draw/vg_lite/lv_vg_lite_utils.h | 4 ++- tests/src/lv_test_conf.h | 5 ++++ 5 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/draw/vg_lite/lv_draw_buf_vg_lite.c b/src/draw/vg_lite/lv_draw_buf_vg_lite.c index 28de3ecfe..65b085ca0 100644 --- a/src/draw/vg_lite/lv_draw_buf_vg_lite.c +++ b/src/draw/vg_lite/lv_draw_buf_vg_lite.c @@ -7,15 +7,11 @@ * INCLUDES *********************/ -/*Fix warning for aligned_alloc. See https://stackoverflow.com/questions/29247065/compiler-cant-find-aligned-alloc-function*/ -#define _ISOC11_SOURCE - #include "lv_draw_vg_lite.h" #if LV_USE_DRAW_VG_LITE #include "lv_vg_lite_utils.h" -#include /********************* * DEFINES @@ -29,10 +25,6 @@ * STATIC PROTOTYPES **********************/ -static void * buf_malloc(size_t size, lv_color_format_t color_format); -static void buf_free(void * buf); -static void * buf_align(void * buf, lv_color_format_t color_format); -static void invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area); static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format); /********************** @@ -50,11 +42,6 @@ static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format); void lv_draw_buf_vg_lite_init_handlers(void) { lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers(); - - handlers->buf_malloc_cb = buf_malloc; - handlers->buf_free_cb = buf_free; - handlers->align_pointer_cb = buf_align; - handlers->invalidate_cache_cb = invalidate_cache; handlers->width_to_stride_cb = width_to_stride; } @@ -62,32 +49,6 @@ void lv_draw_buf_vg_lite_init_handlers(void) * STATIC FUNCTIONS **********************/ -static void * buf_malloc(size_t size_bytes, lv_color_format_t color_format) -{ - LV_UNUSED(color_format); - size_bytes = LV_VG_LITE_ALIGN(size_bytes, LV_VG_LITE_BUF_ALIGN); - return aligned_alloc(LV_VG_LITE_BUF_ALIGN, size_bytes); -} - -static void buf_free(void * buf) -{ - free(buf); -} - -static void * buf_align(void * buf, lv_color_format_t color_format) -{ - LV_UNUSED(color_format); - return (void *)LV_VG_LITE_ALIGN((lv_uintptr_t)buf, LV_VG_LITE_BUF_ALIGN); -} - -static void invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area) -{ - LV_UNUSED(buf); - LV_UNUSED(stride); - LV_UNUSED(color_format); - LV_UNUSED(area); -} - static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format) { return lv_vg_lite_width_to_stride(w, lv_vg_lite_vg_fmt(color_format)); diff --git a/src/draw/vg_lite/lv_vg_lite_decoder.c b/src/draw/vg_lite/lv_vg_lite_decoder.c index 69f66b82d..8e3b479cc 100644 --- a/src/draw/vg_lite/lv_vg_lite_decoder.c +++ b/src/draw/vg_lite/lv_vg_lite_decoder.c @@ -231,7 +231,7 @@ static lv_result_t decoder_open_variable(lv_image_decoder_t * decoder, lv_image_ /* Since the palette and index image are next to each other, * the palette size needs to be aligned to ensure that the image is aligned. */ - uint32_t palette_size_bytes_aligned = LV_VG_LITE_ALIGN(palette_size_bytes, LV_VG_LITE_BUF_ALIGN); + uint32_t palette_size_bytes_aligned = LV_VG_LITE_ALIGN(palette_size_bytes, LV_DRAW_BUF_ALIGN); lv_draw_buf_t * draw_buf = lv_draw_buf_create(width, height, cf, stride); if(draw_buf == NULL) { @@ -305,7 +305,7 @@ static lv_result_t decoder_open_file(lv_image_decoder_t * decoder, lv_image_deco /* Since the palette and index image are next to each other, * the palette size needs to be aligned to ensure that the image is aligned. */ - uint32_t palette_size_bytes_aligned = LV_VG_LITE_ALIGN(palette_size_bytes, LV_VG_LITE_BUF_ALIGN); + uint32_t palette_size_bytes_aligned = LV_VG_LITE_ALIGN(palette_size_bytes, LV_DRAW_BUF_ALIGN); lv_draw_buf_t * draw_buf = lv_draw_buf_create(width, height, cf, stride); if(draw_buf == NULL) { diff --git a/src/draw/vg_lite/lv_vg_lite_utils.c b/src/draw/vg_lite/lv_vg_lite_utils.c index d26cb804a..eab81a8bd 100644 --- a/src/draw/vg_lite/lv_vg_lite_utils.c +++ b/src/draw/vg_lite/lv_vg_lite_utils.c @@ -759,8 +759,8 @@ bool lv_vg_lite_buffer_check(const vg_lite_buffer_t * buffer, bool is_src) return false; } - if(!LV_VG_LITE_IS_ALIGNED(buffer->memory, LV_VG_LITE_BUF_ALIGN)) { - LV_LOG_ERROR("buffer address(%p) is not aligned to %d", buffer->memory, LV_VG_LITE_BUF_ALIGN); + if(!LV_VG_LITE_IS_ALIGNED(buffer->memory, LV_DRAW_BUF_ALIGN)) { + LV_LOG_ERROR("buffer address(%p) is not aligned to %d", buffer->memory, LV_DRAW_BUF_ALIGN); return false; } diff --git a/src/draw/vg_lite/lv_vg_lite_utils.h b/src/draw/vg_lite/lv_vg_lite_utils.h index 0df1c0743..3c24375bd 100644 --- a/src/draw/vg_lite/lv_vg_lite_utils.h +++ b/src/draw/vg_lite/lv_vg_lite_utils.h @@ -29,7 +29,9 @@ extern "C" { * DEFINES *********************/ -#define LV_VG_LITE_BUF_ALIGN 64 +#if LV_DRAW_BUF_ALIGN != 64 +#error "LV_DRAW_BUF_ALIGN must be 64" +#endif #define LV_VG_LITE_IS_ERROR(err) (err > 0) diff --git a/tests/src/lv_test_conf.h b/tests/src/lv_test_conf.h index 841a8b303..a7b04c6d8 100644 --- a/tests/src/lv_test_conf.h +++ b/tests/src/lv_test_conf.h @@ -82,6 +82,9 @@ typedef void * lv_user_data_t; /* Simulate VG-Lite hardware using ThorVG */ #define LV_USE_VG_LITE_THORVG 1 +/* VG-Lite GPU buffer alignment. */ +#define LV_DRAW_BUF_ALIGN 64 + #include "lv_test_conf_full.h" #elif LV_TEST_OPTION == 4 #define LV_COLOR_DEPTH 24 @@ -106,8 +109,10 @@ typedef void * lv_user_data_t; /*Use a large value be sure any issues will cause crash*/ #define LV_DRAW_BUF_STRIDE_ALIGN 64 +#if !defined(LV_DRAW_BUF_ALIGN) /*Use non power of 2 to avoid the case when `malloc` returns aligned pointer by default, and use a large value be sure any issues will cause crash*/ #define LV_DRAW_BUF_ALIGN 852 +#endif /*For screenshots*/ #undef LV_USE_PERF_MONITOR