fix(tests): fix vg-lite buf address not aligned (#7049)
Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
@ -768,6 +768,21 @@ static lv_obj_t * create_blend_mode_obj(lv_obj_t * parent, int32_t col, int32_t
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void canvas_draw_buf_reshape(lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
#if LV_USE_DRAW_VG_LITE
|
||||
/* VG-Lite requires automatic stride calculation */
|
||||
lv_draw_buf_t * buf = lv_draw_buf_reshape(draw_buf,
|
||||
draw_buf->header.cf,
|
||||
draw_buf->header.w,
|
||||
draw_buf->header.h,
|
||||
LV_STRIDE_AUTO);
|
||||
LV_ASSERT_MSG(buf == draw_buf, "Reshape failed");
|
||||
#else
|
||||
LV_UNUSED(draw_buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void blend_mode_cb(lv_obj_t * parent)
|
||||
{
|
||||
|
||||
@ -778,17 +793,16 @@ static void blend_mode_cb(lv_obj_t * parent)
|
||||
/*Make the parent darker for additive blending*/
|
||||
lv_obj_set_style_bg_color(parent, lv_color_hex(0x808080), 0);
|
||||
|
||||
static uint8_t buf_rgb565[LV_CANVAS_BUF_SIZE(36, 30, 16, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
static uint8_t buf_rgb888[LV_CANVAS_BUF_SIZE(36, 30, 24, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
static uint8_t buf_xrgb8888[LV_CANVAS_BUF_SIZE(36, 30, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
static uint8_t buf_argb8888[LV_CANVAS_BUF_SIZE(36, 30, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_rgb565, 36, 30, LV_COLOR_FORMAT_RGB565);
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_rgb888, 36, 30, LV_COLOR_FORMAT_RGB888);
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_xrgb8888, 36, 30, LV_COLOR_FORMAT_XRGB8888);
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_argb8888, 36, 30, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
/*The canvas will stay in the top left corner to show the original image*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
|
||||
const char * cf_txt[] = {"RGB565", "RGB888.", "XRGB8888", "ARGB8888"};
|
||||
lv_color_format_t cf_values[] = {LV_COLOR_FORMAT_RGB565, LV_COLOR_FORMAT_RGB888, LV_COLOR_FORMAT_XRGB8888, LV_COLOR_FORMAT_ARGB8888};
|
||||
uint8_t * cf_bufs[] = {buf_rgb565, buf_rgb888, buf_xrgb8888, buf_argb8888};
|
||||
lv_draw_buf_t * cf_bufs[] = {&buf_rgb565, &buf_rgb888, &buf_xrgb8888, &buf_argb8888};
|
||||
static lv_draw_buf_t image_dscs[4];
|
||||
|
||||
const char * mode_txt[] = {"Add.", "Sub.", "Mul."};
|
||||
@ -807,7 +821,8 @@ static void blend_mode_cb(lv_obj_t * parent)
|
||||
lv_label_set_text(cf_label, cf_txt[cf]);
|
||||
lv_obj_set_grid_cell(cf_label, LV_GRID_ALIGN_CENTER, 1 + cf * 2, 2, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
lv_canvas_set_buffer(canvas, cf_bufs[cf], 36, 30, cf_values[cf]);
|
||||
canvas_draw_buf_reshape(cf_bufs[cf]);
|
||||
lv_canvas_set_draw_buf(canvas, cf_bufs[cf]);
|
||||
create_blend_mode_image_buffer(canvas);
|
||||
lv_draw_buf_t * img_src = lv_canvas_get_draw_buf(canvas);
|
||||
image_dscs[cf] = *img_src;
|
||||
|
@ -48,7 +48,7 @@ LV_EXPORT_CONST_INT(LV_STRIDE_AUTO);
|
||||
* For platform that needs special buffer alignment, call LV_DRAW_BUF_INIT_STATIC.
|
||||
*/
|
||||
#define LV_DRAW_BUF_DEFINE_STATIC(name, _w, _h, _cf) \
|
||||
static uint8_t buf_##name[LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
|
||||
static LV_ATTRIBUTE_MEM_ALIGN uint8_t buf_##name[LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
|
||||
static lv_draw_buf_t name = { \
|
||||
.header = { \
|
||||
.magic = LV_IMAGE_HEADER_MAGIC, \
|
||||
|
@ -247,9 +247,6 @@ static void stroke_free_cb(stroke_item_t * item, void * user_data)
|
||||
|
||||
static lv_cache_compare_res_t path_compare(const vg_lite_path_t * lhs, const vg_lite_path_t * rhs)
|
||||
{
|
||||
LV_VG_LITE_ASSERT_PATH(lhs);
|
||||
LV_VG_LITE_ASSERT_PATH(rhs);
|
||||
|
||||
LV_ASSERT(lhs->format == VG_LITE_FP32);
|
||||
LV_ASSERT(rhs->format == VG_LITE_FP32);
|
||||
|
||||
|
@ -430,6 +430,8 @@ bool lv_vg_lite_is_src_cf_supported(lv_color_format_t cf)
|
||||
case LV_COLOR_FORMAT_I1:
|
||||
case LV_COLOR_FORMAT_I2:
|
||||
case LV_COLOR_FORMAT_I4:
|
||||
return vg_lite_query_feature(gcFEATURE_BIT_VG_INDEX_ENDIAN) ? true : false;
|
||||
|
||||
case LV_COLOR_FORMAT_I8:
|
||||
return vg_lite_query_feature(gcFEATURE_BIT_VG_IM_INDEX_FORMAT) ? true : false;
|
||||
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
@ -70,6 +70,14 @@ typedef void * lv_user_data_t;
|
||||
#elif LV_TEST_OPTION == 6
|
||||
#define LV_COLOR_DEPTH 32
|
||||
#define LV_DPI_DEF 160
|
||||
|
||||
#define LV_DRAW_BUF_ALIGN 64
|
||||
#ifdef _MSC_VER
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN __declspec(align(LV_DRAW_BUF_ALIGN))
|
||||
#else
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN __attribute__((aligned(LV_DRAW_BUF_ALIGN)))
|
||||
#endif
|
||||
|
||||
#include "lv_test_conf_vg_lite.h"
|
||||
#include "lv_test_conf_full.h"
|
||||
#elif LV_TEST_OPTION == 7
|
||||
@ -102,8 +110,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
|
||||
|
||||
#ifndef 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_DPI_DEF
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "lv_test_indev.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "../unity/unity.h"
|
||||
|
||||
#define HOR_RES 800
|
||||
@ -96,7 +97,11 @@ static void test_log_print_cb(lv_log_level_t level, const char * buf)
|
||||
|
||||
void lv_test_assert_fail(void)
|
||||
{
|
||||
/*Flush the output*/
|
||||
fflush(stdout);
|
||||
|
||||
/*Handle error on test*/
|
||||
assert(false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -123,7 +123,7 @@ static void canvas_draw(const char * name, lv_color_format_t large_render_cf)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
|
||||
static uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(180, 4) * 180 + LV_DRAW_BUF_ALIGN];
|
||||
static LV_ATTRIBUTE_MEM_ALIGN uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(180, 4) * 180 + LV_DRAW_BUF_ALIGN];
|
||||
|
||||
static uint8_t canvas2_buf[CANVAS_WIDTH_TO_STRIDE(768, 4) * 390 + LV_DRAW_BUF_ALIGN];
|
||||
lv_obj_t * canvas2 = lv_canvas_create(lv_screen_active());
|
||||
|
@ -21,6 +21,22 @@ static void draw_event_cb(lv_event_t * e)
|
||||
int * draw_counter = lv_event_get_user_data(e);
|
||||
(*draw_counter)++;
|
||||
}
|
||||
|
||||
static void canvas_draw_buf_reshape(lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
#if LV_USE_DRAW_VG_LITE
|
||||
/* VG-Lite requires automatic stride calculation */
|
||||
lv_draw_buf_t * buf = lv_draw_buf_reshape(draw_buf,
|
||||
draw_buf->header.cf,
|
||||
draw_buf->header.w,
|
||||
draw_buf->header.h,
|
||||
LV_STRIDE_AUTO);
|
||||
TEST_ASSERT(buf == draw_buf);
|
||||
#else
|
||||
LV_UNUSED(draw_buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_canvas_functions_invalidate(void)
|
||||
{
|
||||
lv_obj_t * canvas = lv_canvas_create(g_screen_active);
|
||||
@ -31,6 +47,7 @@ void test_canvas_functions_invalidate(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(draw_buf, 100, 100, LV_COLOR_FORMAT_NATIVE);
|
||||
LV_DRAW_BUF_INIT_STATIC(draw_buf);
|
||||
canvas_draw_buf_reshape(&draw_buf);
|
||||
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
lv_refr_now(NULL);
|
||||
@ -69,6 +86,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_i1, 10, 10, LV_COLOR_FORMAT_I1);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_i1);
|
||||
canvas_draw_buf_reshape(&buf_i1);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_i1);
|
||||
lv_canvas_set_palette(canvas, 0, lv_color32_make(0x00, 0xff, 0x00, 0xff));
|
||||
lv_canvas_set_palette(canvas, 1, lv_color32_make(0x00, 0x00, 0xff, 0xff));
|
||||
@ -78,6 +96,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_i2, 10, 10, LV_COLOR_FORMAT_I2);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_i2);
|
||||
canvas_draw_buf_reshape(&buf_i2);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_i2);
|
||||
lv_canvas_set_palette(canvas, 0, lv_color32_make(0x00, 0xff, 0x00, 0xff));
|
||||
lv_canvas_set_palette(canvas, 3, lv_color32_make(0x00, 0x00, 0xff, 0xff));
|
||||
@ -87,6 +106,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_i4, 10, 10, LV_COLOR_FORMAT_I4);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_i4);
|
||||
canvas_draw_buf_reshape(&buf_i4);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_i4);
|
||||
lv_canvas_set_palette(canvas, 0, lv_color32_make(0x00, 0xff, 0x00, 0xff));
|
||||
lv_canvas_set_palette(canvas, 15, lv_color32_make(0x00, 0x00, 0xff, 0xff));
|
||||
@ -96,6 +116,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_i8, 10, 10, LV_COLOR_FORMAT_I8);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_i8);
|
||||
canvas_draw_buf_reshape(&buf_i8);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_i8);
|
||||
lv_canvas_set_palette(canvas, 0, lv_color32_make(0x00, 0xff, 0x00, 0xff));
|
||||
lv_canvas_set_palette(canvas, 255, lv_color32_make(0x00, 0x00, 0xff, 0xff));
|
||||
@ -105,6 +126,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_rgb888, 10, 10, LV_COLOR_FORMAT_RGB888);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_rgb888);
|
||||
canvas_draw_buf_reshape(&buf_rgb888);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_rgb888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex(0x00ff00), LV_OPA_COVER);
|
||||
lv_canvas_set_px(canvas, 1, 7, lv_color_hex(0x0000ff), 0);
|
||||
@ -112,6 +134,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_rgb565, 10, 10, LV_COLOR_FORMAT_RGB565);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_rgb565);
|
||||
canvas_draw_buf_reshape(&buf_rgb565);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_rgb565);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex(0x00ff00), LV_OPA_COVER);
|
||||
lv_canvas_set_px(canvas, 1, 7, lv_color_hex(0x0000ff), 0);
|
||||
@ -119,6 +142,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_xrgb8888, 10, 10, LV_COLOR_FORMAT_XRGB8888);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_xrgb8888);
|
||||
canvas_draw_buf_reshape(&buf_xrgb8888);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_xrgb8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex(0x00ff00), LV_OPA_COVER);
|
||||
lv_canvas_set_px(canvas, 1, 7, lv_color_hex(0x0000ff), 0);
|
||||
@ -126,6 +150,7 @@ void test_canvas_fill_and_set_px(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(buf_argb8888, 10, 10, LV_COLOR_FORMAT_ARGB8888);
|
||||
LV_DRAW_BUF_INIT_STATIC(buf_argb8888);
|
||||
canvas_draw_buf_reshape(&buf_argb8888);
|
||||
lv_canvas_set_draw_buf(canvas, &buf_argb8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex(0x00ff00), LV_OPA_COVER);
|
||||
lv_canvas_set_px(canvas, 1, 7, lv_color_hex(0x0000ff), LV_OPA_COVER);
|
||||
|