mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-28 04:03:45 +08:00
fix(draw): stride handling in case of layers
This commit is contained in:
parent
981a9843fd
commit
386250a336
@ -338,11 +338,12 @@ lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t c
|
||||
|
||||
void * lv_draw_layer_alloc_buf(lv_layer_t * layer)
|
||||
{
|
||||
int32_t w = lv_area_get_width(&layer->buf_area);
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(w, layer->color_format);
|
||||
|
||||
/*If the buffer of the layer is not allocated yet, allocate it now*/
|
||||
if(layer->buf == NULL) {
|
||||
int32_t w = lv_area_get_width(&layer->buf_area);
|
||||
int32_t h = lv_area_get_height(&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);
|
||||
|
||||
@ -368,6 +369,10 @@ void * lv_draw_layer_alloc_buf(lv_layer_t * layer)
|
||||
}
|
||||
}
|
||||
|
||||
/*Set the stride also for static allocated buffers as well as for new dynamically allocated*/
|
||||
layer->buf_stride = stride;
|
||||
|
||||
/*Make sure the buffer address is aligned in case of already allocated buffers*/
|
||||
return lv_draw_buf_align(layer->buf, layer->color_format);
|
||||
}
|
||||
|
||||
|
@ -58,10 +58,9 @@ void lv_draw_sw_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dr
|
||||
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.stride = layer_to_draw->buf_stride;
|
||||
img_dsc.header.always_zero = 0;
|
||||
img_dsc.data = lv_draw_buf_align(layer_to_draw->buf, layer_to_draw->color_format);
|
||||
img_dsc.data = layer_to_draw->buf;
|
||||
|
||||
lv_draw_image_dsc_t new_draw_dsc;
|
||||
lv_memcpy(&new_draw_dsc, draw_dsc, sizeof(lv_draw_image_dsc_t));
|
||||
|
Loading…
Reference in New Issue
Block a user