feat(draw_buf): use draw_buf as parameter of invalidate_cache API (#5602)
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
@@ -70,9 +70,20 @@ void * lv_draw_buf_align(void * data, lv_color_format_t color_format)
|
|||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_draw_buf_invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area)
|
void lv_draw_buf_invalidate_cache(lv_draw_buf_t * draw_buf, const lv_area_t * area)
|
||||||
{
|
{
|
||||||
if(handlers.invalidate_cache_cb) handlers.invalidate_cache_cb(buf, stride, color_format, area);
|
if(handlers.invalidate_cache_cb) {
|
||||||
|
LV_ASSERT_NULL(draw_buf);
|
||||||
|
const lv_image_header_t * header = &draw_buf->header;
|
||||||
|
lv_area_t full;
|
||||||
|
if(area == NULL) {
|
||||||
|
full = (lv_area_t) {
|
||||||
|
0, 0, header->w - 1, header->h - 1
|
||||||
|
};
|
||||||
|
area = &full;
|
||||||
|
}
|
||||||
|
handlers.invalidate_cache_cb(draw_buf, area);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a)
|
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a)
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ typedef void (*lv_draw_buf_free_cb)(void * draw_buf);
|
|||||||
|
|
||||||
typedef void * (*lv_draw_buf_align_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, uint32_t stride, lv_color_format_t color_format,
|
typedef void (*lv_draw_buf_invalidate_cache_cb)(lv_draw_buf_t * draw_buf, const lv_area_t * area);
|
||||||
const lv_area_t * area);
|
|
||||||
|
|
||||||
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_width_to_stride_cb)(uint32_t w, lv_color_format_t color_format);
|
||||||
|
|
||||||
@@ -112,12 +111,11 @@ void * lv_draw_buf_align(void * buf, lv_color_format_t color_format);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate the cache of the buffer
|
* Invalidate the cache of the buffer
|
||||||
* @param buf a memory address to invalidate
|
* @param draw_buf the draw buffer needs to be invalidated
|
||||||
* @param stride stride of the buffer
|
* @param area the area to invalidate in the buffer,
|
||||||
* @param color_format color format of the buffer
|
* use NULL to invalidate the whole draw buffer address range
|
||||||
* @param area the area to invalidate in the buffer
|
|
||||||
*/
|
*/
|
||||||
void lv_draw_buf_invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area);
|
void lv_draw_buf_invalidate_cache(lv_draw_buf_t * draw_buf, const lv_area_t * area);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the stride in bytes based on a width and color format
|
* Calculate the stride in bytes based on a width and color format
|
||||||
|
|||||||
@@ -58,8 +58,12 @@ void lv_draw_buf_pxp_init_handlers(void)
|
|||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void _invalidate_cache(void * buf, uint32_t stride, lv_color_format_t cf, const lv_area_t * area)
|
static void _invalidate_cache(lv_draw_buf_t * draw_buf, const lv_area_t * area)
|
||||||
{
|
{
|
||||||
|
const lv_image_header_t * header = &draw_buf->header;
|
||||||
|
uint32_t stride = header->stride;
|
||||||
|
lv_color_format_t cf = header->cf;
|
||||||
|
|
||||||
if(area->y1 == 0) {
|
if(area->y1 == 0) {
|
||||||
uint16_t size = stride * lv_area_get_height(area);
|
uint16_t size = stride * lv_area_get_height(area);
|
||||||
|
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ static void _pxp_execute_drawing(lv_draw_pxp_unit_t * u)
|
|||||||
lv_area_move(&draw_area, -layer->buf_area.x1, -layer->buf_area.y1);
|
lv_area_move(&draw_area, -layer->buf_area.x1, -layer->buf_area.y1);
|
||||||
|
|
||||||
/* Invalidate only the drawing area */
|
/* Invalidate only the drawing area */
|
||||||
lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &draw_area);
|
lv_draw_buf_invalidate_cache(draw_buf, &draw_area);
|
||||||
|
|
||||||
switch(t->type) {
|
switch(t->type) {
|
||||||
case LV_DRAW_TASK_TYPE_FILL:
|
case LV_DRAW_TASK_TYPE_FILL:
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void lv_draw_pxp_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * d
|
|||||||
.x2 = draw_buf->header.w - 1,
|
.x2 = draw_buf->header.w - 1,
|
||||||
.y2 = draw_buf->header.h - 1
|
.y2 = draw_buf->header.h - 1
|
||||||
};
|
};
|
||||||
lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &area_to_draw);
|
lv_draw_buf_invalidate_cache(draw_buf, &area_to_draw);
|
||||||
|
|
||||||
lv_draw_image_dsc_t new_draw_dsc = *draw_dsc;
|
lv_draw_image_dsc_t new_draw_dsc = *draw_dsc;
|
||||||
new_draw_dsc.src = draw_buf;
|
new_draw_dsc.src = draw_buf;
|
||||||
|
|||||||
@@ -90,8 +90,12 @@ static void * _buf_align(void * buf, lv_color_format_t cf)
|
|||||||
return buf_u8;
|
return buf_u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _invalidate_cache(void * buf, uint32_t stride, lv_color_format_t cf, const lv_area_t * area)
|
static void _invalidate_cache(lv_draw_buf_t * draw_buf, const lv_area_t * area)
|
||||||
{
|
{
|
||||||
|
const lv_image_header_t * header = &draw_buf->header;
|
||||||
|
uint32_t stride = header->stride;
|
||||||
|
lv_color_format_t cf = header->cf;
|
||||||
|
|
||||||
if(area->y1 == 0) {
|
if(area->y1 == 0) {
|
||||||
uint16_t size = stride * lv_area_get_height(area);
|
uint16_t size = stride * lv_area_get_height(area);
|
||||||
|
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ static void _vglite_execute_drawing(lv_draw_vglite_unit_t * u)
|
|||||||
return; /*Fully clipped, nothing to do*/
|
return; /*Fully clipped, nothing to do*/
|
||||||
|
|
||||||
/* Invalidate the drawing area */
|
/* Invalidate the drawing area */
|
||||||
lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &draw_area);
|
lv_draw_buf_invalidate_cache(draw_buf, &draw_area);
|
||||||
|
|
||||||
/* Set scissor area */
|
/* Set scissor area */
|
||||||
vglite_set_scissor(&clip_area);
|
vglite_set_scissor(&clip_area);
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ static void _draw_vglite_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t
|
|||||||
/* Set vgmatrix. */
|
/* Set vgmatrix. */
|
||||||
vglite_set_translation_matrix(&blend_area);
|
vglite_set_translation_matrix(&blend_area);
|
||||||
|
|
||||||
lv_draw_buf_invalidate_cache((void *)mask_buf, mask_stride, LV_COLOR_FORMAT_A8, &mask_area);
|
lv_draw_buf_invalidate_cache(draw_buf, &mask_area);
|
||||||
|
|
||||||
_vglite_draw_letter(&mask_area, glyph_draw_dsc->color, glyph_draw_dsc->opa);
|
_vglite_draw_letter(&mask_area, glyph_draw_dsc->color, glyph_draw_dsc->opa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void lv_draw_vglite_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t
|
|||||||
.x2 = draw_buf->header.w - 1,
|
.x2 = draw_buf->header.w - 1,
|
||||||
.y2 = draw_buf->header.h - 1
|
.y2 = draw_buf->header.h - 1
|
||||||
};
|
};
|
||||||
lv_draw_buf_invalidate_cache(draw_buf->data, draw_buf->header.stride, draw_buf->header.cf, &area_to_draw);
|
lv_draw_buf_invalidate_cache(draw_buf, &area_to_draw);
|
||||||
|
|
||||||
lv_draw_image_dsc_t new_draw_dsc = *draw_dsc;
|
lv_draw_image_dsc_t new_draw_dsc = *draw_dsc;
|
||||||
new_draw_dsc.src = draw_buf;
|
new_draw_dsc.src = draw_buf;
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ static void execute_drawing(lv_draw_dave2d_unit_t * u);
|
|||||||
|
|
||||||
#if defined(RENESAS_CORTEX_M85)
|
#if defined(RENESAS_CORTEX_M85)
|
||||||
#if (BSP_CFG_DCACHE_ENABLED)
|
#if (BSP_CFG_DCACHE_ENABLED)
|
||||||
static void _dave2d_buf_invalidate_cache_cb(void * buf, uint32_t stride, lv_color_format_t color_format,
|
static void _dave2d_buf_invalidate_cache_cb(lv_draw_buf_t * draw_buf, const lv_area_t * area);
|
||||||
const lv_area_t * area);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -123,9 +122,12 @@ static void lv_draw_buf_dave2d_init_handlers(void)
|
|||||||
|
|
||||||
#if defined(RENESAS_CORTEX_M85)
|
#if defined(RENESAS_CORTEX_M85)
|
||||||
#if (BSP_CFG_DCACHE_ENABLED)
|
#if (BSP_CFG_DCACHE_ENABLED)
|
||||||
static void _dave2d_buf_invalidate_cache_cb(void * buf, uint32_t stride, lv_color_format_t color_format,
|
static void _dave2d_buf_invalidate_cache_cb(lv_draw_buf_t * draw_buf, const lv_area_t * area)
|
||||||
const lv_area_t * area)
|
|
||||||
{
|
{
|
||||||
|
const lv_image_header_t * header = &draw_buf->header;
|
||||||
|
uint32_t stride = header->stride;
|
||||||
|
lv_color_format_t cf = header->cf;
|
||||||
|
|
||||||
uint8_t * address = buf;
|
uint8_t * address = buf;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
uint32_t bytes_per_pixel = lv_color_format_get_size(color_format);
|
uint32_t bytes_per_pixel = lv_color_format_get_size(color_format);
|
||||||
@@ -473,7 +475,7 @@ static void execute_drawing(lv_draw_dave2d_unit_t * u)
|
|||||||
lv_area_move(&clipped_area, x, y);
|
lv_area_move(&clipped_area, x, y);
|
||||||
|
|
||||||
/* Invalidate cache */
|
/* Invalidate cache */
|
||||||
lv_draw_buf_invalidate_cache(layer->draw_buf->data, layer->draw_buf->header.stride, layer->color_format, &clipped_area);
|
lv_draw_buf_invalidate_cache(layer->draw_buf, &clipped_area);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -44,9 +44,6 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
|||||||
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
|
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
|
||||||
static void decoder_cache_free(lv_image_cache_data_t * cached_data, void * user_data);
|
static void decoder_cache_free(lv_image_cache_data_t * cached_data, void * user_data);
|
||||||
static void image_color32_pre_mul(lv_color32_t * img_data, uint32_t px_size);
|
static void image_color32_pre_mul(lv_color32_t * img_data, uint32_t px_size);
|
||||||
static void image_invalidate_cache(void * buf, uint32_t stride,
|
|
||||||
uint32_t width, uint32_t height,
|
|
||||||
lv_color_format_t cf);
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -92,16 +89,6 @@ static void image_color32_pre_mul(lv_color32_t * img_data, uint32_t px_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void image_invalidate_cache(void * buf, uint32_t stride,
|
|
||||||
uint32_t width, uint32_t height,
|
|
||||||
lv_color_format_t cf)
|
|
||||||
{
|
|
||||||
width = lv_vg_lite_width_align(width);
|
|
||||||
lv_area_t image_area;
|
|
||||||
lv_area_set(&image_area, 0, 0, width - 1, height - 1);
|
|
||||||
lv_draw_buf_invalidate_cache(buf, stride, cf, &image_area);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t image_stride(const lv_image_header_t * header)
|
static uint32_t image_stride(const lv_image_header_t * header)
|
||||||
{
|
{
|
||||||
/* use stride in header */
|
/* use stride in header */
|
||||||
@@ -250,8 +237,7 @@ static lv_result_t decoder_open_variable(lv_image_decoder_t * decoder, lv_image_
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* invalidate D-Cache */
|
/* invalidate D-Cache */
|
||||||
image_invalidate_cache(draw_buf->data, dest_stride, width, height, DEST_IMG_FORMAT);
|
lv_draw_buf_invalidate_cache(draw_buf, NULL);
|
||||||
|
|
||||||
LV_LOG_INFO("image %p (W%" LV_PRId32 " x H%" LV_PRId32 ", buffer: %p, cf: %d) decode finish",
|
LV_LOG_INFO("image %p (W%" LV_PRId32 " x H%" LV_PRId32 ", buffer: %p, cf: %d) decode finish",
|
||||||
image_data, width, height, draw_buf->data, src_cf);
|
image_data, width, height, draw_buf->data, src_cf);
|
||||||
|
|
||||||
@@ -349,7 +335,7 @@ static lv_result_t decoder_open_file(lv_image_decoder_t * decoder, lv_image_deco
|
|||||||
lv_fs_close(&file);
|
lv_fs_close(&file);
|
||||||
|
|
||||||
/* invalidate D-Cache */
|
/* invalidate D-Cache */
|
||||||
image_invalidate_cache(draw_buf->data, dest_stride, width, height, src_header.cf);
|
lv_draw_buf_invalidate_cache(draw_buf, NULL);
|
||||||
|
|
||||||
LV_LOG_INFO("image %s (W%" LV_PRId32 " x H%" LV_PRId32 ", buffer: %p cf: %d) decode finish",
|
LV_LOG_INFO("image %s (W%" LV_PRId32 " x H%" LV_PRId32 ", buffer: %p cf: %d) decode finish",
|
||||||
path, width, height, draw_buf->data, src_header.cf);
|
path, width, height, draw_buf->data, src_header.cf);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area);
|
static void invalidate_cache(lv_draw_buf_t * draw_buf, const lv_area_t * area);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -50,24 +50,19 @@ void lv_nuttx_cache_init(void)
|
|||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
static void invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area)
|
static void invalidate_cache(lv_draw_buf_t * draw_buf, const lv_area_t * area)
|
||||||
{
|
{
|
||||||
LV_UNUSED(color_format);
|
LV_ASSERT_NULL(draw_buf);
|
||||||
LV_ASSERT_NULL(buf);
|
void * buf = draw_buf->data;
|
||||||
|
uint32_t stride = draw_buf->header.stride;
|
||||||
|
lv_color_format_t cf = draw_buf->header.cf;
|
||||||
|
|
||||||
lv_uintptr_t start;
|
lv_uintptr_t start;
|
||||||
lv_uintptr_t end;
|
lv_uintptr_t end;
|
||||||
|
|
||||||
if(area) {
|
|
||||||
int32_t h = lv_area_get_height(area);
|
int32_t h = lv_area_get_height(area);
|
||||||
start = (lv_uintptr_t)buf + area->y1 * stride;
|
start = (lv_uintptr_t)buf + area->y1 * stride;
|
||||||
end = start + h * stride;
|
end = start + h * stride;
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* If area is empty, use stride as length */
|
|
||||||
start = (lv_uintptr_t)buf;
|
|
||||||
end = start + stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
LV_UNUSED(start);
|
LV_UNUSED(start);
|
||||||
LV_UNUSED(end);
|
LV_UNUSED(end);
|
||||||
|
|||||||
Reference in New Issue
Block a user