fix(tests): fix vg-lite buf address not aligned (#7049)
Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user