From d757aa24de568c6f120bb7e1b085fd12a058c882 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 15 Jan 2024 17:39:55 +0100 Subject: [PATCH] fix(nxp): follow LVGL changes (#5339) --- src/draw/nxp/pxp/lv_draw_pxp.c | 4 ++- src/draw/nxp/pxp/lv_draw_pxp_fill.c | 3 ++- src/draw/nxp/pxp/lv_draw_pxp_img.c | 7 ++--- src/draw/nxp/pxp/lv_draw_pxp_layer.c | 31 ++++++++-------------- src/draw/nxp/pxp/lv_pxp_utils.h | 10 +++++-- src/draw/nxp/vglite/lv_draw_vglite.c | 9 +++---- src/draw/nxp/vglite/lv_draw_vglite_img.c | 6 ++--- src/draw/nxp/vglite/lv_draw_vglite_layer.c | 31 ++++++++-------------- src/draw/nxp/vglite/lv_vglite_utils.h | 10 +++++-- 9 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/draw/nxp/pxp/lv_draw_pxp.c b/src/draw/nxp/pxp/lv_draw_pxp.c index 55df3dc84..3bd0c8ba4 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp.c +++ b/src/draw/nxp/pxp/lv_draw_pxp.c @@ -370,6 +370,7 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u) lv_draw_task_t * t = u->task_act; lv_draw_unit_t * draw_unit = (lv_draw_unit_t *)u; lv_layer_t * layer = draw_unit->target_layer; + lv_draw_buf_t * draw_buf = layer->draw_buf; lv_area_t draw_area; if(!_lv_area_intersect(&draw_area, &t->area, draw_unit->clip_area)) @@ -377,8 +378,9 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u) /* Make area relative to the buffer */ lv_area_move(&draw_area, -layer->buf_area.x1, -layer->buf_area.y1); + /* Invalidate only the drawing area */ - lv_draw_buf_invalidate_cache(layer->buf, layer->buf_stride, layer->color_format, &draw_area); + lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &draw_area); switch(t->type) { case LV_DRAW_TASK_TYPE_FILL: diff --git a/src/draw/nxp/pxp/lv_draw_pxp_fill.c b/src/draw/nxp/pxp/lv_draw_pxp_fill.c index 9d61c4005..60873ede0 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp_fill.c +++ b/src/draw/nxp/pxp/lv_draw_pxp_fill.c @@ -53,6 +53,7 @@ void lv_draw_pxp_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc return; lv_layer_t * layer = draw_unit->target_layer; + lv_draw_buf_t * draw_buf = layer->draw_buf; lv_area_t rel_coords; lv_area_copy(&rel_coords, coords); @@ -66,7 +67,7 @@ void lv_draw_pxp_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc if(!_lv_area_intersect(&blend_area, &rel_coords, &rel_clip_area)) return; /*Fully clipped, nothing to do*/ - _pxp_fill(layer->buf, &blend_area, layer->buf_stride, layer->color_format, dsc); + _pxp_fill(draw_buf->data, &blend_area, draw_buf->header.stride, draw_buf->header.cf, dsc); } /********************** diff --git a/src/draw/nxp/pxp/lv_draw_pxp_img.c b/src/draw/nxp/pxp/lv_draw_pxp_img.c index 962fdd684..9e5205667 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp_img.c +++ b/src/draw/nxp/pxp/lv_draw_pxp_img.c @@ -67,6 +67,7 @@ void lv_draw_pxp_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc return; lv_layer_t * layer = draw_unit->target_layer; + lv_draw_buf_t * draw_buf = layer->draw_buf; const lv_image_dsc_t * img_dsc = dsc->src; lv_area_t rel_coords; @@ -94,9 +95,9 @@ void lv_draw_pxp_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc int32_t src_stride = img_dsc->header.stride; lv_color_format_t src_cf = img_dsc->header.cf; - uint8_t * dest_buf = layer->buf; - int32_t dest_stride = layer->buf_stride; - lv_color_format_t dest_cf = layer->color_format; + uint8_t * dest_buf = draw_buf->data; + int32_t dest_stride = draw_buf->header.stride; + lv_color_format_t dest_cf = draw_buf->header.cf; bool has_recolor = (dsc->recolor_opa > LV_OPA_MIN); if(has_recolor && !has_transform) diff --git a/src/draw/nxp/pxp/lv_draw_pxp_layer.c b/src/draw/nxp/pxp/lv_draw_pxp_layer.c index 385e97c46..ee474d721 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp_layer.c +++ b/src/draw/nxp/pxp/lv_draw_pxp_layer.c @@ -54,33 +54,24 @@ void lv_draw_pxp_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * d const lv_area_t * coords) { lv_layer_t * layer_to_draw = (lv_layer_t *)draw_dsc->src; + const lv_draw_buf_t * draw_buf = layer_to_draw->draw_buf; - /*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->buf == NULL) + /* It can happen that nothing was draw on a layer and therefore its buffer is not allocated. + * In this case just return. + */ + if(draw_buf == NULL) return; - uint32_t width = lv_area_get_width(&layer_to_draw->buf_area); - uint32_t height = lv_area_get_height(&layer_to_draw->buf_area); - const lv_area_t area = { + const lv_area_t area_to_draw = { .x1 = 0, .y1 = 0, - .x2 = width - 1, - .y2 = height - 1 + .x2 = draw_buf->header.w - 1, + .y2 = draw_buf->header.h - 1 }; - lv_draw_buf_invalidate_cache(layer_to_draw->buf, layer_to_draw->buf_stride, layer_to_draw->color_format, &area); - - lv_image_dsc_t img_dsc = {0}; - img_dsc.header.w = width; - img_dsc.header.h = height; - img_dsc.header.cf = layer_to_draw->color_format; - img_dsc.header.stride = layer_to_draw->buf_stride; - 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)); - new_draw_dsc.src = &img_dsc; + lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &area_to_draw); + lv_draw_image_dsc_t new_draw_dsc = *draw_dsc; + new_draw_dsc.src = draw_buf; lv_draw_pxp_img(draw_unit, &new_draw_dsc, coords); #if LV_USE_LAYER_DEBUG || LV_USE_PARALLEL_DRAW_DEBUG diff --git a/src/draw/nxp/pxp/lv_pxp_utils.h b/src/draw/nxp/pxp/lv_pxp_utils.h index 928517c55..a1f0a16c4 100644 --- a/src/draw/nxp/pxp/lv_pxp_utils.h +++ b/src/draw/nxp/pxp/lv_pxp_utils.h @@ -31,12 +31,18 @@ extern "C" { #if LV_USE_PXP_ASSERT #define PXP_ASSERT(expr) LV_ASSERT(expr) -#define PXP_ASSERT_MSG(expr, msg) LV_ASSERT_MSG(expr, msg) #else #define PXP_ASSERT(expr) -#define PXP_ASSERT_MSG(expr, msg) LV_LOG_ERROR(msg) #endif +#define PXP_ASSERT_MSG(expr, msg) \ + do { \ + if(!(expr)) { \ + LV_LOG_ERROR(msg); \ + PXP_ASSERT(false); \ + } \ + } while(0) + /********************** * TYPEDEFS **********************/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite.c b/src/draw/nxp/vglite/lv_draw_vglite.c index 2b5570b31..f701f6800 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite.c +++ b/src/draw/nxp/vglite/lv_draw_vglite.c @@ -334,12 +334,11 @@ static void _vglite_execute_drawing(lv_draw_vglite_unit_t * u) lv_draw_task_t * t = u->task_act; lv_draw_unit_t * draw_unit = (lv_draw_unit_t *)u; lv_layer_t * layer = draw_unit->target_layer; + lv_draw_buf_t * draw_buf = layer->draw_buf; /* Set target buffer */ - uint32_t buf_width = lv_area_get_width(&layer->buf_area); - uint32_t buf_height = lv_area_get_height(&layer->buf_area); - - vglite_set_dest_buf(layer->buf, buf_width, buf_height, layer->buf_stride, layer->color_format); + vglite_set_dest_buf(draw_buf->data, draw_buf->header.w, draw_buf->header.h, draw_buf->header.stride, + draw_buf->header.cf); lv_area_t clip_area; lv_area_copy(&clip_area, draw_unit->clip_area); @@ -353,7 +352,7 @@ static void _vglite_execute_drawing(lv_draw_vglite_unit_t * u) return; /*Fully clipped, nothing to do*/ /* Invalidate the drawing area */ - lv_draw_buf_invalidate_cache(layer->buf, layer->buf_stride, layer->color_format, &draw_area); + lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &draw_area); /* Set scissor area */ vglite_set_scissor(&clip_area); diff --git a/src/draw/nxp/vglite/lv_draw_vglite_img.c b/src/draw/nxp/vglite/lv_draw_vglite_img.c index a95374904..6dacad88b 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite_img.c +++ b/src/draw/nxp/vglite/lv_draw_vglite_img.c @@ -163,9 +163,9 @@ void lv_draw_vglite_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * vglite_set_src_buf(src_buf, lv_area_get_width(&src_area), lv_area_get_height(&src_area), src_stride, src_cf); #if LV_USE_VGLITE_BLIT_SPLIT - void * dest_buf = layer->buf; - uint32_t dest_stride = layer->buf_stride; - lv_color_format_t dest_cf = layer->color_format; + void * dest_buf = layer->draw_buf->data; + uint32_t dest_stride = layer->draw_buf->header.stride; + lv_color_format_t dest_cf = layer->draw_buf->header.cf; if(!has_transform) _vglite_blit_split(dest_buf, &blend_area, dest_stride, dest_cf, diff --git a/src/draw/nxp/vglite/lv_draw_vglite_layer.c b/src/draw/nxp/vglite/lv_draw_vglite_layer.c index 5f7b46528..3a46a142c 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite_layer.c +++ b/src/draw/nxp/vglite/lv_draw_vglite_layer.c @@ -54,33 +54,24 @@ void lv_draw_vglite_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t const lv_area_t * coords) { lv_layer_t * layer_to_draw = (lv_layer_t *)draw_dsc->src; + const lv_draw_buf_t * draw_buf = layer_to_draw->draw_buf; - /*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->buf == NULL) + /* It can happen that nothing was draw on a layer and therefore its buffer is not allocated. + * In this case just return. + */ + if(draw_buf == NULL) return; - uint32_t width = lv_area_get_width(&layer_to_draw->buf_area); - uint32_t height = lv_area_get_height(&layer_to_draw->buf_area); - const lv_area_t area = { + const lv_area_t area_to_draw = { .x1 = 0, .y1 = 0, - .x2 = width - 1, - .y2 = height - 1 + .x2 = draw_buf->header.w - 1, + .y2 = draw_buf->header.h - 1 }; - lv_draw_buf_invalidate_cache(layer_to_draw->buf, layer_to_draw->buf_stride, layer_to_draw->color_format, &area); - - lv_image_dsc_t img_dsc = {0}; - img_dsc.header.w = width; - img_dsc.header.h = height; - img_dsc.header.cf = layer_to_draw->color_format; - img_dsc.header.stride = layer_to_draw->buf_stride; - 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)); - new_draw_dsc.src = &img_dsc; + lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &area_to_draw); + lv_draw_image_dsc_t new_draw_dsc = *draw_dsc; + new_draw_dsc.src = draw_buf; lv_draw_vglite_img(draw_unit, &new_draw_dsc, coords); #if LV_USE_LAYER_DEBUG || LV_USE_PARALLEL_DRAW_DEBUG diff --git a/src/draw/nxp/vglite/lv_vglite_utils.h b/src/draw/nxp/vglite/lv_vglite_utils.h index 822d162a4..814276223 100644 --- a/src/draw/nxp/vglite/lv_vglite_utils.h +++ b/src/draw/nxp/vglite/lv_vglite_utils.h @@ -37,12 +37,18 @@ extern "C" { #if LV_USE_VGLITE_ASSERT #define VGLITE_ASSERT(expr) LV_ASSERT(expr) -#define VGLITE_ASSERT_MSG(expr, msg) LV_ASSERT_MSG(expr, msg) #else #define VGLITE_ASSERT(expr) -#define VGLITE_ASSERT_MSG(expr, msg) LV_LOG_ERROR(msg) #endif +#define VGLITE_ASSERT_MSG(expr, msg) \ + do { \ + if(!(expr)) { \ + LV_LOG_ERROR(msg); \ + VGLITE_ASSERT(false); \ + } \ + } while(0) + #define VGLITE_CHECK_ERROR(function) \ do { \ vg_lite_error_t error = function; \