diff --git a/src/draw/lv_draw.c b/src/draw/lv_draw.c index 116e3b231..f538756b3 100644 --- a/src/draw/lv_draw.c +++ b/src/draw/lv_draw.c @@ -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*/ } /********************** diff --git a/src/draw/lv_draw.h b/src/draw/lv_draw.h index 8e3c6cb94..9995330dc 100644 --- a/src/draw/lv_draw.h +++ b/src/draw/lv_draw.h @@ -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 diff --git a/src/draw/sw/lv_draw_sw.c b/src/draw/sw/lv_draw_sw.c index 21da4ee6b..c4cd84ba7 100644 --- a/src/draw/sw/lv_draw_sw.c +++ b/src/draw/sw/lv_draw_sw.c @@ -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 **********************/ diff --git a/src/draw/sw/lv_draw_sw.h b/src/draw/sw/lv_draw_sw.h index cba5b480b..323783e9d 100644 --- a/src/draw/sw/lv_draw_sw.h +++ b/src/draw/sw/lv_draw_sw.h @@ -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 ***********************/