1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(draw): add draw_ctx->buffer_copy

realted to: #3087
This commit is contained in:
Gabor Kiss-Vamosi 2022-02-18 13:56:05 +01:00
parent 48cb4e9164
commit d034511bba
4 changed files with 49 additions and 7 deletions

View File

@ -39,12 +39,7 @@
void lv_draw_init(void)
{
// backend_head = NULL;
// lv_draw_sw_init();
//
//#if LV_USE_GPU_STM32_DMA2D == 0
// lv_gpu_stm32_dma2d_init();
//#endif
/*Nothing to init now*/
}
/**********************

View File

@ -88,8 +88,25 @@ typedef struct _lv_draw_ctx_t {
/**
* Wait until all background operations are finished. (E.g. GPU operations)
*/
void (*wait_for_finish)(struct _lv_draw_ctx_t * draw);
void (*wait_for_finish)(struct _lv_draw_ctx_t * draw_ctx);
/**
* Copy an area from buffer to an other
* @param draw_ctx pointer to a draw context
* @param dest_buf copy the buffer into this buffer
* @param dest_stride the width of the dest_buf in pixels
* @param dest_area the destination area
* @param src_buf copy from this buffer
* @param src_stride the width of src_buf in pixels
* @param src_area the source area.
*
* @note dest_area and src_area must have the same width and height
* but can have different x and y position.
* @note dest_area and src_area must be clipped to the real dimensions of the buffers
*/
void (*buffer_copy)(struct _lv_draw_ctx_t * draw_ctx, void * dest_buf, lv_coord_t dest_stride,
const lv_area_t * dest_area,
void * src_buf, lv_coord_t src_stride, const lv_area_t * src_area);
#if LV_USE_USER_DATA
void * user_data;
#endif

View File

@ -52,6 +52,7 @@ void lv_draw_sw_init_ctx(lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx)
draw_sw_ctx->base_draw.draw_line = lv_draw_sw_line;
draw_sw_ctx->base_draw.draw_polygon = lv_draw_sw_polygon;
draw_sw_ctx->base_draw.wait_for_finish = lv_draw_sw_wait_for_finish;
draw_sw_ctx->base_draw.buffer_copy = lv_draw_sw_buffer_copy;
draw_sw_ctx->blend = lv_draw_sw_blend_basic;
}
@ -69,6 +70,32 @@ void lv_draw_sw_wait_for_finish(lv_draw_ctx_t * draw_ctx)
/*Nothing to wait for*/
}
void lv_draw_sw_buffer_copy(lv_draw_ctx_t * draw_ctx,
void * dest_buf, lv_coord_t dest_stride, const lv_area_t * dest_area,
void * src_buf, lv_coord_t src_stride, const lv_area_t * src_area)
{
LV_UNUSED(draw_ctx);
lv_color_t * dest_bufc = dest_buf;
lv_color_t * src_bufc = src_buf;
/*Got the first pixel of each buffer*/
dest_bufc += dest_stride * dest_area->y1;
dest_bufc += dest_area->x1;
src_bufc += src_stride * src_area->y1;
src_bufc += src_area->x1;
uint32_t line_length = lv_area_get_width(dest_area) * sizeof(lv_color_t);
lv_coord_t y;
for(y = dest_area->y1; y <= dest_area->y2; y++) {
lv_memcpy(dest_bufc, src_bufc, line_length);
dest_bufc += dest_stride;
src_bufc += src_stride;
}
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -63,6 +63,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_line(struct _lv_draw_ctx_t * draw_ctx, con
void lv_draw_sw_polygon(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc,
const lv_point_t * points, uint16_t point_cnt);
void lv_draw_sw_buffer_copy(lv_draw_ctx_t * draw_ctx,
void * dest_buf, lv_coord_t dest_stride, const lv_area_t * dest_area,
void * src_buf, lv_coord_t src_stride, const lv_area_t * src_area);
/***********************
* GLOBAL VARIABLES
***********************/