fix(draw) fix stride realted bugs in SW render
@@ -179,7 +179,8 @@ static void * align_buf(void * buf, lv_color_format_t color_format)
|
||||
|
||||
static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format)
|
||||
{
|
||||
uint32_t width_byte = w * lv_color_format_get_size(color_format);
|
||||
uint32_t width_byte;
|
||||
width_byte = w * lv_color_format_get_size(color_format);
|
||||
return (width_byte + LV_DRAW_BUF_STRIDE_ALIGN - 1) & ~(LV_DRAW_BUF_STRIDE_ALIGN - 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void lv_draw_sw_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle_dsc_
|
||||
void lv_draw_sw_mask_rect(lv_draw_unit_t * draw_unit, const lv_draw_mask_rect_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_area, const void * src_buf,
|
||||
lv_coord_t src_w, lv_coord_t src_h,
|
||||
lv_coord_t src_w, lv_coord_t src_h, lv_coord_t src_stride,
|
||||
const lv_draw_image_dsc_t * draw_dsc, const lv_draw_image_sup_t * sup, lv_color_format_t cf, void * dest_buf);
|
||||
|
||||
/***********************
|
||||
|
||||
@@ -285,42 +285,38 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
}
|
||||
|
||||
uint32_t px_size = lv_color_format_get_size(cf_final);
|
||||
uint32_t max_buf_size = MAX_BUF_SIZE / px_size;
|
||||
uint32_t buf_stride = lv_draw_buf_width_to_stride(blend_w, cf_final);
|
||||
uint32_t buf_h;
|
||||
if(buf_stride * blend_h <= max_buf_size) buf_h = blend_h;
|
||||
else buf_h = max_buf_size / buf_stride; /*Round to full lines*/
|
||||
lv_coord_t buf_h = MAX_BUF_SIZE / buf_stride;
|
||||
if(buf_h > blend_h) buf_h = blend_h;
|
||||
|
||||
uint32_t buf_size = buf_stride * buf_h;
|
||||
uint8_t * tmp_buf = lv_malloc(buf_size);
|
||||
blend_dsc.src_buf = tmp_buf;
|
||||
uint8_t * tmp_buf = lv_malloc(buf_stride * buf_h);
|
||||
uint8_t * tmp_buf_aligned = lv_draw_buf_align_buf(tmp_buf, cf_final);
|
||||
blend_dsc.src_buf = tmp_buf_aligned;
|
||||
blend_dsc.src_color_format = cf_final;
|
||||
lv_coord_t y_last = blend_area.y2;
|
||||
blend_area.y2 = blend_area.y1 + buf_h - 1;
|
||||
|
||||
blend_dsc.src_area = &blend_area;
|
||||
if(cf_final == LV_COLOR_FORMAT_RGB565A8) {
|
||||
/*RGB565A8 images will blended as RGB565 + mask
|
||||
*Therefore the stride can be different. */
|
||||
blend_dsc.src_stride = lv_draw_buf_width_to_stride(blend_w, LV_COLOR_FORMAT_RGB565);
|
||||
}
|
||||
else {
|
||||
blend_dsc.src_stride = buf_stride;
|
||||
}
|
||||
|
||||
|
||||
if(cf_final == LV_COLOR_FORMAT_RGB565A8) {
|
||||
blend_dsc.mask_buf = tmp_buf + lv_draw_buf_width_to_stride(blend_w, LV_COLOR_FORMAT_RGB565) * buf_h;
|
||||
blend_dsc.mask_buf = tmp_buf_aligned + lv_draw_buf_width_to_stride(blend_w, LV_COLOR_FORMAT_RGB565) * buf_h;
|
||||
blend_dsc.mask_area = &blend_area;
|
||||
blend_dsc.mask_res = LV_DRAW_SW_MASK_RES_CHANGED;
|
||||
blend_dsc.src_color_format = LV_COLOR_FORMAT_RGB565;
|
||||
}
|
||||
|
||||
if(blend_dsc.src_color_format == LV_COLOR_FORMAT_A8) {
|
||||
else if(cf_final == LV_COLOR_FORMAT_A8) {
|
||||
blend_dsc.mask_buf = blend_dsc.src_buf;
|
||||
blend_dsc.mask_area = &blend_area;
|
||||
blend_dsc.mask_res = LV_DRAW_SW_MASK_RES_CHANGED;
|
||||
blend_dsc.color = draw_dsc->recolor;
|
||||
blend_dsc.src_buf = NULL;
|
||||
}
|
||||
else {
|
||||
blend_dsc.src_stride = buf_stride;
|
||||
}
|
||||
|
||||
|
||||
while(blend_area.y1 <= y_last) {
|
||||
/*Apply transformations if any or separate the channels*/
|
||||
@@ -328,8 +324,8 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
lv_area_copy(&relative_area, &blend_area);
|
||||
lv_area_move(&relative_area, -img_coords->x1, -img_coords->y1);
|
||||
if(transformed) {
|
||||
lv_draw_sw_transform(draw_unit, &relative_area, src_buf, src_w, src_h,
|
||||
draw_dsc, sup, cf, tmp_buf);
|
||||
lv_draw_sw_transform(draw_unit, &relative_area, src_buf, src_w, src_h, img_stride,
|
||||
draw_dsc, sup, cf, tmp_buf_aligned);
|
||||
}
|
||||
else if(draw_dsc->recolor_opa >= LV_OPA_MIN) {
|
||||
lv_coord_t h = lv_area_get_height(&relative_area);
|
||||
@@ -337,7 +333,7 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
const uint8_t * rgb_src_buf = src_buf + blend_dsc.src_stride * relative_area.y1 + relative_area.x1 * 2;
|
||||
const uint8_t * a_src_buf = src_buf + blend_dsc.src_stride * src_h + blend_dsc.src_stride / 2 * relative_area.y1 +
|
||||
relative_area.x1;
|
||||
uint8_t * rgb_dest_buf = tmp_buf;
|
||||
uint8_t * rgb_dest_buf = tmp_buf_aligned;
|
||||
uint8_t * a_dest_buf = (uint8_t *)blend_dsc.mask_buf;
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < h; i++) {
|
||||
@@ -351,7 +347,7 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
}
|
||||
else if(cf_final != LV_COLOR_FORMAT_A8) {
|
||||
const uint8_t * src_buf_tmp = src_buf + blend_dsc.src_stride * relative_area.y1 + relative_area.x1 * px_size;
|
||||
uint8_t * dest_buf_tmp = tmp_buf;
|
||||
uint8_t * dest_buf_tmp = tmp_buf_aligned;
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < h; i++) {
|
||||
lv_memcpy(dest_buf_tmp, src_buf_tmp, blend_w * px_size);
|
||||
@@ -371,7 +367,7 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
c_mult[0] = (color.blue >> 3) * mix;
|
||||
c_mult[1] = (color.green >> 2) * mix;
|
||||
c_mult[2] = (color.red >> 3) * mix;
|
||||
uint16_t * buf16 = (uint16_t *)tmp_buf;
|
||||
uint16_t * buf16 = (uint16_t *)tmp_buf_aligned;
|
||||
lv_coord_t i;
|
||||
lv_coord_t size = lv_draw_buf_width_to_stride(blend_w, LV_COLOR_FORMAT_RGB565) / 2 * lv_area_get_height(&blend_area);
|
||||
for(i = 0; i < size; i++) {
|
||||
@@ -387,7 +383,7 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
c_mult[0] = color.blue * mix;
|
||||
c_mult[1] = color.green * mix;
|
||||
c_mult[2] = color.red * mix;
|
||||
uint8_t * tmp_buf_2 = tmp_buf;
|
||||
uint8_t * tmp_buf_2 = tmp_buf_aligned;
|
||||
for(i = 0; i < size * px_size; i += px_size) {
|
||||
tmp_buf_2[i + 0] = (c_mult[0] + (tmp_buf_2[i + 0] * mix_inv)) >> 8;
|
||||
tmp_buf_2[i + 1] = (c_mult[1] + (tmp_buf_2[i + 1] * mix_inv)) >> 8;
|
||||
@@ -405,13 +401,13 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
if(blend_area.y2 > y_last) {
|
||||
blend_area.y2 = y_last;
|
||||
if(cf_final == LV_COLOR_FORMAT_RGB565A8) {
|
||||
blend_dsc.mask_buf = tmp_buf + lv_draw_buf_width_to_stride(blend_w,
|
||||
LV_COLOR_FORMAT_RGB565) * lv_area_get_height(&blend_area);
|
||||
blend_dsc.mask_buf = tmp_buf_aligned + lv_draw_buf_width_to_stride(blend_w,
|
||||
LV_COLOR_FORMAT_RGB565) * lv_area_get_height(&blend_area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lv_free(tmp_buf);
|
||||
lv_draw_buf_free(tmp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ static void transform_a8(const uint8_t * src, lv_coord_t src_w, lv_coord_t src_h
|
||||
**********************/
|
||||
|
||||
void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_area, const void * src_buf,
|
||||
lv_coord_t src_w, lv_coord_t src_h,
|
||||
lv_coord_t src_w, lv_coord_t src_h, lv_coord_t src_stride,
|
||||
const lv_draw_image_dsc_t * draw_dsc, const lv_draw_image_sup_t * sup, lv_color_format_t src_cf, void * dest_buf)
|
||||
{
|
||||
LV_UNUSED(draw_unit);
|
||||
@@ -110,13 +110,22 @@ void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_are
|
||||
|
||||
lv_coord_t dest_w = lv_area_get_width(dest_area);
|
||||
lv_coord_t dest_h = lv_area_get_height(dest_area);
|
||||
lv_coord_t src_stride = lv_draw_buf_width_to_stride(src_w, src_cf) / lv_color_format_get_size(src_cf);
|
||||
|
||||
lv_coord_t dest_stride_a8 = lv_draw_buf_width_to_stride(dest_w, LV_COLOR_FORMAT_A8);
|
||||
lv_coord_t dest_stride_a8 = dest_w;
|
||||
lv_coord_t dest_stride;
|
||||
if(src_cf == LV_COLOR_FORMAT_RGB888) dest_stride = lv_draw_buf_width_to_stride(dest_w, LV_COLOR_FORMAT_ARGB8888);
|
||||
else if(src_cf == LV_COLOR_FORMAT_RGB565A8) dest_stride = lv_draw_buf_width_to_stride(dest_w, LV_COLOR_FORMAT_RGB565);
|
||||
else dest_stride = lv_draw_buf_width_to_stride(dest_w, src_cf);
|
||||
lv_coord_t src_stride_px;
|
||||
if(src_cf == LV_COLOR_FORMAT_RGB888) {
|
||||
dest_stride = lv_draw_buf_width_to_stride(dest_w, LV_COLOR_FORMAT_ARGB8888);
|
||||
src_stride_px = src_stride / lv_color_format_get_size(LV_COLOR_FORMAT_RGB888);
|
||||
}
|
||||
else if(src_cf == LV_COLOR_FORMAT_RGB565A8) {
|
||||
dest_stride = lv_draw_buf_width_to_stride(dest_w, LV_COLOR_FORMAT_RGB565);
|
||||
src_stride_px = src_stride / lv_color_format_get_size(LV_COLOR_FORMAT_RGB565);
|
||||
}
|
||||
else {
|
||||
dest_stride = lv_draw_buf_width_to_stride(dest_w, src_cf);
|
||||
src_stride_px = src_stride / lv_color_format_get_size(src_cf);
|
||||
}
|
||||
|
||||
uint8_t * alpha_buf;
|
||||
if(src_cf == LV_COLOR_FORMAT_RGB565 || src_cf == LV_COLOR_FORMAT_RGB565A8) {
|
||||
@@ -150,23 +159,25 @@ void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_are
|
||||
|
||||
switch(src_cf) {
|
||||
case LV_COLOR_FORMAT_XRGB8888:
|
||||
tranform_rgb888(src_buf, src_w, src_h, src_stride, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa, 4);
|
||||
tranform_rgb888(src_buf, src_w, src_h, src_stride_px, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa,
|
||||
4);
|
||||
break;
|
||||
case LV_COLOR_FORMAT_RGB888:
|
||||
tranform_rgb888(src_buf, src_w, src_h, src_stride, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa, 3);
|
||||
tranform_rgb888(src_buf, src_w, src_h, src_stride_px, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa,
|
||||
3);
|
||||
break;
|
||||
case LV_COLOR_FORMAT_A8:
|
||||
transform_a8(src_buf, src_w, src_h, src_stride, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa);
|
||||
transform_a8(src_buf, src_w, src_h, src_stride_px, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa);
|
||||
break;
|
||||
case LV_COLOR_FORMAT_ARGB8888:
|
||||
tranform_argb8888(src_buf, src_w, src_h, src_stride, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa);
|
||||
tranform_argb8888(src_buf, src_w, src_h, src_stride_px, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf, aa);
|
||||
break;
|
||||
case LV_COLOR_FORMAT_RGB565:
|
||||
transform_rgb565a8(src_buf, src_w, src_h, src_stride, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf,
|
||||
transform_rgb565a8(src_buf, src_w, src_h, src_stride_px, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w, dest_buf,
|
||||
alpha_buf, false, aa);
|
||||
break;
|
||||
case LV_COLOR_FORMAT_RGB565A8:
|
||||
transform_rgb565a8(src_buf, src_w, src_h, src_stride, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w,
|
||||
transform_rgb565a8(src_buf, src_w, src_h, src_stride_px, xs_ups, ys_ups, xs_step_256, ys_step_256, dest_w,
|
||||
(uint16_t *)dest_buf,
|
||||
alpha_buf, true, aa);
|
||||
break;
|
||||
|
||||
@@ -386,11 +386,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
|
||||
|
||||
lv_coord_t y;
|
||||
lv_coord_t x;
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(w, LV_COLOR_FORMAT_A8);
|
||||
|
||||
for(x = 0; x < w; x++) {
|
||||
out[x] = opa_table[line_buf1[x]];
|
||||
}
|
||||
out += w;
|
||||
out += stride;
|
||||
|
||||
for(y = 1; y < h; y++) {
|
||||
if(prefilter) {
|
||||
@@ -408,7 +409,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
|
||||
out[x] = opa_table[line_buf1[x]];
|
||||
}
|
||||
}
|
||||
out += w;
|
||||
out += stride;
|
||||
}
|
||||
|
||||
lv_free(line_buf1);
|
||||
|
||||
@@ -338,7 +338,8 @@ static const uint8_t * ttf_get_glyph_bitmap_cb(const lv_font_t * font, uint32_t
|
||||
return NULL;
|
||||
}
|
||||
memset(buffer, 0, buffer_size);
|
||||
stbtt_MakeGlyphBitmap(info, buffer, w, h, w, dsc->scale, dsc->scale, g1);
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(w, LV_COLOR_FORMAT_A8);
|
||||
stbtt_MakeGlyphBitmap(info, buffer, w, h, stride, dsc->scale, dsc->scale, g1);
|
||||
}
|
||||
return buffer; /*Or NULL if not found*/
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ void lv_canvas_set_buffer(lv_obj_t * obj, void * buf, lv_coord_t w, lv_coord_t h
|
||||
canvas->dsc.header.cf = cf;
|
||||
canvas->dsc.header.w = w;
|
||||
canvas->dsc.header.h = h;
|
||||
canvas->dsc.header.stride = 0; /*Let LVGL calculate it automatically*/
|
||||
canvas->dsc.header.stride = lv_draw_buf_width_to_stride(w, cf); /*Let LVGL calculate it automatically*/
|
||||
canvas->dsc.data = buf;
|
||||
canvas->dsc.data_size = w * h * lv_color_format_get_size(cf);
|
||||
|
||||
@@ -243,10 +243,12 @@ void lv_canvas_fill_bg(lv_obj_t * obj, lv_color_t color, lv_opa_t opa)
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(dsc->header.w, dsc->header.cf);
|
||||
|
||||
if(dsc->header.cf == LV_COLOR_FORMAT_RGB565) {
|
||||
uint16_t c16 = lv_color_to_u16(color);
|
||||
for(y = 0; y < dsc->header.h; y++) {
|
||||
uint16_t * buf16 = (uint16_t *)(dsc->data + y * dsc->header.w * 2);
|
||||
uint16_t * buf16 = (uint16_t *)(dsc->data + y * stride);
|
||||
for(x = 0; x < dsc->header.w; x++) {
|
||||
buf16[x] = c16;
|
||||
}
|
||||
@@ -259,7 +261,7 @@ void lv_canvas_fill_bg(lv_obj_t * obj, lv_color_t color, lv_opa_t opa)
|
||||
c32 |= opa << 24;
|
||||
}
|
||||
for(y = 0; y < dsc->header.h; y++) {
|
||||
uint32_t * buf32 = (uint32_t *)(dsc->data + y * dsc->header.w * 4);
|
||||
uint32_t * buf32 = (uint32_t *)(dsc->data + y * stride);
|
||||
for(x = 0; x < dsc->header.w; x++) {
|
||||
buf32[x] = c32;
|
||||
}
|
||||
@@ -267,7 +269,7 @@ void lv_canvas_fill_bg(lv_obj_t * obj, lv_color_t color, lv_opa_t opa)
|
||||
}
|
||||
else if(dsc->header.cf == LV_COLOR_FORMAT_RGB888) {
|
||||
for(y = 0; y < dsc->header.h; y++) {
|
||||
uint8_t * buf8 = (uint8_t *)(dsc->data + y * dsc->header.w * 3);
|
||||
uint8_t * buf8 = (uint8_t *)(dsc->data + y * stride);
|
||||
for(x = 0; x < dsc->header.w * 3; x += 3) {
|
||||
buf8[x + 0] = color.blue;
|
||||
buf8[x + 1] = color.green;
|
||||
|
||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -88,6 +88,9 @@ typedef void * lv_user_data_t;
|
||||
#if defined(LVGL_CI_USING_SYS_HEAP) || defined(LVGL_CI_USING_DEF_HEAP)
|
||||
#undef LV_LOG_PRINTF
|
||||
|
||||
//#define LV_DRAW_BUF_STRIDE_ALIGN 64
|
||||
//#define LV_DRAW_BUF_ALIGN 32
|
||||
|
||||
/*For screenshots*/
|
||||
#undef LV_USE_PERF_MONITOR
|
||||
#undef LV_USE_MEM_MONITOR
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#else
|
||||
#define LV_HEAP_CHECK(x) x
|
||||
|
||||
|
||||
static inline uint32_t lv_test_get_free_mem(void)
|
||||
{
|
||||
lv_mem_monitor_t m1;
|
||||
@@ -19,6 +20,7 @@ static inline uint32_t lv_test_get_free_mem(void)
|
||||
}
|
||||
#endif /* LVGL_CI_USING_SYS_HEAP */
|
||||
|
||||
#define CANVAS_WIDTH_TO_STRIDE(w, px_size) ((((w) * (px_size) + (LV_DRAW_BUF_STRIDE_ALIGN - 1)) / LV_DRAW_BUF_STRIDE_ALIGN) * LV_DRAW_BUF_STRIDE_ALIGN)
|
||||
|
||||
#endif /*LV_TEST_HELPERS_H*/
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "lv_test_helpers.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
@@ -63,7 +64,7 @@ static void draw_arcs_line(lv_layer_t * layer, lv_draw_arc_dsc_t * dsc, uint32_t
|
||||
|
||||
static void draw_arcs(lv_draw_arc_dsc_t * arc_dsc, const char * fn)
|
||||
{
|
||||
static uint8_t canvas_buf[760 * 440 * 4];
|
||||
static uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(760, 4) * 440];
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, canvas_buf, 760, 440, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "lv_test_helpers.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
@@ -93,6 +94,7 @@ void canvas_blend_test(lv_obj_t * canvas_large, lv_draw_image_dsc_t * img_dsc,
|
||||
{
|
||||
lv_image_dsc_t * img = (lv_image_dsc_t *)img_dsc->src;
|
||||
img->header.cf = small_render_cf;
|
||||
img->header.stride = lv_draw_buf_width_to_stride(180, small_render_cf);
|
||||
canvas_basic_render((uint8_t *)img->data, small_render_cf, name_main, name_sub);
|
||||
|
||||
lv_area_t area;
|
||||
@@ -120,18 +122,17 @@ static void canvas_draw(const char * name, lv_color_format_t large_render_cf)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
static uint8_t canvas_buf[180 * 180 * 4];
|
||||
static uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(180, 4) * 180];
|
||||
|
||||
|
||||
static uint8_t canvas2_buf[770 * 390 * 4];
|
||||
static uint8_t canvas2_buf[CANVAS_WIDTH_TO_STRIDE(768, 4) * 390];
|
||||
lv_obj_t * canvas2 = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas2, canvas2_buf, 770, 390, large_render_cf);
|
||||
lv_canvas_set_buffer(canvas2, canvas2_buf, 768, 390, large_render_cf);
|
||||
lv_canvas_fill_bg(canvas2, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_COVER);
|
||||
|
||||
lv_image_dsc_t img = { 0 };
|
||||
img.header.w = 180;
|
||||
img.header.h = 180;
|
||||
img.header.stride = 0;
|
||||
img.header.always_zero = 0;
|
||||
img.data = canvas_buf;
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "lv_test_helpers.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
lv_obj_set_flex_flow(lv_scr_act(), LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(lv_scr_act(), LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_EVENLY);
|
||||
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
@@ -148,24 +149,24 @@ static void draw_images(lv_layer_t * layer, lv_draw_image_dsc_t * dsc)
|
||||
|
||||
void create_test_screen(lv_color_format_t render_cf, const char * name)
|
||||
{
|
||||
static uint8_t canvas_buf_large[760 * 440 * 4];
|
||||
static uint8_t canvas_buf_large[CANVAS_WIDTH_TO_STRIDE(768, 4) * 440];
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, canvas_buf_large, 760, 440, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_set_buffer(canvas, canvas_buf_large, 768, 440, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_50);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
static uint8_t canvas_buf_small[100 * 100 * 4];
|
||||
static uint8_t canvas_buf_small[CANVAS_WIDTH_TO_STRIDE(100, 4) * 100];
|
||||
|
||||
lv_image_dsc_t img;
|
||||
img.data = canvas_buf_small;
|
||||
img.header.cf = render_cf;
|
||||
img.header.w = 100;
|
||||
img.header.h = 100;
|
||||
img.header.stride = 100 * lv_color_format_get_size(render_cf);
|
||||
img.header.stride = lv_draw_buf_width_to_stride(100, render_cf);
|
||||
img.header.always_zero = 0;
|
||||
|
||||
lv_draw_image_dsc_t img_dsc;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "lv_test_helpers.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
@@ -55,11 +56,11 @@ static void draw_triangles(lv_layer_t * layer, lv_draw_triangle_dsc_t * dsc, uin
|
||||
|
||||
void test_draw_triangle(void)
|
||||
{
|
||||
static uint8_t canvas_buf[760 * 440 * 4];
|
||||
static uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(768, 4) * 440 * 4];
|
||||
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, canvas_buf, 760, 440, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_set_buffer(canvas, canvas_buf, 768, 440, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_RED, 2), LV_OPA_50);
|
||||
|
||||
|
||||