feat(libs): add libjpeg-turbo decoder (#4567)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -176,6 +176,10 @@ set(generate_test_runner_rb
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/unity/generate_test_runner.rb)
|
||||
set(generate_test_runner_config ${CMAKE_CURRENT_SOURCE_DIR}/config.yml)
|
||||
|
||||
# libjpeg is required for the jpeg test case
|
||||
find_package(JPEG REQUIRED)
|
||||
include_directories(${JPEG_INCLUDE_DIR})
|
||||
|
||||
# disable test targets for build only tests
|
||||
if (ENABLE_TESTS)
|
||||
file( GLOB_RECURSE TEST_CASE_FILES src/test_cases/*.c )
|
||||
@@ -204,7 +208,7 @@ foreach( test_case_fname ${TEST_CASE_FILES} )
|
||||
${test_case_fname}
|
||||
${test_runner_fname}
|
||||
)
|
||||
target_link_libraries(${test_name} test_common lvgl_demos lvgl png m ${TEST_LIBS})
|
||||
target_link_libraries(${test_name} test_common lvgl_demos lvgl png ${JPEG_LIBRARIES} m ${TEST_LIBS})
|
||||
target_include_directories(${test_name} PUBLIC ${TEST_INCLUDE_DIRS})
|
||||
target_compile_options(${test_name} PUBLIC ${LVGL_TESTFILE_COMPILE_OPTIONS})
|
||||
|
||||
|
||||
BIN
tests/ref_imgs/libs/jpg_2.png
Normal file
BIN
tests/ref_imgs/libs/jpg_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
@@ -64,6 +64,7 @@
|
||||
#define LV_USE_LODEPNG 1
|
||||
#define LV_USE_BMP 1
|
||||
#define LV_USE_TJPGD 1
|
||||
#define LV_USE_LIBJPEG_TURBO 1
|
||||
#define LV_USE_GIF 1
|
||||
#define LV_USE_QRCODE 1
|
||||
#define LV_USE_BARCODE 1
|
||||
|
||||
54
tests/src/test_cases/libs/test_libjpeg_turbo.c
Normal file
54
tests/src/test_cases/libs/test_libjpeg_turbo.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
#include "lv_test_helpers.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
/* Function run before every test */
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
/* Function run after every test */
|
||||
}
|
||||
|
||||
static void create_images(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_t * img;
|
||||
|
||||
img = lv_img_create(lv_scr_act());
|
||||
lv_img_set_src(img, "A:src/test_assets/test_img_lvgl_logo.jpg");
|
||||
lv_obj_center(img);
|
||||
}
|
||||
|
||||
void test_jpg_2(void)
|
||||
{
|
||||
/* Temporarily remove tjpgd decoder */
|
||||
lv_tjpgd_deinit();
|
||||
|
||||
create_images();
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/jpg_2.png");
|
||||
|
||||
|
||||
uint32_t mem_before = lv_test_get_free_mem();
|
||||
for(uint32_t i = 0; i < 20; i++) {
|
||||
create_images();
|
||||
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
lv_refr_now(NULL);
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/jpg_2.png");
|
||||
|
||||
TEST_ASSERT_EQUAL(mem_before, lv_test_get_free_mem());
|
||||
|
||||
/* Re-add tjpgd decoder */
|
||||
lv_tjpgd_init();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -41,6 +41,9 @@ static void create_images(void)
|
||||
|
||||
void test_tjpgd_1(void)
|
||||
{
|
||||
/* Temporarily remove libjpeg_turbo decoder */
|
||||
lv_libjpeg_turbo_deinit();
|
||||
|
||||
create_images();
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/jpg_1.png");
|
||||
@@ -58,6 +61,8 @@ void test_tjpgd_1(void)
|
||||
|
||||
TEST_ASSERT_EQUAL(mem_before, lv_test_get_free_mem());
|
||||
|
||||
/* Re-add libjpeg_turbo decoder */
|
||||
lv_libjpeg_turbo_init();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user