feat(tests): add VG-Lite render test (#6264)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: liamHowatt <liamjmh0@gmail.com>
This commit is contained in:
VIFEX
2024-06-08 04:29:13 +08:00
committed by GitHub
parent 6b17a613fd
commit 9a7639ccea
432 changed files with 165 additions and 64 deletions

View File

@@ -88,7 +88,7 @@ jobs:
with:
name: screenshot-errors-amd64
path: |
tests/ref_imgs/**/*_err.png
tests/ref_imgs*/**/*_err.png
test_screenshot_error.h
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4

View File

@@ -393,6 +393,10 @@ lv_result_t lv_draw_buf_adjust_stride(lv_draw_buf_t * src, uint32_t stride)
uint32_t w = header->w;
uint32_t h = header->h;
if(!lv_draw_buf_has_flag(src, LV_IMAGE_FLAGS_MODIFIABLE)) {
return LV_RESULT_INVALID;
}
/*Use global stride*/
if(stride == 0) stride = lv_draw_buf_width_to_stride(w, header->cf);

View File

@@ -124,7 +124,7 @@ lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src
lv_result_t res = dsc->decoder->open_cb(dsc->decoder, dsc);
/* Flush the D-Cache if enabled and the image was successfully opened */
if(dsc->args.flush_cache && res == LV_RESULT_OK) {
if(dsc->args.flush_cache && res == LV_RESULT_OK && dsc->decoded != NULL) {
lv_draw_buf_flush_cache(dsc->decoded, NULL);
LV_LOG_INFO("Flushed D-cache: src %p (%s) (W%" LV_PRId32 " x H%" LV_PRId32 ", data: %p cf: %d)",
src,

View File

@@ -203,6 +203,12 @@ static int32_t draw_evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task)
{
LV_UNUSED(draw_unit);
/* Return if target buffer format is not supported. */
const lv_draw_dsc_base_t * base_dsc = task->draw_dsc;
if(!lv_vg_lite_is_dest_cf_supported(base_dsc->layer->color_format)) {
return -1;
}
switch(task->type) {
case LV_DRAW_TASK_TYPE_LABEL:
case LV_DRAW_TASK_TYPE_FILL:

View File

@@ -27,6 +27,7 @@
* so for simplicity, they are uniformly converted to I8 for display.
*/
#define DEST_IMG_FORMAT LV_COLOR_FORMAT_I8
#define IS_CONV_INDEX_FORMAT(cf) (cf == LV_COLOR_FORMAT_I1 || cf == LV_COLOR_FORMAT_I2 || cf == LV_COLOR_FORMAT_I4)
/* 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.
@@ -162,12 +163,17 @@ static lv_result_t decoder_info(lv_image_decoder_t * decoder, const void * src,
return LV_RESULT_OK;
}
if(LV_COLOR_FORMAT_IS_INDEXED(header->cf)) {
header->cf = DEST_IMG_FORMAT;
return LV_RESULT_OK;
if(!IS_CONV_INDEX_FORMAT(header->cf)) {
return LV_RESULT_INVALID;
}
return LV_RESULT_INVALID;
if(header->flags & LV_IMAGE_FLAGS_COMPRESSED) {
LV_LOG_WARN("NOT Supported compressed index format: %d", header->cf);
return LV_RESULT_INVALID;
}
header->cf = DEST_IMG_FORMAT;
return LV_RESULT_OK;
}
static lv_result_t decoder_open_variable(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
@@ -234,7 +240,7 @@ static lv_result_t decoder_open_variable(lv_image_decoder_t * decoder, lv_image_
/* copy palette */
lv_memcpy(dest, src, palette_size_bytes);
if(!dsc->args.premultiply) {
if(dsc->args.premultiply) {
/* pre-multiply palette */
image_color32_pre_mul((lv_color32_t *)dest, palette_size);
draw_buf->header.flags |= LV_IMAGE_FLAGS_PREMULTIPLIED;

View File

@@ -162,6 +162,7 @@ const char * lv_vg_lite_feature_string(vg_lite_feature_t feature)
FEATURE_ENUM_TO_STRING(YUV_TILED_INPUT);
FEATURE_ENUM_TO_STRING(AYUV_INPUT);
FEATURE_ENUM_TO_STRING(16PIXELS_ALIGN);
FEATURE_ENUM_TO_STRING(DEC_COMPRESS_2_0);
default:
break;
}
@@ -500,7 +501,7 @@ uint32_t lv_vg_lite_width_to_stride(uint32_t w, vg_lite_buffer_format_t color_fo
uint32_t mul, div, align;
lv_vg_lite_buffer_format_bytes(color_format, &mul, &div, &align);
return LV_VG_LITE_ALIGN((w * mul / div), align);
return LV_VG_LITE_ALIGN(((w * mul + div - 1) / div), align);
}
uint32_t lv_vg_lite_width_align(uint32_t w)

View File

@@ -435,6 +435,15 @@ static inline lv_color_t lv_color_black(void)
static inline void lv_color_premultiply(lv_color32_t * c)
{
if(c->alpha == LV_OPA_COVER) {
return;
}
if(c->alpha == LV_OPA_TRANSP) {
lv_memzero(c, sizeof(lv_color32_t));
return;
}
c->red = LV_OPA_MIX2(c->red, c->alpha);
c->green = LV_OPA_MIX2(c->green, c->alpha);
c->blue = LV_OPA_MIX2(c->blue, c->alpha);
@@ -442,6 +451,15 @@ static inline void lv_color_premultiply(lv_color32_t * c)
static inline void lv_color16_premultiply(lv_color16_t * c, lv_opa_t a)
{
if(a == LV_OPA_COVER) {
return;
}
if(a == LV_OPA_TRANSP) {
lv_memzero(c, sizeof(lv_color16_t));
return;
}
c->red = LV_OPA_MIX2(c->red, a);
c->green = LV_OPA_MIX2(c->green, a);
c->blue = LV_OPA_MIX2(c->blue, a);

View File

@@ -310,9 +310,9 @@ static vg_lite_converter<vg_color16_t, vg_color32_t> conv_bgra8888_to_bgr565(
[](vg_color16_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->red = src->red >> 3;
dest->green = src->green >> 2;
dest->blue = src->blue >> 3;
dest->red = src->red * 0x1F / 0xFF;
dest->green = src->green * 0x3F / 0xFF;
dest->blue = src->blue * 0x1F / 0xFF;
src++;
dest++;
}
@@ -322,9 +322,9 @@ static vg_lite_converter<vg_color16_alpha_t, vg_color32_t> conv_bgra8888_to_bgra
[](vg_color16_alpha_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->c.red = src->red >> 3;
dest->c.green = src->green >> 2;
dest->c.blue = src->blue >> 3;
dest->c.red = src->red * 0x1F / 0xFF;
dest->c.green = src->green * 0x3F / 0xFF;
dest->c.blue = src->blue * 0x1F / 0xFF;
dest->alpha = src->alpha;
src++;
dest++;
@@ -335,9 +335,9 @@ static vg_lite_converter<vg_color32_t, vg_color16_t> conv_bgr565_to_bgra8888(
[](vg_color32_t * dest, const vg_color16_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->red = src->red << 3;
dest->green = src->green << 2;
dest->blue = src->blue << 3;
dest->red = src->red * 0xFF / 0x1F;
dest->green = src->green * 0xFF / 0x3F;
dest->blue = src->blue * 0xFF / 0x1F;
dest->alpha = 0xFF;
src++;
dest++;
@@ -348,9 +348,9 @@ static vg_lite_converter<vg_color32_t, vg_color16_alpha_t> conv_bgra5658_to_bgra
[](vg_color32_t * dest, const vg_color16_alpha_t * src, vg_lite_uint32_t px_size, vg_lite_uint32_t /* color */)
{
while(px_size--) {
dest->red = src->c.red << 3;
dest->green = src->c.green << 2;
dest->blue = src->c.blue << 3;
dest->red = src->c.red * 0xFF / 0x1F;
dest->green = src->c.green * 0xFF / 0x3F;
dest->blue = src->c.blue * 0xFF / 0x1F;
dest->alpha = src->alpha;
src++;
dest++;
@@ -515,6 +515,7 @@ extern "C" {
auto shape = Shape::gen();
TVG_CHECK_RETURN_VG_ERROR(shape_append_rect(shape, target, rectangle));
TVG_CHECK_RETURN_VG_ERROR(shape->blend(BlendMethod::SrcOver));
TVG_CHECK_RETURN_VG_ERROR(shape->fill(TVG_COLOR(color)));
TVG_CHECK_RETURN_VG_ERROR(ctx->canvas->push(std::move(shape)));
@@ -614,9 +615,9 @@ extern "C" {
static void picture_bgra8888_to_bgr565(vg_color16_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
{
while(px_size--) {
dest->red = src->red >> 3;
dest->green = src->green >> 2;
dest->blue = src->blue >> 3;
dest->red = src->red * 0x1F / 0xFF;
dest->green = src->green * 0x3F / 0xFF;
dest->blue = src->blue * 0x1F / 0xFF;
src++;
dest++;
}
@@ -625,9 +626,9 @@ extern "C" {
static void picture_bgra8888_to_bgra5658(vg_color16_alpha_t * dest, const vg_color32_t * src, vg_lite_uint32_t px_size)
{
while(px_size--) {
dest->c.red = src->red >> 3;
dest->c.green = src->green >> 2;
dest->c.blue = src->blue >> 3;
dest->c.red = src->red * 0x1F / 0xFF;
dest->c.green = src->green * 0x3F / 0xFF;
dest->c.blue = src->blue * 0x1F / 0xFF;
dest->alpha = src->alpha;
src++;
dest++;

View File

@@ -208,11 +208,28 @@ static void anim_exec_cb(void * var, int32_t v)
static void lottie_update(lv_lottie_t * lottie, int32_t v)
{
lv_obj_t * obj = (lv_obj_t *) lottie;
lv_draw_buf_t * draw_buf = lv_canvas_get_draw_buf(obj);
if(draw_buf) {
#if LV_USE_DRAW_VG_LITE && LV_USE_VG_LITE_THORVG
/**
* Since the buffer clearing operation in the SwRenderer::preRender
* function is removed when the VG-Lite simulator is enabled, the canvas
* buffer must be manually cleared here.
*/
lv_draw_buf_clear(draw_buf, NULL);
#endif
/*Drop old cached image*/
lv_image_cache_drop(lv_image_get_src(obj));
}
tvg_animation_set_frame(lottie->tvg_anim, v);
tvg_canvas_update(lottie->tvg_canvas);
tvg_canvas_draw(lottie->tvg_canvas);
tvg_canvas_sync(lottie->tvg_canvas);
lv_obj_invalidate((lv_obj_t *)lottie);
lv_obj_invalidate(obj);
}
#endif /*LV_USE_LOTTIE*/

View File

@@ -57,9 +57,16 @@ include(CTest)
set(LVGL_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SANITIZE_AND_COVERAGE_OPTIONS
-fsanitize=address
-fsanitize=leak
-fsanitize=undefined
--coverage
)
set(LVGL_TEST_OPTIONS_VG_LITE
-DLV_TEST_OPTION=6
-Wno-dangling-pointer # workaround for thorvg dangling-pointer warning
)
set(LVGL_TEST_OPTIONS_MINIMAL_MONOCHROME
@@ -86,16 +93,14 @@ set(LVGL_TEST_OPTIONS_TEST_SYSHEAP
-DLV_TEST_OPTION=5
-DLVGL_CI_USING_SYS_HEAP
-Wno-unused-but-set-variable # unused variables are common in the dual-heap arrangement
${SANITIZE_AND_COVERAGE_OPTIONS}
)
set(LVGL_TEST_OPTIONS_TEST_DEFHEAP
-DLV_TEST_OPTION=5
-DLV_USE_OBJ_PROPERTY=1 # add obj property test and disable pedantic
-DLVGL_CI_USING_DEF_HEAP
-fsanitize=address
-fsanitize=leak
-fsanitize=undefined
--coverage
${SANITIZE_AND_COVERAGE_OPTIONS}
)
if (OPTIONS_VG_LITE)
@@ -109,13 +114,13 @@ elseif (OPTIONS_24BIT)
elseif (OPTIONS_FULL_32BIT)
set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_FULL_32BIT})
elseif (OPTIONS_TEST_SYSHEAP)
set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_SYSHEAP} -fsanitize=address -fsanitize=leak -fsanitize=undefined --coverage)
filter_compiler_options (C TEST_LIBS --coverage -fsanitize=address -fsanitize=leak -fsanitize=undefined)
set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_SYSHEAP})
filter_compiler_options (C TEST_LIBS ${SANITIZE_AND_COVERAGE_OPTIONS})
set (LV_CONF_BUILD_DISABLE_EXAMPLES ON)
set (ENABLE_TESTS ON)
elseif (OPTIONS_TEST_DEFHEAP)
set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_DEFHEAP})
filter_compiler_options (C TEST_LIBS --coverage -fsanitize=address -fsanitize=leak -fsanitize=undefined)
filter_compiler_options (C TEST_LIBS ${SANITIZE_AND_COVERAGE_OPTIONS})
set (LV_CONF_BUILD_DISABLE_EXAMPLES ON)
set (ENABLE_TESTS ON)
elseif (OPTIONS_TEST_MEMORYCHECK)
@@ -124,6 +129,18 @@ elseif (OPTIONS_TEST_MEMORYCHECK)
set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_SYSHEAP})
set (LV_CONF_BUILD_DISABLE_EXAMPLES ON)
set (ENABLE_TESTS ON)
elseif (OPTIONS_TEST_VG_LITE)
set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_VG_LITE} -DLVGL_CI_USING_SYS_HEAP ${SANITIZE_AND_COVERAGE_OPTIONS})
filter_compiler_options (C TEST_LIBS ${SANITIZE_AND_COVERAGE_OPTIONS})
set (LV_CONF_BUILD_DISABLE_EXAMPLES ON)
set (ENABLE_TESTS ON)
add_definitions(-DREF_IMGS_PATH="ref_imgs_vg_lite/")
# In 32-bit systems, the output of ThorVG's anti-aliasing algorithm has a slight deviation.
if ($ENV{NON_AMD64_BUILD})
# Set a tolerance value for the VG-Lite tests.
add_definitions(-DREF_IMG_TOLERANCE=9)
endif()
else()
message(FATAL_ERROR "Must provide a known options value (check main.py?).")
endif()

View File

@@ -27,6 +27,7 @@ build_only_options = {
test_options = {
'OPTIONS_TEST_SYSHEAP': 'Test config, system heap, 32 bit color depth',
'OPTIONS_TEST_DEFHEAP': 'Test config, LVGL heap, 32 bit color depth',
'OPTIONS_TEST_VG_LITE': 'VG-Lite simulator with full config, 32 bit color depth',
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Some files were not shown because too many files have changed in this diff Show More