mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
refactor(draw_buf): remove lv_draw_buf_t and make all functions work on void * buffer directly
This commit is contained in:
parent
17d0f568c8
commit
8deea70049
@ -577,15 +577,15 @@ static void refr_invalid_areas(void)
|
||||
static void refr_area(const lv_area_t * area_p)
|
||||
{
|
||||
lv_layer_t * layer = disp_refr->layer_head;
|
||||
layer->draw_buf.buf = disp_refr->buf_act;
|
||||
layer->buf = disp_refr->buf_act;
|
||||
|
||||
/*With full refresh just redraw directly into the buffer*/
|
||||
/*In direct mode draw directly on the absolute coordinates of the buffer*/
|
||||
if(disp_refr->render_mode != LV_DISPLAY_RENDER_MODE_PARTIAL) {
|
||||
layer->draw_buf.width = lv_display_get_horizontal_resolution(disp_refr);
|
||||
layer->draw_buf.height = lv_display_get_vertical_resolution(disp_refr);
|
||||
layer->draw_buf_ofs.x = 0;
|
||||
layer->draw_buf_ofs.y = 0;
|
||||
layer->buf_area.x1 = 0;
|
||||
layer->buf_area.y1 = 0;
|
||||
layer->buf_area.x2 = lv_display_get_horizontal_resolution(disp_refr) - 1;
|
||||
layer->buf_area.y2 = lv_display_get_vertical_resolution(disp_refr) - 1;
|
||||
lv_area_t disp_area;
|
||||
lv_area_set(&disp_area, 0, 0, lv_display_get_horizontal_resolution(disp_refr) - 1,
|
||||
lv_display_get_vertical_resolution(disp_refr) - 1);
|
||||
@ -621,11 +621,8 @@ static void refr_area(const lv_area_t * area_p)
|
||||
sub_area.x2 = area_p->x2;
|
||||
sub_area.y1 = row;
|
||||
sub_area.y2 = row + max_row - 1;
|
||||
layer->draw_buf.buf = disp_refr->buf_act;
|
||||
layer->draw_buf.width = lv_area_get_width(&sub_area);
|
||||
layer->draw_buf.height = max_row;
|
||||
layer->draw_buf_ofs.x = sub_area.x1;
|
||||
layer->draw_buf_ofs.y = sub_area.y1;
|
||||
layer->buf = disp_refr->buf_act;
|
||||
layer->buf_area = sub_area;
|
||||
layer->clip_area = sub_area;
|
||||
if(sub_area.y2 > y2) sub_area.y2 = y2;
|
||||
row_last = sub_area.y2;
|
||||
@ -640,11 +637,8 @@ static void refr_area(const lv_area_t * area_p)
|
||||
sub_area.x2 = area_p->x2;
|
||||
sub_area.y1 = row;
|
||||
sub_area.y2 = y2;
|
||||
layer->draw_buf.buf = disp_refr->buf_act;
|
||||
layer->draw_buf.width = lv_area_get_width(&sub_area);
|
||||
layer->draw_buf.height = lv_area_get_height(&sub_area);
|
||||
layer->draw_buf_ofs.x = sub_area.x1;
|
||||
layer->draw_buf_ofs.y = sub_area.y1;
|
||||
layer->buf = disp_refr->buf_act;
|
||||
layer->buf_area = sub_area;
|
||||
layer->clip_area = sub_area;
|
||||
disp_refr->last_part = 1;
|
||||
refr_area_part(layer);
|
||||
@ -662,7 +656,8 @@ static void refr_area_part(lv_layer_t * layer)
|
||||
}
|
||||
/*If the screen is transparent initialize it when the flushing is ready*/
|
||||
if(lv_color_format_has_alpha(disp_refr->color_format)) {
|
||||
lv_draw_buf_clear(&layer->draw_buf, &disp_refr->refreshed_area);
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(lv_area_get_width(&layer->buf_area), layer->color_format);
|
||||
lv_draw_buf_clear(layer->buf, stride, layer->color_format, &disp_refr->refreshed_area);
|
||||
}
|
||||
|
||||
lv_obj_t * top_act_scr = NULL;
|
||||
@ -909,8 +904,8 @@ void refr_obj(lv_layer_t * layer, lv_obj_t * obj)
|
||||
|
||||
lv_draw_image_dsc_t layer_draw_dsc;
|
||||
lv_draw_image_dsc_init(&layer_draw_dsc);
|
||||
layer_draw_dsc.pivot.x = obj->coords.x1 + lv_obj_get_style_transform_pivot_x(obj, 0) - new_layer->draw_buf_ofs.x;
|
||||
layer_draw_dsc.pivot.y = obj->coords.y1 + lv_obj_get_style_transform_pivot_y(obj, 0) - new_layer->draw_buf_ofs.y;
|
||||
layer_draw_dsc.pivot.x = obj->coords.x1 + lv_obj_get_style_transform_pivot_x(obj, 0) - new_layer->buf_area.x1;
|
||||
layer_draw_dsc.pivot.y = obj->coords.y1 + lv_obj_get_style_transform_pivot_y(obj, 0) - new_layer->buf_area.y1;
|
||||
|
||||
layer_draw_dsc.opa = opa;
|
||||
layer_draw_dsc.rotation = lv_obj_get_style_transform_rotation(obj, 0);
|
||||
@ -1000,10 +995,10 @@ static void draw_buf_flush(lv_display_t * disp)
|
||||
/*Rotate the buffer to the display's native orientation if necessary*/
|
||||
if(disp->rotation != LV_DISPLAY_ROTATION_0 && disp->sw_rotate) {
|
||||
LV_LOG_WARN("SW rotation is not supported now");
|
||||
call_flush_cb(disp, &disp->refreshed_area, layer->draw_buf.buf);
|
||||
call_flush_cb(disp, &disp->refreshed_area, layer->buf);
|
||||
}
|
||||
else {
|
||||
call_flush_cb(disp, &disp->refreshed_area, layer->draw_buf.buf);
|
||||
call_flush_cb(disp, &disp->refreshed_area, layer->buf);
|
||||
}
|
||||
}
|
||||
/*If there are 2 buffers swap them. With direct mode swap only on the last area*/
|
||||
|
@ -78,8 +78,11 @@ lv_display_t * lv_display_create(lv_coord_t hor_res, lv_coord_t ver_res)
|
||||
lv_memzero(disp->layer_head, sizeof(lv_layer_t));
|
||||
|
||||
if(disp->layer_init) disp->layer_init(disp, disp->layer_head);
|
||||
|
||||
lv_draw_buf_init(&disp->layer_head->draw_buf, hor_res, ver_res, disp->color_format);
|
||||
disp->layer_head->buf_area.x1 = 0;
|
||||
disp->layer_head->buf_area.y1 = 0;
|
||||
disp->layer_head->buf_area.x2 = hor_res - 1;
|
||||
disp->layer_head->buf_area.y2 = ver_res - 1;
|
||||
disp->layer_head->color_format = disp->color_format;
|
||||
|
||||
disp->inv_en_cnt = 1;
|
||||
|
||||
@ -397,7 +400,7 @@ void lv_display_set_color_format(lv_display_t * disp, lv_color_format_t color_fo
|
||||
if(disp == NULL) return;
|
||||
|
||||
disp->color_format = color_format;
|
||||
disp->layer_head->draw_buf.color_format = color_format;
|
||||
disp->layer_head->color_format = color_format;
|
||||
}
|
||||
|
||||
lv_color_format_t lv_display_get_color_format(lv_display_t * disp)
|
||||
|
@ -155,13 +155,14 @@ bool lv_draw_dispatch_layer(struct _lv_display_t * disp, lv_layer_t * layer)
|
||||
lv_draw_image_dsc_t * draw_image_dsc = t->draw_dsc;
|
||||
lv_layer_t * layer_drawn = (lv_layer_t *)draw_image_dsc->src;
|
||||
|
||||
if(lv_draw_buf_get_buf(&layer_drawn->draw_buf)) {
|
||||
uint32_t layer_size_byte = layer_drawn->draw_buf.height * lv_draw_buf_width_to_stride(layer_drawn->draw_buf.width,
|
||||
layer_drawn->draw_buf.color_format);
|
||||
if(layer_drawn->buf) {
|
||||
int32_t h = lv_area_get_height(&layer_drawn->buf_area);
|
||||
int32_t w = lv_area_get_width(&layer_drawn->buf_area);
|
||||
uint32_t layer_size_byte = h * lv_draw_buf_width_to_stride(w, layer_drawn->color_format);
|
||||
|
||||
_draw_info.used_memory_for_layers_kb -= layer_size_byte < 1024 ? 1 : layer_size_byte >> 10;
|
||||
LV_LOG_INFO("Layer memory used: %d kB\n", _draw_info.used_memory_for_layers_kb);
|
||||
lv_draw_buf_free(layer_drawn->draw_buf.buf);
|
||||
lv_draw_buf_free(layer_drawn->buf_unaligned);
|
||||
}
|
||||
|
||||
/*Remove the layer from the display's*/
|
||||
@ -217,9 +218,11 @@ bool lv_draw_dispatch_layer(struct _lv_display_t * disp, lv_layer_t * layer)
|
||||
/*Assign draw tasks to the draw_units*/
|
||||
else {
|
||||
bool layer_ok = true;
|
||||
if(layer->draw_buf.buf == NULL) {
|
||||
uint32_t layer_size_byte = layer->draw_buf.height * lv_draw_buf_width_to_stride(layer->draw_buf.width,
|
||||
layer->draw_buf.color_format);
|
||||
if(layer->buf == NULL) {
|
||||
int32_t h = lv_area_get_height(&layer->buf_area);
|
||||
int32_t w = lv_area_get_width(&layer->buf_area);
|
||||
uint32_t layer_size_byte = h * lv_draw_buf_width_to_stride(w, layer->color_format);
|
||||
|
||||
uint32_t kb = layer_size_byte < 1024 ? 1 : layer_size_byte >> 10;
|
||||
if(_draw_info.used_memory_for_layers_kb + kb > LV_LAYER_MAX_MEMORY_USAGE) {
|
||||
layer_ok = false;
|
||||
@ -304,11 +307,10 @@ lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t c
|
||||
if(new_layer == NULL) return NULL;
|
||||
lv_memzero(new_layer, sizeof(lv_layer_t));
|
||||
|
||||
lv_draw_buf_init(&new_layer->draw_buf, lv_area_get_width(area), lv_area_get_height(area), color_format);
|
||||
new_layer->draw_buf_ofs.x = area->x1;
|
||||
new_layer->draw_buf_ofs.y = area->y1;
|
||||
new_layer->parent = parent_layer;
|
||||
new_layer->clip_area = *area;
|
||||
new_layer->buf_area = *area;
|
||||
new_layer->color_format = color_format;
|
||||
|
||||
if(disp->layer_head) {
|
||||
lv_layer_t * tail = disp->layer_head;
|
||||
@ -322,42 +324,42 @@ lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t c
|
||||
return new_layer;
|
||||
}
|
||||
|
||||
void lv_draw_layer_get_area(lv_layer_t * layer, lv_area_t * area)
|
||||
{
|
||||
area->x1 = 0;
|
||||
area->y1 = 0;
|
||||
area->x2 = layer->draw_buf.width - 1;
|
||||
area->y2 = layer->draw_buf.height - 1;
|
||||
lv_area_move(area, layer->draw_buf_ofs.x, layer->draw_buf_ofs.y);
|
||||
}
|
||||
|
||||
void * lv_draw_layer_alloc_buf(lv_layer_t * layer)
|
||||
{
|
||||
/*If the buffer of the layer is not allocated yet, allocate it now*/
|
||||
if(lv_draw_buf_get_buf(&layer->draw_buf) == NULL) {
|
||||
uint32_t layer_size_byte = layer->draw_buf.height * lv_draw_buf_width_to_stride(layer->draw_buf.width,
|
||||
layer->draw_buf.color_format);
|
||||
size_t s = lv_draw_buf_get_stride(&layer->draw_buf) * layer->draw_buf.height;
|
||||
layer->draw_buf.buf = lv_draw_buf_malloc(s, layer->draw_buf.color_format);
|
||||
if(layer->buf == NULL) {
|
||||
int32_t h = lv_area_get_height(&layer->buf_area);
|
||||
int32_t w = lv_area_get_width(&layer->buf_area);
|
||||
int32_t stride = lv_draw_buf_width_to_stride(w, layer->color_format);
|
||||
uint32_t layer_size_byte = h * stride;
|
||||
layer->buf_unaligned = lv_draw_buf_malloc(layer_size_byte, layer->color_format);
|
||||
|
||||
if(lv_draw_buf_get_buf(&layer->draw_buf) == NULL) {
|
||||
if(layer->buf_unaligned == NULL) {
|
||||
LV_LOG_WARN("Allocating %"LV_PRIu32" bytes of layer buffer failed. Try later", layer_size_byte);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
layer->buf = lv_draw_buf_align(layer->buf_unaligned, layer->color_format);
|
||||
|
||||
uint32_t kb = layer_size_byte < 1024 ? 1 : layer_size_byte >> 10;
|
||||
_draw_info.used_memory_for_layers_kb += kb;
|
||||
LV_LOG_INFO("Layer memory used: %d kB\n", _draw_info.used_memory_for_layers_kb);
|
||||
|
||||
|
||||
if(lv_color_format_has_alpha(layer->draw_buf.color_format)) {
|
||||
lv_draw_buf_clear(&layer->draw_buf, NULL);
|
||||
if(lv_color_format_has_alpha(layer->color_format)) {
|
||||
lv_draw_buf_clear(layer->buf, stride, layer->color_format, &layer->buf_area);
|
||||
}
|
||||
}
|
||||
|
||||
return lv_draw_buf_get_buf(&layer->draw_buf);
|
||||
return lv_draw_buf_align(layer->buf, layer->color_format);
|
||||
}
|
||||
|
||||
void * lv_draw_layer_go_to_xy(lv_layer_t * layer, lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(lv_area_get_width(&layer->buf_area), layer->color_format);
|
||||
return lv_draw_buf_go_to_xy(layer->buf, stride, layer->color_format, x, y);
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
|
@ -134,8 +134,15 @@ typedef struct _lv_draw_unit_t {
|
||||
|
||||
typedef struct _lv_layer_t {
|
||||
|
||||
lv_draw_buf_t draw_buf;
|
||||
lv_point_t draw_buf_ofs;
|
||||
/** The unaligned buffer where drawing will happen*/
|
||||
void * buf_unaligned;
|
||||
|
||||
/** The aligned buffer, result of lv_draw_buf_align(layer->buf_unaligned)*/
|
||||
void * buf;
|
||||
|
||||
uint32_t buf_stride;
|
||||
lv_area_t buf_area;
|
||||
lv_color_format_t color_format;
|
||||
|
||||
/**
|
||||
* The current clip area with absolute coordinates, always the same or smaller than `buf_area`
|
||||
@ -224,9 +231,6 @@ lv_draw_task_t * lv_draw_get_next_available_task(lv_layer_t * layer, lv_draw_tas
|
||||
*/
|
||||
lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t color_format, const lv_area_t * area);
|
||||
|
||||
|
||||
void lv_draw_layer_get_area(lv_layer_t * layer, lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Try to allocate a buffer for the layer.
|
||||
* @param layer pointer to a layer
|
||||
@ -234,6 +238,15 @@ void lv_draw_layer_get_area(lv_layer_t * layer, lv_area_t * area);
|
||||
*/
|
||||
void * lv_draw_layer_alloc_buf(lv_layer_t * layer);
|
||||
|
||||
/**
|
||||
* Got to a pixel at X and Y coordinate on a layer
|
||||
* @param layer pointer to a layer
|
||||
* @param x the target X coordinate
|
||||
* @param y the target X coordinate
|
||||
* @return `buf` offset to point to the given X and Y coordinate
|
||||
*/
|
||||
void * lv_draw_layer_go_to_xy(lv_layer_t * layer, lv_coord_t x, lv_coord_t y);
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
@ -24,13 +24,13 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void buf_init(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h, lv_color_format_t color_format);
|
||||
static void * buf_malloc(size_t size, lv_color_format_t color_format);
|
||||
static void buf_free(void * buf);
|
||||
static void * align_buf(void * buf, lv_color_format_t color_format);
|
||||
static void * buf_align(void * buf, lv_color_format_t color_format);
|
||||
static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format);
|
||||
static void * go_to_xy(lv_draw_buf_t * draw_buf, lv_coord_t x, lv_coord_t y);
|
||||
static void buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a);
|
||||
static void * buf_go_to_xy(const void * buf, uint32_t stride, lv_color_format_t color_format, lv_coord_t x,
|
||||
lv_coord_t y);
|
||||
static void buf_clear(void * buf, uint32_t strid, lv_color_format_t color_format, const lv_area_t * a);
|
||||
static void buf_copy(void * dest_buf, uint32_t dest_stride, const lv_area_t * dest_area,
|
||||
void * src_buf, uint32_t src_stride, const lv_area_t * src_area, lv_color_format_t color_format);
|
||||
|
||||
@ -49,13 +49,12 @@ static void buf_copy(void * dest_buf, uint32_t dest_stride, const lv_area_t * de
|
||||
void _lv_draw_buf_init_handlers(void)
|
||||
{
|
||||
lv_memzero(&handlers, sizeof(lv_draw_buf_handlers_t));
|
||||
handlers.init_cb = buf_init;
|
||||
handlers.buf_malloc_cb = buf_malloc;
|
||||
handlers.buf_free_cb = buf_free;
|
||||
handlers.align_pointer_cb = align_buf;
|
||||
handlers.align_pointer_cb = buf_align;
|
||||
handlers.invalidate_cache_cb = NULL;
|
||||
handlers.width_to_stride_cb = width_to_stride;
|
||||
handlers.go_to_xy_cb = go_to_xy;
|
||||
handlers.go_to_xy_cb = buf_go_to_xy;
|
||||
handlers.buf_clear_cb = buf_clear;
|
||||
handlers.buf_copy_cb = buf_copy;
|
||||
}
|
||||
@ -65,19 +64,6 @@ lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void)
|
||||
return &handlers;
|
||||
}
|
||||
|
||||
void lv_draw_buf_init(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h, lv_color_format_t color_format)
|
||||
{
|
||||
lv_memzero(draw_buf, sizeof(lv_draw_buf_t));
|
||||
if(handlers.init_cb) handlers.init_cb(draw_buf, w, h, color_format);
|
||||
}
|
||||
|
||||
void lv_draw_buf_init_alloc(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h, lv_color_format_t color_format)
|
||||
{
|
||||
lv_draw_buf_init(draw_buf, w, h, color_format);
|
||||
|
||||
size_t s = lv_draw_buf_get_stride(draw_buf) * h;
|
||||
draw_buf->buf = lv_draw_buf_malloc(s, color_format);
|
||||
}
|
||||
|
||||
uint32_t lv_draw_buf_width_to_stride(uint32_t w, lv_color_format_t color_format)
|
||||
{
|
||||
@ -96,7 +82,7 @@ void lv_draw_buf_free(void * buf)
|
||||
if(handlers.buf_free_cb) handlers.buf_free_cb(buf);
|
||||
}
|
||||
|
||||
void * lv_draw_buf_align_buf(void * data, lv_color_format_t color_format)
|
||||
void * lv_draw_buf_align(void * data, lv_color_format_t color_format)
|
||||
{
|
||||
if(handlers.align_pointer_cb) return handlers.align_pointer_cb(data, color_format);
|
||||
else return NULL;
|
||||
@ -107,15 +93,16 @@ void lv_draw_buf_invalidate_cache(void * buf, size_t size)
|
||||
if(handlers.invalidate_cache_cb) handlers.invalidate_cache_cb(buf, size);
|
||||
}
|
||||
|
||||
void * lv_draw_buf_go_to_xy(lv_draw_buf_t * draw_buf, lv_coord_t x, lv_coord_t y)
|
||||
void * lv_draw_buf_go_to_xy(const void * buf, uint32_t stride, lv_color_format_t color_format, lv_coord_t x,
|
||||
lv_coord_t y)
|
||||
{
|
||||
if(handlers.go_to_xy_cb) return handlers.go_to_xy_cb(draw_buf, x, y);
|
||||
if(handlers.go_to_xy_cb) return handlers.go_to_xy_cb(buf, stride, color_format, x, y);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a)
|
||||
void lv_draw_buf_clear(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * a)
|
||||
{
|
||||
if(handlers.buf_clear_cb) handlers.buf_clear_cb(draw_buf, a);
|
||||
if(handlers.buf_clear_cb) handlers.buf_clear_cb(buf, stride, color_format, a);
|
||||
}
|
||||
|
||||
void lv_draw_buf_copy(void * dest_buf, uint32_t dest_stride, const lv_area_t * dest_area,
|
||||
@ -125,32 +112,11 @@ void lv_draw_buf_copy(void * dest_buf, uint32_t dest_stride, const lv_area_t * d
|
||||
color_format);
|
||||
}
|
||||
|
||||
void * lv_draw_buf_get_buf(lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
if(draw_buf->buf) return lv_draw_buf_align_buf(draw_buf->buf, draw_buf->color_format);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
|
||||
uint32_t lv_draw_buf_get_stride(const lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
return lv_draw_buf_width_to_stride(draw_buf->width, draw_buf->color_format);
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
static void buf_init(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h, lv_color_format_t color_format)
|
||||
{
|
||||
draw_buf->width = w;
|
||||
draw_buf->height = h;
|
||||
draw_buf->color_format = color_format;
|
||||
draw_buf->buf = NULL;
|
||||
}
|
||||
|
||||
static void * buf_malloc(size_t size_bytes, lv_color_format_t color_format)
|
||||
{
|
||||
LV_UNUSED(color_format);
|
||||
@ -165,7 +131,7 @@ static void buf_free(void * buf)
|
||||
lv_free(buf);
|
||||
}
|
||||
|
||||
static void * align_buf(void * buf, lv_color_format_t color_format)
|
||||
static void * buf_align(void * buf, lv_color_format_t color_format)
|
||||
{
|
||||
LV_UNUSED(color_format);
|
||||
|
||||
@ -184,24 +150,21 @@ static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format)
|
||||
return (width_byte + LV_DRAW_BUF_STRIDE_ALIGN - 1) & ~(LV_DRAW_BUF_STRIDE_ALIGN - 1);
|
||||
}
|
||||
|
||||
static void * go_to_xy(lv_draw_buf_t * draw_buf, lv_coord_t x, lv_coord_t y)
|
||||
static void * buf_go_to_xy(const void * buf, uint32_t stride, lv_color_format_t color_format, lv_coord_t x,
|
||||
lv_coord_t y)
|
||||
{
|
||||
uint32_t px_size = lv_color_format_get_size(draw_buf->color_format);
|
||||
uint32_t stride = lv_draw_buf_get_stride(draw_buf);
|
||||
uint8_t * buf_tmp = lv_draw_buf_get_buf(draw_buf);
|
||||
const uint8_t * buf_tmp = buf;
|
||||
buf_tmp += stride * y;
|
||||
buf_tmp += x * px_size;
|
||||
buf_tmp += x * lv_color_format_get_size(color_format);
|
||||
|
||||
return buf_tmp;
|
||||
return (void *)buf_tmp;
|
||||
}
|
||||
|
||||
static void buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a)
|
||||
static void buf_clear(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * a)
|
||||
{
|
||||
//TODO clear the area
|
||||
LV_UNUSED(a);
|
||||
uint32_t stride = lv_draw_buf_get_stride(draw_buf);
|
||||
uint8_t * buf = lv_draw_buf_get_buf(draw_buf);
|
||||
lv_memzero(buf, stride * draw_buf->height);
|
||||
LV_UNUSED(color_format);
|
||||
lv_memzero(buf, stride * lv_area_get_height(a));
|
||||
}
|
||||
|
||||
static void buf_copy(void * dest_buf, uint32_t dest_stride, const lv_area_t * dest_area,
|
||||
|
@ -23,43 +23,29 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
void * buf;
|
||||
lv_coord_t width;
|
||||
lv_coord_t height;
|
||||
lv_color_format_t color_format;
|
||||
uint32_t usage_cnt;
|
||||
uint32_t flags;
|
||||
} lv_draw_buf_t;
|
||||
|
||||
|
||||
typedef void (*lv_draw_buf_init_cb)(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h,
|
||||
lv_color_format_t color_format);
|
||||
|
||||
typedef void * (*lv_draw_buf_malloc_cb)(size_t size, lv_color_format_t color_format);
|
||||
|
||||
typedef void (*lv_draw_buf_free_cb)(void * draw_buf);
|
||||
|
||||
typedef void * (*lv_draw_buf_align_buf_cb)(void * buf, lv_color_format_t color_format);
|
||||
typedef void * (*lv_draw_buf_align_cb)(void * buf, lv_color_format_t color_format);
|
||||
|
||||
typedef void (*lv_draw_buf_invalidate_cache_cb)(void * buf, size_t size);
|
||||
|
||||
typedef uint32_t (*lv_draw_buf_width_to_stride_cb)(uint32_t w, lv_color_format_t color_format);
|
||||
|
||||
typedef uint32_t (*lv_draw_buf_get_stride_cb)(const lv_draw_buf_t * draw_buf);
|
||||
typedef void * (*lv_draw_buf_go_to_xy_cb)(const void * buf, uint32_t stride, lv_color_format_t color_format,
|
||||
lv_coord_t x, lv_coord_t y);
|
||||
|
||||
typedef void * (*lv_draw_buf_go_to_xy_cb)(lv_draw_buf_t * draw_buf, lv_coord_t x, lv_coord_t y);
|
||||
|
||||
typedef void (*lv_draw_buf_clear_cb)(lv_draw_buf_t * draw_buf, const lv_area_t * a);
|
||||
typedef void (*lv_draw_buf_clear_cb)(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * a);
|
||||
|
||||
typedef void (*lv_draw_buf_copy_cb)(void * dest_buf, uint32_t dest_stride, const lv_area_t * dest_area,
|
||||
void * src_buf, uint32_t src_stride, const lv_area_t * src_area, lv_color_format_t color_format);
|
||||
|
||||
typedef struct {
|
||||
lv_draw_buf_init_cb init_cb;
|
||||
lv_draw_buf_malloc_cb buf_malloc_cb;
|
||||
lv_draw_buf_free_cb buf_free_cb;
|
||||
lv_draw_buf_align_buf_cb align_pointer_cb;
|
||||
lv_draw_buf_align_cb align_pointer_cb;
|
||||
lv_draw_buf_invalidate_cache_cb invalidate_cache_cb;
|
||||
lv_draw_buf_width_to_stride_cb width_to_stride_cb;
|
||||
lv_draw_buf_go_to_xy_cb go_to_xy_cb;
|
||||
@ -83,31 +69,13 @@ void _lv_draw_buf_init_handlers(void);
|
||||
*/
|
||||
lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void);
|
||||
|
||||
/**
|
||||
* Initialize a draw buffer object. The buffer won't be allocated.
|
||||
* @param draw_buf pointer to a draw buffer
|
||||
* @param w the width of the buffer in pixel
|
||||
* @param h the height of the buffer in pixel
|
||||
* @param color_format the color format of the buffer
|
||||
*/
|
||||
void lv_draw_buf_init(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Initialize a draw buffer object and also allocate the buffer.
|
||||
* @param draw_buf pointer to a draw buffer
|
||||
* @param w the width of the buffer in pixel
|
||||
* @param h the height of the buffer in pixel
|
||||
* @param color_format the color format of the buffer
|
||||
*/
|
||||
void lv_draw_buf_init_alloc(lv_draw_buf_t * draw_buf, lv_coord_t w, lv_coord_t h, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Allocate a buffer with the given size. It might allocate slightly larger buffer to fulfill the alignment requirements.
|
||||
* @param size the size to allocate in bytes
|
||||
* @param color_format the color format of the buffer to allcoate
|
||||
* @return the allocated buffer.
|
||||
* @note The returned value can be saved in draw_buf->buf
|
||||
* @note lv_draw_buf_align_buf can be sued the align the returned pointer
|
||||
* @note lv_draw_buf_align can be sued the align the returned pointer
|
||||
*/
|
||||
void * lv_draw_buf_malloc(size_t size_bytes, lv_color_format_t color_format);
|
||||
|
||||
@ -123,15 +91,7 @@ void lv_draw_buf_free(void * buf);
|
||||
* @param color_format the color format of the buffer
|
||||
* @return the aligned buffer
|
||||
*/
|
||||
void * lv_draw_buf_align_buf(void * buf, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Get the buffer of the draw_buf.
|
||||
* Never get the buffer as draw_buf->buf adn this function might align the buffer
|
||||
* @param draw_buf pointer to a draw buffer
|
||||
* @return pointer to the buffer
|
||||
*/
|
||||
void * lv_draw_buf_get_buf(lv_draw_buf_t * draw_buf);
|
||||
void * lv_draw_buf_align(void * buf, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Invalidate the cache of the buffer
|
||||
@ -149,26 +109,25 @@ void lv_draw_buf_invalidate_cache(void * buf, size_t size);
|
||||
uint32_t lv_draw_buf_width_to_stride(uint32_t w, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Get the stride of a draw buffer using the set width and color format
|
||||
* @param draw_buf pointer to draw buffer
|
||||
* @return the stride in bytes
|
||||
* Got to a pixel at X and Y coordinate in a buffer
|
||||
* @param buf pointer to a buffer
|
||||
* @param stride stride of the buffer
|
||||
* @param color_format color format of the buffer
|
||||
* @param x the target X coordinate
|
||||
* @param y the target X coordinate
|
||||
* @return `buf` offset to point to the given X and Y coordinate
|
||||
*/
|
||||
uint32_t lv_draw_buf_get_stride(const lv_draw_buf_t * draw_buf);
|
||||
|
||||
/**
|
||||
* Go to the X, Y coordinate on the buffer.
|
||||
* @param draw_buf pointer to draw buffer
|
||||
* @param x the X coordinate to seek
|
||||
* @param y the Y coordinate to seek
|
||||
*/
|
||||
void * lv_draw_buf_go_to_xy(lv_draw_buf_t * draw_buf, lv_coord_t x, lv_coord_t y);
|
||||
void * lv_draw_buf_go_to_xy(const void * buf, uint32_t stride, lv_color_format_t color_format, lv_coord_t x,
|
||||
lv_coord_t y);
|
||||
|
||||
/**
|
||||
* Clear an area on the buffer
|
||||
* @param draw_buf pointer to draw buffer
|
||||
* @param stride stride of the buffer
|
||||
* @param color_format color format of the buffer
|
||||
* @param a the area to clear, or NULL to clear the whole buffer
|
||||
*/
|
||||
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a);
|
||||
void lv_draw_buf_clear(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * a);
|
||||
|
||||
/**
|
||||
* Copy an area from a buffer to an other
|
||||
|
@ -400,12 +400,13 @@ static void draw_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc,
|
||||
}
|
||||
|
||||
uint32_t bitmap_size = lv_draw_buf_width_to_stride(g.box_w, LV_COLOR_FORMAT_A8) * g.box_h;
|
||||
bitmap_size = (bitmap_size + 63) & (~63); /*Round up*/
|
||||
bitmap_size = (bitmap_size + 63) &
|
||||
(~63); /*Round up to avoid many allocations if the next buffer is just slightly larger*/
|
||||
if(dsc->_bitmap_buf_size < bitmap_size) {
|
||||
lv_draw_buf_free(dsc->_bitmap_buf_unaligned);
|
||||
dsc->_bitmap_buf_unaligned = lv_draw_buf_malloc(bitmap_size, LV_COLOR_FORMAT_A8);
|
||||
LV_ASSERT_MALLOC(dsc->_bitmap_buf_unaligned);
|
||||
dsc->bitmap_buf = lv_draw_buf_align_buf(dsc->_bitmap_buf_unaligned, LV_COLOR_FORMAT_A8);
|
||||
dsc->bitmap_buf = lv_draw_buf_align(dsc->_bitmap_buf_unaligned, LV_COLOR_FORMAT_A8);
|
||||
dsc->_bitmap_buf_size = bitmap_size;
|
||||
}
|
||||
|
||||
|
@ -43,14 +43,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_mask_rect_dsc_init(lv_draw_mask_rect_dsc_t *
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_mask_rect(struct _lv_layer_t * layer, const lv_draw_mask_rect_dsc_t * dsc)
|
||||
{
|
||||
if(!lv_color_format_has_alpha(layer->draw_buf.color_format)) {
|
||||
if(!lv_color_format_has_alpha(layer->color_format)) {
|
||||
LV_LOG_WARN("Only layers with alpha channel can be masked");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_area_t a;
|
||||
lv_draw_layer_get_area(layer, &a);
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &a);
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &layer->buf_area);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
|
@ -46,13 +46,14 @@ void lv_draw_sw_blend(lv_draw_unit_t * draw_unit, const lv_draw_sw_blend_dsc_t *
|
||||
if(!_lv_area_intersect(&blend_area, blend_dsc->blend_area, draw_unit->clip_area)) return;
|
||||
|
||||
lv_layer_t * layer = draw_unit->target_layer;
|
||||
uint32_t layer_stride_byte = lv_draw_buf_width_to_stride(lv_area_get_width(&layer->buf_area), layer->color_format);
|
||||
uint32_t layer_stride_px = layer_stride_byte / lv_color_format_get_size(layer->color_format);
|
||||
|
||||
if(blend_dsc->src_buf == NULL) {
|
||||
_lv_draw_sw_blend_fill_dsc_t fill_dsc;
|
||||
fill_dsc.dest_w = lv_area_get_width(&blend_area);
|
||||
fill_dsc.dest_h = lv_area_get_height(&blend_area);
|
||||
fill_dsc.dest_stride = lv_draw_buf_get_stride(&layer->draw_buf) / lv_color_format_get_size(
|
||||
layer->draw_buf.color_format);
|
||||
fill_dsc.dest_stride = layer_stride_px;
|
||||
fill_dsc.opa = blend_dsc->opa;
|
||||
fill_dsc.color = blend_dsc->color;
|
||||
|
||||
@ -60,8 +61,8 @@ void lv_draw_sw_blend(lv_draw_unit_t * draw_unit, const lv_draw_sw_blend_dsc_t *
|
||||
else if(blend_dsc->mask_res == LV_DRAW_SW_MASK_RES_FULL_COVER) fill_dsc.mask_buf = NULL;
|
||||
else fill_dsc.mask_buf = blend_dsc->mask_buf;
|
||||
|
||||
fill_dsc.dest_buf = lv_draw_buf_go_to_xy(&layer->draw_buf, blend_area.x1 - layer->draw_buf_ofs.x,
|
||||
blend_area.y1 - layer->draw_buf_ofs.y);
|
||||
fill_dsc.dest_buf = lv_draw_layer_go_to_xy(layer, blend_area.x1 - layer->buf_area.x1,
|
||||
blend_area.y1 - layer->buf_area.y1);
|
||||
|
||||
if(fill_dsc.mask_buf) {
|
||||
fill_dsc.mask_stride = lv_area_get_width(blend_dsc->mask_area);
|
||||
@ -69,7 +70,7 @@ void lv_draw_sw_blend(lv_draw_unit_t * draw_unit, const lv_draw_sw_blend_dsc_t *
|
||||
(blend_area.x1 - blend_dsc->mask_area->x1);
|
||||
}
|
||||
|
||||
switch(layer->draw_buf.color_format) {
|
||||
switch(layer->color_format) {
|
||||
case LV_COLOR_FORMAT_RGB565:
|
||||
lv_draw_sw_blend_color_to_rgb565(&fill_dsc);
|
||||
break;
|
||||
@ -92,8 +93,8 @@ void lv_draw_sw_blend(lv_draw_unit_t * draw_unit, const lv_draw_sw_blend_dsc_t *
|
||||
_lv_draw_sw_blend_image_dsc_t image_dsc;
|
||||
image_dsc.dest_w = lv_area_get_width(&blend_area);
|
||||
image_dsc.dest_h = lv_area_get_height(&blend_area);
|
||||
image_dsc.dest_stride = lv_draw_buf_get_stride(&layer->draw_buf) / lv_color_format_get_size(
|
||||
layer->draw_buf.color_format);
|
||||
image_dsc.dest_stride = layer_stride_px;
|
||||
|
||||
image_dsc.opa = blend_dsc->opa;
|
||||
image_dsc.blend_mode = blend_dsc->blend_mode;
|
||||
image_dsc.src_stride = blend_dsc->src_stride / lv_color_format_get_size(blend_dsc->src_color_format);
|
||||
@ -116,10 +117,10 @@ void lv_draw_sw_blend(lv_draw_unit_t * draw_unit, const lv_draw_sw_blend_dsc_t *
|
||||
(blend_area.x1 - blend_dsc->mask_area->x1);
|
||||
}
|
||||
|
||||
image_dsc.dest_buf = lv_draw_buf_go_to_xy(&layer->draw_buf, blend_area.x1 - layer->draw_buf_ofs.x,
|
||||
blend_area.y1 - layer->draw_buf_ofs.y);
|
||||
image_dsc.dest_buf = lv_draw_layer_go_to_xy(layer, blend_area.x1 - layer->buf_area.x1,
|
||||
blend_area.y1 - layer->buf_area.y1);
|
||||
|
||||
switch(layer->draw_buf.color_format) {
|
||||
switch(layer->color_format) {
|
||||
case LV_COLOR_FORMAT_RGB565:
|
||||
case LV_COLOR_FORMAT_RGB565A8:
|
||||
lv_draw_sw_blend_image_to_rgb565(&image_dsc);
|
||||
|
@ -52,15 +52,16 @@ void lv_draw_sw_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dr
|
||||
|
||||
/*It can happen that nothing was draw on a layer and therefore its buffer is not allocated.
|
||||
*In this case just return. */
|
||||
if(layer_to_draw->draw_buf.buf == NULL) return;
|
||||
if(layer_to_draw->buf == NULL) return;
|
||||
|
||||
lv_image_dsc_t img_dsc;
|
||||
img_dsc.header.w = layer_to_draw->draw_buf.width;
|
||||
img_dsc.header.h = layer_to_draw->draw_buf.height;
|
||||
img_dsc.header.cf = layer_to_draw->draw_buf.color_format;
|
||||
img_dsc.header.stride = lv_draw_buf_get_stride(&layer_to_draw->draw_buf);
|
||||
img_dsc.header.w = lv_area_get_width(&layer_to_draw->buf_area);
|
||||
img_dsc.header.h = lv_area_get_height(&layer_to_draw->buf_area);
|
||||
img_dsc.header.cf = layer_to_draw->color_format;
|
||||
img_dsc.header.stride = lv_draw_buf_width_to_stride(lv_area_get_width(&layer_to_draw->buf_area),
|
||||
layer_to_draw->color_format);
|
||||
img_dsc.header.always_zero = 0;
|
||||
img_dsc.data = lv_draw_buf_get_buf(&layer_to_draw->draw_buf);
|
||||
img_dsc.data = lv_draw_buf_align(layer_to_draw->buf, layer_to_draw->color_format);
|
||||
|
||||
lv_draw_image_dsc_t new_draw_dsc;
|
||||
lv_memcpy(&new_draw_dsc, draw_dsc, sizeof(lv_draw_image_dsc_t));
|
||||
@ -89,7 +90,7 @@ void lv_draw_sw_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dr
|
||||
#if LV_USE_LAYER_DEBUG
|
||||
lv_draw_fill_dsc_t fill_dsc;
|
||||
lv_draw_fill_dsc_init(&fill_dsc);
|
||||
fill_dsc.color = lv_color_hex(layer_to_draw->draw_buf.color_format == LV_COLOR_FORMAT_ARGB8888 ? 0xff0000 : 0x00ff00);
|
||||
fill_dsc.color = lv_color_hex(layer_to_draw->draw_color_format == LV_COLOR_FORMAT_ARGB8888 ? 0xff0000 : 0x00ff00);
|
||||
fill_dsc.opa = LV_OPA_20;
|
||||
lv_draw_sw_fill(draw_unit, &fill_dsc, &area_rot);
|
||||
|
||||
@ -300,7 +301,7 @@ static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
||||
tmp_buf = lv_draw_buf_malloc(buf_stride * buf_h, cf_final);
|
||||
}
|
||||
|
||||
uint8_t * tmp_buf_aligned = lv_draw_buf_align_buf(tmp_buf, cf_final);
|
||||
uint8_t * tmp_buf_aligned = lv_draw_buf_align(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;
|
||||
|
@ -66,9 +66,8 @@ void lv_draw_sw_mask_rect(lv_draw_unit_t * draw_unit, const lv_draw_mask_rect_ds
|
||||
if(res == LV_DRAW_SW_MASK_RES_FULL_COVER) continue;
|
||||
|
||||
lv_layer_t * target_layer = draw_unit->target_layer;
|
||||
|
||||
lv_color32_t * c32_buf = lv_draw_buf_go_to_xy(&target_layer->draw_buf, draw_area.x1 - target_layer->draw_buf_ofs.x,
|
||||
y - target_layer->draw_buf_ofs.y);
|
||||
lv_color32_t * c32_buf = lv_draw_layer_go_to_xy(target_layer, draw_area.x1 - target_layer->buf_area.x1,
|
||||
y - target_layer->buf_area.y1);
|
||||
|
||||
if(res == LV_DRAW_SW_MASK_RES_TRANSP) {
|
||||
uint32_t i;
|
||||
|
@ -122,10 +122,12 @@ lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_ima
|
||||
lv_layer_t layer;
|
||||
lv_memzero(&layer, sizeof(layer));
|
||||
|
||||
lv_draw_buf_init(&layer.draw_buf, dsc->header.w, dsc->header.h, dsc->header.cf);
|
||||
layer.draw_buf.buf = buf;
|
||||
layer.draw_buf_ofs.x = snapshot_area.x1;
|
||||
layer.draw_buf_ofs.y = snapshot_area.y1;
|
||||
layer.buf = lv_draw_buf_align(buf, cf);
|
||||
layer.buf_area.x1 = snapshot_area.x1;
|
||||
layer.buf_area.y1 = snapshot_area.y1;
|
||||
layer.buf_area.x2 = snapshot_area.x1 + w - 1;
|
||||
layer.buf_area.y2 = snapshot_area.y1 + h - 1;
|
||||
layer.color_format = cf;
|
||||
layer.clip_area = snapshot_area;
|
||||
|
||||
lv_obj_redraw(&layer, obj);
|
||||
|
@ -299,8 +299,9 @@ void lv_canvas_init_layer(lv_obj_t * canvas, lv_layer_t * layer)
|
||||
lv_area_t canvas_area = {0, 0, dsc->header.w - 1, dsc->header.h - 1};
|
||||
lv_memzero(layer, sizeof(*layer));
|
||||
|
||||
lv_draw_buf_init(&layer->draw_buf, dsc->header.w, dsc->header.h, dsc->header.cf);
|
||||
layer->draw_buf.buf = (uint8_t *)dsc->data;
|
||||
layer->buf = lv_draw_buf_align((uint8_t *)dsc->data, dsc->header.cf);
|
||||
layer->color_format = dsc->header.cf;
|
||||
layer->buf_area = canvas_area;
|
||||
layer->clip_area = canvas_area;
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ void test_func_1(void)
|
||||
create_panel(30, true);
|
||||
create_panel(100, true);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("clip_corner_1.png");
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -127,14 +127,14 @@ static void canvas_draw(const char * name, lv_color_format_t large_render_cf)
|
||||
|
||||
static uint8_t canvas2_buf[CANVAS_WIDTH_TO_STRIDE(768, 4) * 390 + LV_DRAW_BUF_ALIGN];
|
||||
lv_obj_t * canvas2 = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas2, lv_draw_buf_align_buf(canvas2_buf, large_render_cf), 768, 390, large_render_cf);
|
||||
lv_canvas_set_buffer(canvas2, lv_draw_buf_align(canvas2_buf, large_render_cf), 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.always_zero = 0;
|
||||
img.data = lv_draw_buf_align_buf(canvas_buf, LV_COLOR_FORMAT_ARGB8888);
|
||||
img.data = lv_draw_buf_align(canvas_buf, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
lv_draw_image_dsc_t img_dsc;
|
||||
lv_draw_image_dsc_init(&img_dsc);
|
||||
|
@ -152,7 +152,7 @@ void create_test_screen(lv_color_format_t render_cf, const char * name)
|
||||
static uint8_t canvas_buf_large[CANVAS_WIDTH_TO_STRIDE(768, 4) * 440 + LV_DRAW_BUF_ALIGN];
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, lv_draw_buf_align_buf(canvas_buf_large, LV_COLOR_FORMAT_ARGB8888), 768, 440,
|
||||
lv_canvas_set_buffer(canvas, lv_draw_buf_align(canvas_buf_large, LV_COLOR_FORMAT_ARGB8888), 768, 440,
|
||||
LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_50);
|
||||
@ -163,7 +163,7 @@ void create_test_screen(lv_color_format_t render_cf, const char * name)
|
||||
static uint8_t canvas_buf_small[CANVAS_WIDTH_TO_STRIDE(100, 4) * 100 + LV_DRAW_BUF_ALIGN];
|
||||
|
||||
lv_image_dsc_t img;
|
||||
img.data = lv_draw_buf_align_buf(canvas_buf_small, render_cf);
|
||||
img.data = lv_draw_buf_align(canvas_buf_small, render_cf);
|
||||
img.header.cf = render_cf;
|
||||
img.header.w = 100;
|
||||
img.header.h = 100;
|
||||
@ -174,7 +174,7 @@ void create_test_screen(lv_color_format_t render_cf, const char * name)
|
||||
lv_draw_image_dsc_init(&img_dsc);
|
||||
img_dsc.src = &img;
|
||||
|
||||
canvas_basic_render(render_cf, lv_draw_buf_align_buf(canvas_buf_small, render_cf));
|
||||
canvas_basic_render(render_cf, lv_draw_buf_align(canvas_buf_small, render_cf));
|
||||
draw_images(&layer, &img_dsc);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
|
@ -73,7 +73,7 @@ bool lv_test_assert_image_eq(const char * fn_ref)
|
||||
lv_refr_now(NULL);
|
||||
|
||||
extern uint8_t * last_flushed_buf;
|
||||
uint8_t * screen_buf = lv_draw_buf_align_buf(last_flushed_buf, LV_COLOR_FORMAT_XRGB8888);
|
||||
uint8_t * screen_buf = lv_draw_buf_align(last_flushed_buf, LV_COLOR_FORMAT_XRGB8888);
|
||||
|
||||
png_image_t p;
|
||||
int res = read_png_file(&p, fn_ref_full);
|
||||
|
Loading…
x
Reference in New Issue
Block a user