diff --git a/src/draw/lv_draw_buf.c b/src/draw/lv_draw_buf.c index 1a9059855..ae662a27a 100644 --- a/src/draw/lv_draw_buf.c +++ b/src/draw/lv_draw_buf.c @@ -300,9 +300,14 @@ lv_draw_buf_t * lv_draw_buf_create_user(const lv_draw_buf_handlers_t * handlers, } lv_draw_buf_t * lv_draw_buf_dup(const lv_draw_buf_t * draw_buf) +{ + return lv_draw_buf_dup_user(&default_handlers, draw_buf); +} + +lv_draw_buf_t * lv_draw_buf_dup_user(const lv_draw_buf_handlers_t * handlers, const lv_draw_buf_t * draw_buf) { const lv_image_header_t * header = &draw_buf->header; - lv_draw_buf_t * new_buf = lv_draw_buf_create(header->w, header->h, header->cf, header->stride); + lv_draw_buf_t * new_buf = lv_draw_buf_create_user(handlers, header->w, header->h, header->cf, header->stride); if(new_buf == NULL) return NULL; new_buf->header.flags = draw_buf->header.flags; diff --git a/src/draw/lv_draw_buf.h b/src/draw/lv_draw_buf.h index 753fc3c07..571d24cbc 100644 --- a/src/draw/lv_draw_buf.h +++ b/src/draw/lv_draw_buf.h @@ -250,6 +250,21 @@ lv_draw_buf_t * lv_draw_buf_create(uint32_t w, uint32_t h, lv_color_format_t cf, lv_draw_buf_t * lv_draw_buf_create_user(const lv_draw_buf_handlers_t * handlers, uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride); +/** + * Duplicate a draw buf with same image size, stride and color format. Copy the image data too. + * @param draw_buf the draw buf to duplicate + * @return the duplicated draw buf on success, NULL if failed + */ +lv_draw_buf_t * lv_draw_buf_dup(const lv_draw_buf_t * draw_buf); + +/** + * Duplicate a draw buf with same image size, stride and color format. Copy the image data too. + * @param handlers the draw buffer handlers + * @param draw_buf the draw buf to duplicate + * @return the duplicated draw buf on success, NULL if failed + */ +lv_draw_buf_t * lv_draw_buf_dup_user(const lv_draw_buf_handlers_t * handlers, const lv_draw_buf_t * draw_buf); + /** * Initialize a draw buf with the given buffer and parameters. * @param draw_buf the draw buf to initialize @@ -264,13 +279,6 @@ lv_draw_buf_t * lv_draw_buf_create_user(const lv_draw_buf_handlers_t * handlers, lv_result_t lv_draw_buf_init(lv_draw_buf_t * draw_buf, uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride, void * data, uint32_t data_size); -/** - * Duplicate a draw buf with same image size, stride and color format. Copy the image data too. - * @param draw_buf the draw buf to duplicate - * @return the duplicated draw buf on success, NULL if failed - */ -lv_draw_buf_t * lv_draw_buf_dup(const lv_draw_buf_t * draw_buf); - /** * Keep using the existing memory, reshape the draw buffer to the given width and height. * Return NULL if data_size is smaller than the required size.