1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(draw): make tests work with non default LV_DRAW_BUF_ALIGN

This commit is contained in:
Gabor Kiss-Vamosi 2023-11-14 14:52:51 +01:00
parent 7ea8192208
commit f9c98905b9
6 changed files with 18 additions and 15 deletions

View File

@ -195,9 +195,9 @@ void lv_mem_monitor_core(lv_mem_monitor_t * mon_p)
lv_tlsf_walk_pool(*pool_p, lv_mem_walker, mon_p);
}
mon_p->used_pct = 100 - (100U * mon_p->free_size) / mon_p->total_size;
mon_p->used_pct = 100 - (uint64_t)100U * mon_p->free_size / mon_p->total_size;
if(mon_p->free_size > 0) {
mon_p->frag_pct = mon_p->free_biggest_size * 100U / mon_p->free_size;
mon_p->frag_pct = (uint64_t)mon_p->free_biggest_size * 100U / mon_p->free_size;
mon_p->frag_pct = 100 - mon_p->frag_pct;
}
else {

View File

@ -86,8 +86,11 @@ typedef void * lv_user_data_t;
#if defined(LVGL_CI_USING_SYS_HEAP) || defined(LVGL_CI_USING_DEF_HEAP)
#undef LV_LOG_PRINTF
/*Use a large value be sure any issues will cause crash*/
//#define LV_DRAW_BUF_STRIDE_ALIGN 64
//#define LV_DRAW_BUF_ALIGN 40 /*Use non power of 2 to avoid the case when `malloc` returns aligned pointer by default*/
/*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
/*For screenshots*/
#undef LV_USE_PERF_MONITOR

View File

@ -1,4 +1,4 @@
#if LV_BUILD_TEST
#if LV_BUILD_TEST || 1
#include "lv_test_init.h"
#include "lv_test_indev.h"
#include <sys/time.h>
@ -31,9 +31,10 @@ void lv_test_deinit(void)
static void hal_init(void)
{
static lv_color32_t test_fb[HOR_RES * VER_RES * 2];
static lv_color32_t test_fb[(HOR_RES + LV_DRAW_BUF_STRIDE_ALIGN - 1) * VER_RES + LV_DRAW_BUF_ALIGN];
lv_display_t * disp = lv_display_create(HOR_RES, VER_RES);
lv_display_set_draw_buffers(disp, test_fb, NULL, HOR_RES * VER_RES, LV_DISPLAY_RENDER_MODE_DIRECT);
lv_display_set_draw_buffers(disp, lv_draw_buf_align(test_fb, LV_COLOR_FORMAT_ARGB8888), NULL, HOR_RES * VER_RES,
LV_DISPLAY_RENDER_MODE_DIRECT);
lv_display_set_flush_cb(disp, dummy_flush_cb);
lv_test_mouse_indev = lv_indev_create();

View File

@ -204,7 +204,8 @@ static void canvas_draw(const char * name, void (*draw_cb)(lv_layer_t *))
{
static uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(640, 4) * 480 + LV_DRAW_BUF_ALIGN];
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
lv_canvas_set_buffer(canvas, canvas_buf, 640, 480, LV_COLOR_FORMAT_ARGB8888);
lv_canvas_set_buffer(canvas, lv_draw_buf_align(canvas_buf, LV_COLOR_FORMAT_ARGB8888), 640, 480,
LV_COLOR_FORMAT_ARGB8888);
lv_layer_t layer;
lv_canvas_init_layer(canvas, &layer);

View File

@ -1,4 +1,5 @@
#if LV_BUILD_TEST || 1
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
@ -77,10 +78,8 @@ void test_anim_timeline_progress_1(void)
lv_refr_now(NULL);
TEST_ASSERT_EQUAL(700, lv_obj_get_x(obj));
}
void test_anim_timeline_progress_2(void)
{
lv_obj_t * obj = lv_obj_create(lv_scr_act());
@ -106,7 +105,6 @@ void test_anim_timeline_progress_2(void)
* 0 21845 43690 65535 progress
*/
anim_timeline = lv_anim_timeline_create();
lv_anim_timeline_add(anim_timeline, 0, &a1);
lv_anim_timeline_add(anim_timeline, 500, &a2);
@ -146,5 +144,4 @@ void test_anim_timeline_progress_2(void)
TEST_ASSERT_EQUAL(300, lv_obj_get_y(obj));
}
#endif

View File

@ -1,8 +1,9 @@
#if LV_BUILD_TEST || 1
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
#include "lv_test_indev.h"
#include "lv_test_helpers.h"
static void create_ui(void);
static void chart_type_observer_cb(lv_subject_t * subject, lv_observer_t * observer);
@ -152,12 +153,12 @@ static void create_ui(void)
}
/*Large byte array*/
static uint8_t canvas_buf[400 * 100 * 2];
static uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(400, 2) * 100 * 2];
lv_obj_t * canvas = lv_canvas_create(scr);
lv_obj_set_grid_cell(canvas, LV_GRID_ALIGN_START, 0, 2, LV_GRID_ALIGN_START, 2, 1);
/*Test RGB565 rendering*/
lv_canvas_set_buffer(canvas, canvas_buf, 400, 100, LV_COLOR_FORMAT_RGB565);
lv_canvas_set_buffer(canvas, lv_draw_buf_align(canvas_buf, LV_COLOR_FORMAT_RGB565), 400, 100, LV_COLOR_FORMAT_RGB565);
lv_canvas_fill_bg(canvas, c2, LV_OPA_COVER);
draw_to_canvas(canvas);