Skip to content

Commit

Permalink
chore(test): only do rotation test when image loaded to RAM
Browse files Browse the repository at this point in the history
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>

get-area-fix

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
  • Loading branch information
XuNeo committed Dec 6, 2023
1 parent e56ad3d commit 0528328
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
23 changes: 16 additions & 7 deletions src/draw/sw/lv_draw_sw_img.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,23 @@ static void img_decode_and_draw(lv_draw_unit_t * draw_unit, const lv_draw_image_
lv_area_t decoded_area = {
.x1 = 0,
.y1 = 0,
.x2 = decoded->header.w - 1,
.y2 = decoded->header.h - 1,
.x2 = decoder_dsc->header.w - 1,
.y2 = decoder_dsc->header.h - 1,
};

_lv_area_intersect(&relative_full_area_to_decode, &relative_full_area_to_decode, &decoded_area);

decoded_area.x2 = decoded->header.w - 1;
decoded_area.y2 = decoded->header.h - 1;

/*Decoded image can be used.*/
if(_lv_area_intersect(&decoded_area, &relative_full_area_to_decode, &decoded_area)) {
if(_lv_area_is_in(&relative_full_area_to_decode, &decoded_area, 0)) {
img_draw_core(draw_unit, draw_dsc, decoder_dsc, &sup, img_area, clipped_img_area);
return;
}
else {
LV_LOG_USER("area not ready");
}
}

/*Draw in smaller pieces*/
Expand Down Expand Up @@ -319,10 +327,11 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t

cf = LV_COLOR_FORMAT_IS_INDEXED(cf) ? LV_COLOR_FORMAT_ARGB8888 : cf;

if(decoder_dsc->decoded) {
src_buf = decoder_dsc->decoded->data;
img_stride = decoder_dsc->decoded->header.stride;
cf = decoder_dsc->decoded->header.cf;
const lv_draw_buf_t * decoded = decoder_dsc->decoded;
if(decoded) {
src_buf = decoded->data;
img_stride = decoded->header.stride;
cf = decoded->header.cf;
}

lv_memzero(&blend_dsc, sizeof(lv_draw_sw_blend_dsc_t));
Expand Down
12 changes: 8 additions & 4 deletions tests/src/test_cases/draw/test_image_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void test_image_built_in_decode(void)

void test_image_built_in_decode_rotate(void)
{
#if LV_BIN_DECODER_RAM_LOAD
LV_IMAGE_DECLARE(test_image_cogwheel_i4);
LV_IMAGE_DECLARE(test_image_cogwheel_a8);
LV_IMAGE_DECLARE(test_image_cogwheel_rgb565);
Expand All @@ -95,6 +96,7 @@ void test_image_built_in_decode_rotate(void)
img_create("binARGB8888", "A:src/test_files/binimages/cogwheel.ARGB8888.bin", true, false);

TEST_ASSERT_EQUAL_SCREENSHOT("draw/image_format_rotated.png");
#endif
}

void test_image_built_in_decode_recolor(void)
Expand Down Expand Up @@ -129,6 +131,7 @@ void test_image_built_in_decode_recolor(void)

void test_image_built_in_decode_rotate_and_recolor(void)
{
#if LV_BIN_DECODER_RAM_LOAD
LV_IMAGE_DECLARE(test_image_cogwheel_i4);
LV_IMAGE_DECLARE(test_image_cogwheel_a8);
LV_IMAGE_DECLARE(test_image_cogwheel_rgb565);
Expand All @@ -155,6 +158,7 @@ void test_image_built_in_decode_rotate_and_recolor(void)
img_create("binARGB8888", "A:src/test_files/binimages/cogwheel.ARGB8888.bin", true, true);

TEST_ASSERT_EQUAL_SCREENSHOT("draw/image_format_rotate_and_recolor.png");
#endif
}

void test_image_rle_compressed_decode(void)
Expand All @@ -180,7 +184,7 @@ void test_image_rle_compressed_decode(void)

void test_image_rle_compressed_decode_rotate(void)
{
#if LV_USE_RLE
#if LV_USE_RLE && LV_BIN_DECODER_RAM_LOAD
img_create("rleA1", "A:src/test_files/rle_compressed/cogwheel.A1.bin", true, false);
img_create("rleA2", "A:src/test_files/rle_compressed/cogwheel.A2.bin", true, false);
img_create("rleA4", "A:src/test_files/rle_compressed/cogwheel.A4.bin", true, false);
Expand All @@ -201,7 +205,7 @@ void test_image_rle_compressed_decode_rotate(void)

void test_image_rle_compressed_decode_rotate_recolor(void)
{
#if LV_USE_RLE
#if LV_USE_RLE && LV_BIN_DECODER_RAM_LOAD
img_create("rleA1", "A:src/test_files/rle_compressed/cogwheel.A1.bin", true, true);
img_create("rleA2", "A:src/test_files/rle_compressed/cogwheel.A2.bin", true, true);
img_create("rleA4", "A:src/test_files/rle_compressed/cogwheel.A4.bin", true, true);
Expand Down Expand Up @@ -243,7 +247,7 @@ void test_image_lz4_compressed_decode(void)

void test_image_lz4_compressed_decode_rotate(void)
{
#if LV_USE_LZ4
#if LV_USE_LZ4 && LV_BIN_DECODER_RAM_LOAD
img_create("lz4A1", "A:src/test_files/lz4_compressed/cogwheel.A1.bin", true, false);
img_create("lz4A2", "A:src/test_files/lz4_compressed/cogwheel.A2.bin", true, false);
img_create("lz4A4", "A:src/test_files/lz4_compressed/cogwheel.A4.bin", true, false);
Expand All @@ -264,7 +268,7 @@ void test_image_lz4_compressed_decode_rotate(void)

void test_image_lz4_compressed_decode_rotate_recolor(void)
{
#if LV_USE_LZ4
#if LV_USE_LZ4 && LV_BIN_DECODER_RAM_LOAD
img_create("lz4A1", "A:src/test_files/lz4_compressed/cogwheel.A1.bin", true, true);
img_create("lz4A2", "A:src/test_files/lz4_compressed/cogwheel.A2.bin", true, true);
img_create("lz4A4", "A:src/test_files/lz4_compressed/cogwheel.A4.bin", true, true);
Expand Down

0 comments on commit 0528328

Please sign in to comment.