From b97a166020f69748e3c8ec10385ddacbb326a4b3 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Sat, 28 Dec 2024 12:54:11 +0800 Subject: [PATCH] improve to support linux g2d --- docs/changes.md | 3 + src/awtk_global.c | 8 +- src/base/bitmap.c | 48 +++++--- src/base/bitmap.h | 49 ++++++++ src/base/canvas_offline.inc | 12 +- src/base/graphic_buffer.h | 20 ++++ src/blend/image_g2d.h | 3 +- src/blend/soft_g2d.c | 8 +- src/graphic_buffer/graphic_buffer_default.c | 7 ++ src/lcd/lcd_mem.h | 69 ++++++++++-- src/lcd/lcd_mem.inc | 119 +++++++++++++++----- src/lcd/lcd_mem_bgr565.c | 17 ++- src/lcd/lcd_mem_bgr565.h | 40 ++++++- src/lcd/lcd_mem_bgr888.c | 13 +++ src/lcd/lcd_mem_bgr888.h | 36 ++++++ src/lcd/lcd_mem_bgra8888.c | 17 ++- src/lcd/lcd_mem_bgra8888.h | 37 ++++++ src/lcd/lcd_mem_rgb565.c | 17 ++- src/lcd/lcd_mem_rgb565.h | 36 ++++++ src/lcd/lcd_mem_rgb888.c | 17 ++- src/lcd/lcd_mem_rgb888.h | 37 ++++++ src/lcd/lcd_mem_rgba8888.c | 17 ++- src/lcd/lcd_mem_rgba8888.h | 37 ++++++ 23 files changed, 590 insertions(+), 77 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index c6affc4b95..7e7ef2fc30 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,8 @@ # 最新动态 +2024/12/28 + * 重构以支持Linux G2D。 + 2024/12/27 * 修复fdb资源泄露的问题(感谢智明提供补丁) diff --git a/src/awtk_global.c b/src/awtk_global.c index 8df95ce6b2..412a7a9c68 100644 --- a/src/awtk_global.c +++ b/src/awtk_global.c @@ -331,6 +331,10 @@ ret_t tk_init(wh_t w, wh_t h, app_type_t app_type, const char* app_name, const c ENSURE(system_info_init(app_type, app_name, app_root) == RET_OK); return_value_if_fail(tk_init_internal() == RET_OK, RET_FAIL); +#ifdef WITH_G2D + tk_g2d_init(); +#endif /*WITH_G2D*/ + if (APP_CONSOLE == system_info()->app_type) { #if WITH_MAIN_LOOP_CONSOLE loop = (main_loop_t*)main_loop_console_init(); @@ -345,10 +349,6 @@ ret_t tk_init(wh_t w, wh_t h, app_type_t app_type, const char* app_name, const c tk_socket_init(); #endif /*WITH_SOCKET*/ -#ifdef WITH_G2D - tk_g2d_init(); -#endif /*WITH_G2D*/ - return RET_OK; } diff --git a/src/base/bitmap.c b/src/base/bitmap.c index 3888454cda..1bd3af07fc 100644 --- a/src/base/bitmap.c +++ b/src/base/bitmap.c @@ -146,8 +146,8 @@ static ret_t bitmap_platform_create(bitmap_t* bitmap) { return_value_if_fail(format == BITMAP_FMT_RGBA8888, RET_BAD_PARAMS); data = bitmap_lock_buffer_for_write(bitmap); - id = EM_ASM_INT( - { return VGCanvas.createMutableImage($0, $1, $2, $3, $4); }, data, w, h, line_length, format); + id = EM_ASM_INT({ return VGCanvas.createMutableImage($0, $1, $2, $3, $4); }, data, w, h, + line_length, format); bitmap->specific = tk_pointer_from_int(id); bitmap->specific_destroy = bitmap_web_destroy; bitmap_unlock_buffer(bitmap); @@ -161,7 +161,7 @@ static ret_t bitmap_platform_create(bitmap_t* bitmap) { #endif /*AWTK_WEB*/ bitmap_t* bitmap_create_ex(uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format) { - bitmap_t* bitmap = TKMEM_ZALLOC(bitmap_t); + bitmap_t* bitmap = bitmap_create(); return_value_if_fail(bitmap != NULL, NULL); bitmap_init_ex(bitmap, w, h, line_length, format, NULL); @@ -170,6 +170,22 @@ bitmap_t* bitmap_create_ex(uint32_t w, uint32_t h, uint32_t line_length, bitmap_ return bitmap; } +bitmap_t* bitmap_create_ex3(uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format, + uint8_t* data, uint8_t* physical_data_addr, bool_t should_free_data) { + bitmap_t* bitmap = bitmap_create(); + return_value_if_fail(bitmap != NULL, NULL); + + bitmap_init_ex2(bitmap, w, h, line_length, format, data, physical_data_addr, should_free_data); + bitmap->should_free_handle = TRUE; + + return bitmap; +} + +bitmap_t* bitmap_create_ex2(uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format, + uint8_t* data, bool_t should_free_data) { + return bitmap_create_ex3(w, h, line_length, format, data, NULL, should_free_data); +} + ret_t bitmap_get_pixel(bitmap_t* bitmap, uint32_t x, uint32_t y, rgba_t* rgba) { ret_t ret = RET_OK; const uint8_t* data = NULL; @@ -588,7 +604,16 @@ ret_t bitmap_init_from_rgba(bitmap_t* bitmap, uint32_t w, uint32_t h, bitmap_for } ret_t bitmap_init(bitmap_t* bitmap, uint32_t w, uint32_t h, bitmap_format_t format, uint8_t* data) { - uint32_t line_length = 0; + return bitmap_init_ex(bitmap, w, h, 0, format, data); +} + +ret_t bitmap_init_ex2(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length, + bitmap_format_t format, uint8_t* data, uint8_t* physical_data_addr, + bool_t should_free_data) { + uint32_t bpp = bitmap_get_bpp_of_format(format); + return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS); + + bitmap->should_free_data = should_free_data; if (bitmap->format == BITMAP_FMT_MONO) { line_length = TK_BITMAP_MONO_LINE_LENGTH(w); } else { @@ -596,14 +621,6 @@ ret_t bitmap_init(bitmap_t* bitmap, uint32_t w, uint32_t h, bitmap_format_t form line_length = tk_max(w * bpp, line_length); } - return bitmap_init_ex(bitmap, w, h, line_length, format, data); -} - -ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length, - bitmap_format_t format, uint8_t* data) { - uint32_t bpp = bitmap_get_bpp_of_format(format); - return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS); - memset(bitmap, 0x00, sizeof(bitmap_t)); bitmap->w = w; @@ -617,7 +634,7 @@ ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_len if (data == NULL) { bitmap_alloc_data(bitmap); } else { - bitmap->buffer = GRAPHIC_BUFFER_CREATE_WITH_DATA(data, w, h, format); + bitmap->buffer = GRAPHIC_BUFFER_CREATE_WITH_DATA_EX(data, physical_data_addr, w, h, line_length, format); bitmap->should_free_data = TRUE; } @@ -628,6 +645,11 @@ ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_len return bitmap->buffer != NULL ? RET_OK : RET_OOM; } +ret_t bitmap_init_ex(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length, + bitmap_format_t format, uint8_t* data) { + return bitmap_init_ex2(bitmap, w, h, line_length, format, data, NULL, FALSE); +} + ret_t bitmap_set_line_length(bitmap_t* bitmap, uint32_t line_length) { return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS); diff --git a/src/base/bitmap.h b/src/base/bitmap.h index 5b85bb9390..d370e8d8df 100644 --- a/src/base/bitmap.h +++ b/src/base/bitmap.h @@ -139,6 +139,55 @@ bitmap_t* bitmap_create(void); */ bitmap_t* bitmap_create_ex(uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format); +/** + * @method bitmap_create_ex2 + * 创建图片对象。 + * @annotation ["constructor", "scriptable", "gc"] + * @param {uint32_t} w 宽度。 + * @param {uint32_t} h 高度。 + * @param {uint32_t} line_length line_length。 + * @param {bitmap_format_t} format 格式。 + * @param {uint8_t*} data 图像数据。 + * @param {bool_t} should_free_data 是否释放数据。 + * + * @return {bitmap_t*} 返回bitmap对象。 + */ +bitmap_t* bitmap_create_ex2(uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format, + uint8_t* data, bool_t should_free_data); + +/** + * @method bitmap_create_ex3 + * 创建图片对象。 + * @annotation ["constructor", "scriptable", "gc"] + * @param {uint32_t} w 宽度。 + * @param {uint32_t} h 高度。 + * @param {uint32_t} line_length line_length。 + * @param {bitmap_format_t} format 格式。 + * @param {uint8_t*} data 图像数据。 + * @param {uint8_t*} physical_data_addr 物理地址(部分硬件加速需要)。 + * @param {bool_t} should_free_data 是否释放数据。 + * + * @return {bitmap_t*} 返回bitmap对象。 + */ +bitmap_t* bitmap_create_ex3(uint32_t w, uint32_t h, uint32_t line_length, bitmap_format_t format, + uint8_t* data, uint8_t* physical_data_addr, bool_t should_free_data); +/** + * @method bitmap_init_ex2 + * 创建图片对象。 + * @annotation ["constructor", "scriptable", "gc"] + * @param {uint32_t} w 宽度。 + * @param {uint32_t} h 高度。 + * @param {uint32_t} line_length line_length。 + * @param {bitmap_format_t} format 格式。 + * @param {uint8_t*} data 图像数据。 + * @param {uint8_t*} physical_data_addr 物理地址(部分硬件加速需要)。 + * @param {bool_t} should_free_data 是否释放数据。 + * + * @return {bitmap_t*} 返回bitmap对象。 + */ +ret_t bitmap_init_ex2(bitmap_t* bitmap, uint32_t w, uint32_t h, uint32_t line_length, + bitmap_format_t format, uint8_t* data, uint8_t* physical_data_addr, + bool_t should_free_data); /** * @method bitmap_get_bpp * 获取图片一个像素占用的字节数。 diff --git a/src/base/canvas_offline.inc b/src/base/canvas_offline.inc index 3e48372d02..dda70b0947 100644 --- a/src/base/canvas_offline.inc +++ b/src/base/canvas_offline.inc @@ -198,19 +198,19 @@ canvas_t* canvas_offline_create(uint32_t w, uint32_t h, bitmap_format_t format) buff = bitmap_lock_buffer_for_write(bitmap); return_value_if_fail(buff != NULL, NULL); if (bitmap->format == BITMAP_FMT_RGBA8888) { - lcd = lcd_mem_rgba8888_create_single_fb(bitmap->w, bitmap->h, buff); + lcd = lcd_mem_rgba8888_create_single_fb_bitmap(bitmap); } else if (bitmap->format == BITMAP_FMT_BGRA8888) { - lcd = lcd_mem_bgra8888_create_single_fb(bitmap->w, bitmap->h, buff); + lcd = lcd_mem_bgra8888_create_single_fb_bitmap(bitmap); } else if (bitmap->format == BITMAP_FMT_BGR565) { - lcd = lcd_mem_bgr565_create_single_fb(bitmap->w, bitmap->h, buff); + lcd = lcd_mem_bgr565_create_single_fb_bitmap(bitmap); } else if (bitmap->format == BITMAP_FMT_RGB565) { - lcd = lcd_mem_rgb565_create_single_fb(bitmap->w, bitmap->h, buff); + lcd = lcd_mem_rgb565_create_single_fb_bitmap(bitmap); } #ifdef WITH_LCD_RGB888 else if (bitmap->format == BITMAP_FMT_RGB888) { - lcd = lcd_mem_rgb888_create_single_fb(bitmap->w, bitmap->h, buff); + lcd = lcd_mem_rgb888_create_single_fb_bitmap(bitmap); } else if (bitmap->format == BITMAP_FMT_BGR888) { - lcd = lcd_mem_bgr888_create_single_fb(bitmap->w, bitmap->h, buff); + lcd = lcd_mem_bgr888_create_single_fb_bitmap(bitmap); } #endif /*WITH_LCD_RGB888*/ diff --git a/src/base/graphic_buffer.h b/src/base/graphic_buffer.h index 2071caf26f..796c4b5b77 100644 --- a/src/base/graphic_buffer.h +++ b/src/base/graphic_buffer.h @@ -103,6 +103,24 @@ ret_t graphic_buffer_create_for_bitmap(bitmap_t* bitmap); graphic_buffer_t* graphic_buffer_create_with_data(const uint8_t* data, uint32_t w, uint32_t h, bitmap_format_t format); +/** + * @method graphic_buffer_create_with_data_ex + * 创建缓冲区。 + * + * > 为了兼容raw图像。 + * @param {const uint8_t*} virtual_data 数据虚拟地址。 + * @param {const uint8_t*} physical_data 数据物理地址。 + * @param {uint32_t} w 宽度。 + * @param {uint32_t} h 宽度。 + * @param {uint32_t} line_length 每行宽度(字节数) + * @param {bitmap_format_t} format 格式。 + * + * @return {graphic_buffer_t*} 返回缓存区。 + */ +graphic_buffer_t* graphic_buffer_create_with_data_ex(const uint8_t* virtual_data, + const uint8_t* physical_data, uint32_t w, + uint32_t h, uint32_t line_length, + bitmap_format_t format); /** * @method graphic_buffer_lock_for_read * 为读取数据而锁定缓冲区。 @@ -198,6 +216,8 @@ ret_t graphic_buffer_destroy(graphic_buffer_t* buffer); #define GRAPHIC_BUFFER_CREATE_WITH_DATA(data, w, h, format) \ graphic_buffer_create_with_data(data, w, h, format) +#define GRAPHIC_BUFFER_CREATE_WITH_DATA_EX(data, physical_data_addr, w, h, line_length, format) \ + graphic_buffer_create_with_data_ex(data, physical_data_addr, w, h, line_length, format) END_C_DECLS #endif /*TK_GRAPHIC_BUFFER_H*/ diff --git a/src/blend/image_g2d.h b/src/blend/image_g2d.h index 17e3c068dc..77a145405f 100644 --- a/src/blend/image_g2d.h +++ b/src/blend/image_g2d.h @@ -122,9 +122,10 @@ ret_t image_rotate_ex(bitmap_t* dst, bitmap_t* src, const rect_t* src_r, xy_t dx ret_t image_rotate_blend(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r, const rectf_t* src_r, uint8_t global_alpha, lcd_orientation_t o); -ret_t image_g2d_benchmark(void); #endif +ret_t image_g2d_benchmark(void); + END_C_DECLS #endif /*TK_IMAGE_G2D_H*/ diff --git a/src/blend/soft_g2d.c b/src/blend/soft_g2d.c index 7dcfc11028..ca7f470fcc 100644 --- a/src/blend/soft_g2d.c +++ b/src/blend/soft_g2d.c @@ -185,8 +185,10 @@ ret_t soft_fill_rect(bitmap_t* dst, const rect_t* dst_r, color_t c) { return fill_abgr8888_rect(dst, dst_r, c); } #endif /*LCD_BGR565_LITE*/ - default: + default: { + log_debug("not support format: w=%u h=%u format=%u\n", dst->w, dst->h, dst->format); break; + } } assert(!"not supported format"); @@ -219,8 +221,10 @@ ret_t soft_rotate_image(bitmap_t* dst, bitmap_t* src, const rect_t* src_r, lcd_o return rotate_bgra8888_image(dst, src, src_r, o); } #endif /*LCD_BGR565_LITE*/ - default: + default: { + log_debug("not support format: w=%u h=%u format=%u\n", dst->w, dst->h, dst->format); break; + } } assert(!"not supported format"); diff --git a/src/graphic_buffer/graphic_buffer_default.c b/src/graphic_buffer/graphic_buffer_default.c index 72c8b9a380..eaa49ac078 100644 --- a/src/graphic_buffer/graphic_buffer_default.c +++ b/src/graphic_buffer/graphic_buffer_default.c @@ -178,6 +178,13 @@ graphic_buffer_t* graphic_buffer_create_with_data(const uint8_t* data, uint32_t return GRAPHIC_BUFFER(buffer); } +graphic_buffer_t* graphic_buffer_create_with_data_ex(const uint8_t* virtual_data, + const uint8_t* physical_data, uint32_t w, + uint32_t h, uint32_t line_length, + bitmap_format_t format) { + return graphic_buffer_create_with_data(virtual_data, w, h, format); +} + ret_t graphic_buffer_create_for_bitmap(bitmap_t* bitmap) { uint32_t line_length = bitmap_get_line_length(bitmap); return_value_if_fail(bitmap != NULL && bitmap->buffer == NULL, RET_BAD_PARAMS); diff --git a/src/lcd/lcd_mem.h b/src/lcd/lcd_mem.h index 32970945a9..51f831c9b1 100644 --- a/src/lcd/lcd_mem.h +++ b/src/lcd/lcd_mem.h @@ -40,11 +40,9 @@ typedef struct _lcd_mem_t { uint32_t online_line_length; uint32_t line_length; bitmap_format_t format; - bool_t own_offline_fb; - - graphic_buffer_t* online_gb; - graphic_buffer_t* offline_gb; + bitmap_t* fb_bitmaps[3]; + bool_t should_destroy_fb_bitmaps; lcd_fb_dirty_rects_t fb_dirty_rects_list; /*VBI: vertical blank interrupt。用于2fb等待当前显示完成,以便把下一帧的数据从offline fb拷贝到online fb,从而避免因为同时访问online fb数据造成闪烁。*/ @@ -84,6 +82,7 @@ static inline ret_t lcd_mem_set_wait_vbi(lcd_t* lcd, lcd_mem_wait_vbi_t wait_vbi * @return {ret_t} 返回RET_OK表示成功,否则表示失败。 */ static inline ret_t lcd_mem_deinit(lcd_mem_t* mem) { + uint32_t i = 0; return_value_if_fail(mem != NULL && mem->base.begin_frame != NULL, RET_BAD_PARAMS); lcd_fb_dirty_rects_deinit(&(mem->fb_dirty_rects_list)); @@ -92,13 +91,13 @@ static inline ret_t lcd_mem_deinit(lcd_mem_t* mem) { mem->vgcanvas = NULL; } - if (mem->own_offline_fb) { - TKMEM_FREE(mem->offline_fb); + if (mem->should_destroy_fb_bitmaps) { + for (i = 0; i < ARRAY_SIZE(mem->fb_bitmaps); i++) { + bitmap_destroy(mem->fb_bitmaps[i]); + mem->fb_bitmaps[i] = NULL; + } } - graphic_buffer_destroy(mem->online_gb); - graphic_buffer_destroy(mem->offline_gb); - return RET_OK; } @@ -186,6 +185,58 @@ static inline uint8_t* lcd_mem_get_next_fb(lcd_mem_t* lcd) { return lcd->next_fb; } +static inline ret_t lcd_mem_set_single_fb_bitmap(lcd_t* lcd, bitmap_t* offline_fb_bitmap) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + return_value_if_fail(mem != NULL, RET_BAD_PARAMS); + return_value_if_fail(offline_fb_bitmap != NULL, RET_BAD_PARAMS); + + lcd_mem_set_offline_fb(mem, bitmap_lock_buffer_for_write(offline_fb_bitmap)); + mem->fb_bitmaps[0] = offline_fb_bitmap; + + return RET_OK; +} + +static inline ret_t lcd_mem_set_double_fb_bitmap(lcd_t* lcd, bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + return_value_if_fail(mem != NULL, RET_BAD_PARAMS); + return_value_if_fail(online_fb_bitmap != NULL && offline_fb_bitmap != NULL, RET_BAD_PARAMS); + + assert(online_fb_bitmap->w == offline_fb_bitmap->w); + assert(online_fb_bitmap->h == offline_fb_bitmap->h); + assert(online_fb_bitmap->format == offline_fb_bitmap->format); + + lcd_mem_set_online_fb(mem, bitmap_lock_buffer_for_write(online_fb_bitmap)); + lcd_mem_set_offline_fb(mem, bitmap_lock_buffer_for_write(offline_fb_bitmap)); + + mem->fb_bitmaps[0] = offline_fb_bitmap; + mem->fb_bitmaps[1] = online_fb_bitmap; + + return RET_OK; +} + +static inline ret_t lcd_mem_set_three_fb_bitmap(lcd_t* lcd, bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + lcd_mem_t* mem = (lcd_mem_t*)lcd; + return_value_if_fail(mem != NULL, RET_BAD_PARAMS); + return_value_if_fail(online_fb_bitmap != NULL && offline_fb_bitmap != NULL && next_fb_bitmap != NULL, RET_BAD_PARAMS); + + assert(online_fb_bitmap->w == next_fb_bitmap->w); + assert(online_fb_bitmap->h == next_fb_bitmap->h); + assert(online_fb_bitmap->w == offline_fb_bitmap->w); + assert(online_fb_bitmap->h == offline_fb_bitmap->h); + assert(online_fb_bitmap->format == offline_fb_bitmap->format); + + lcd_mem_set_next_fb(mem, bitmap_lock_buffer_for_write(next_fb_bitmap)); + lcd_mem_set_online_fb(mem, bitmap_lock_buffer_for_write(online_fb_bitmap)); + lcd_mem_set_offline_fb(mem, bitmap_lock_buffer_for_write(offline_fb_bitmap)); + + mem->fb_bitmaps[0] = offline_fb_bitmap; + mem->fb_bitmaps[1] = online_fb_bitmap; + mem->fb_bitmaps[2] = next_fb_bitmap; + + return RET_OK; +} + END_C_DECLS #endif /*TK_LCD_MEM_H*/ diff --git a/src/lcd/lcd_mem.inc b/src/lcd/lcd_mem.inc index db05533d6e..9b099e363f 100644 --- a/src/lcd/lcd_mem.inc +++ b/src/lcd/lcd_mem.inc @@ -56,18 +56,32 @@ static uint32_t lcd_get_physical_line_length(lcd_mem_t* mem) { return tk_max(lcd_get_physical_width((lcd_t*)mem) * bpp, mem->line_length); } +static bitmap_t* lcd_mem_find_fb_bitmap_by_buff(lcd_t* lcd, uint8_t* fbuff) { + uint32_t i = 0; + lcd_mem_t* mem = (lcd_mem_t*)lcd; + for (i = 0; i < ARRAY_SIZE(mem->fb_bitmaps); i++) { + bitmap_t* iter = mem->fb_bitmaps[i]; + if (iter != NULL) { + uint8_t* b = bitmap_lock_buffer_for_write(iter); + bitmap_unlock_buffer(iter); + if (b == fbuff) { + return iter; + } + } + } + assert(!"not found fb bitmap"); + return NULL; +} + static pixel_t* lcd_mem_init_drawing_fb(lcd_t* lcd, bitmap_t* fb) { lcd_mem_t* mem = (lcd_mem_t*)lcd; uint8_t* fbuff = mem->offline_fb; if (fb != NULL) { - memset(fb, 0x00, sizeof(bitmap_t)); + *fb = *lcd_mem_find_fb_bitmap_by_buff(lcd ,fbuff); - fb->format = mem->format; - fb->buffer = mem->offline_gb; fb->w = lcd_get_physical_width(lcd); fb->h = lcd_get_physical_height(lcd); - graphic_buffer_attach(mem->offline_gb, mem->offline_fb, fb->w, fb->h); bitmap_set_line_length(fb, lcd_get_physical_line_length(mem)); } @@ -95,12 +109,9 @@ static bitmap_t* lcd_mem_init_online_fb(lcd_t* lcd, bitmap_t* fb, lcd_orientatio } } - memset(fb, 0x00, sizeof(bitmap_t)); + *fb = *lcd_mem_find_fb_bitmap_by_buff(lcd, mem->online_fb); fb->w = w; fb->h = h; - fb->buffer = mem->online_gb; - fb->format = mem->format; - graphic_buffer_attach(mem->online_gb, mem->online_fb, w, h); bitmap_set_line_length(fb, tk_max(fb->w * bpp, mem->online_line_length)); return fb; @@ -205,7 +216,7 @@ static ret_t lcd_mem_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) { color_t c = lcd->stroke_color; uint8_t a = (c.rgba.a * lcd->global_alpha) / 0xff; uint32_t line_length = lcd_get_physical_line_length((lcd_mem_t*)lcd); - uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL); + uint8_t* fbuff = (uint8_t*)lcd_mem_get_offline_fb((lcd_mem_t*)lcd); #ifdef WITH_FAST_LCD_PORTRAIT if (system_info()->flags & SYSTEM_INFO_FLAG_FAST_LCD_PORTRAIT) { @@ -259,7 +270,7 @@ static ret_t lcd_mem_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) { pixel_t pixel = color_to_pixel(c); uint8_t a = (c.rgba.a * lcd->global_alpha) / 0xff; uint32_t line_length = lcd_get_physical_line_length((lcd_mem_t*)lcd); - uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL); + uint8_t* fbuff = (uint8_t*)lcd_mem_get_offline_fb((lcd_mem_t*)lcd); for (i = 0; i < nr; i++) { point_t* point = points + i; @@ -287,7 +298,7 @@ static ret_t lcd_mem_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) { static color_t lcd_mem_get_point_color(lcd_t* lcd, xy_t x, xy_t y) { color_t c; uint32_t line_length = lcd_get_physical_line_length((lcd_mem_t*)lcd); - uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL); + uint8_t* fbuff = (uint8_t*)lcd_mem_get_offline_fb((lcd_mem_t*)lcd); #ifdef WITH_FAST_LCD_PORTRAIT if (system_info()->flags & SYSTEM_INFO_FLAG_FAST_LCD_PORTRAIT) { lcd_orientation_point_rotate_by_anticlockwise(&x, &y, system_info()->lcd_orientation, lcd_get_width(lcd), lcd_get_height(lcd)); @@ -317,7 +328,7 @@ static ret_t lcd_mem_draw_glyph4(lcd_t* lcd, glyph_t* glyph, const rect_t* src, uint8_t global_alpha = lcd->global_alpha; uint8_t color_alpha = (color.rgba.a * global_alpha) >> 8; uint32_t line_length = lcd_get_physical_line_length((lcd_mem_t*)lcd); - uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL); + uint8_t* fbuff = (uint8_t*)lcd_mem_get_offline_fb((lcd_mem_t*)lcd); const uint8_t* src_p = glyph->data + pitch * sy + sx / 2; wh_t dst_offset = line_length; pixel_t pixel = color_to_pixel(color); @@ -390,7 +401,7 @@ static ret_t lcd_mem_draw_glyph8(lcd_t* lcd, glyph_t* glyph, const rect_t* src, uint8_t global_alpha = lcd->global_alpha; uint8_t color_alpha = (color.rgba.a * global_alpha) >> 8; uint32_t line_length = lcd_get_physical_line_length((lcd_mem_t*)lcd); - uint8_t* fbuff = (uint8_t*)lcd_mem_init_drawing_fb(lcd, NULL); + uint8_t* fbuff = (uint8_t*)lcd_mem_get_offline_fb((lcd_mem_t*)lcd); const uint8_t* src_p = glyph->data + glyph->w * src->y + src->x; wh_t dst_offset = line_length; pixel_t pixel = color_to_pixel(color); @@ -546,7 +557,7 @@ static vgcanvas_t* lcd_mem_get_vgcanvas(lcd_t* lcd) { uint32_t w = lcd_get_physical_width(lcd); uint32_t h = lcd_get_physical_height(lcd); uint32_t line_length = lcd_get_physical_line_length(mem); - uint32_t* fbdata = (uint32_t*)lcd_mem_init_drawing_fb(lcd, NULL); + uint32_t* fbdata = (uint32_t*)lcd_mem_get_offline_fb((lcd_mem_t*)lcd); if (mem->vgcanvas == NULL) { mem->vgcanvas = vgcanvas_create(w, h, line_length, format, fbdata); @@ -742,16 +753,12 @@ static lcd_t* lcd_mem_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) { lcd_fb_dirty_rects_init(&(lcd->fb_dirty_rects_list), w, h); if (alloc) { - uint8_t* offline_fb = (uint8_t*)TKMEM_ALLOC(w * h * (uint32_t)sizeof(pixel_t)); - ret_t ret = lcd_mem_set_offline_fb(lcd, offline_fb); - if (ret != RET_OK && offline_fb != NULL) { - TKMEM_FREE(offline_fb); - } - return_value_if_fail(lcd->offline_fb != NULL && ret == RET_OK, NULL); + lcd->should_destroy_fb_bitmaps = TRUE; + lcd->fb_bitmaps[0] = bitmap_create_ex(w, h, bpp * w, LCD_FORMAT); + lcd->offline_fb = bitmap_lock_buffer_for_write(lcd->fb_bitmaps[0]); + lcd_mem_set_offline_fb(lcd, lcd->offline_fb); } - lcd->own_offline_fb = alloc; - base->begin_frame = lcd_mem_begin_frame; base->draw_vline = lcd_mem_draw_vline; base->draw_hline = lcd_mem_draw_hline; @@ -789,8 +796,6 @@ static lcd_t* lcd_mem_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc) { lcd->format = LCD_FORMAT; lcd->line_length = w * bpp; lcd->online_line_length = lcd->line_length; - lcd->online_gb = graphic_buffer_create_with_data(NULL, w, h, LCD_FORMAT); - lcd->offline_gb = graphic_buffer_create_with_data(NULL, w, h, LCD_FORMAT); system_info_set_lcd_w(info, base->w); system_info_set_lcd_h(info, base->h); @@ -806,12 +811,29 @@ static lcd_t* lcd_mem_create(wh_t w, wh_t h, bool_t alloc) { return lcd_mem_init(lcd, w, h, alloc); } -static lcd_t* lcd_mem_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { +static lcd_t* lcd_mem_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { lcd_t* lcd = lcd_mem_create(w, h, FALSE); lcd_mem_t* mem = (lcd_mem_t*)lcd; + lcd_mem_set_offline_fb(mem, fbuff); + mem->online_fb = NULL; + lcd->flush = NULL; + + mem->should_destroy_fb_bitmaps = TRUE; + mem->fb_bitmaps[0] = bitmap_create_ex2(w, h, 0, LCD_FORMAT, fbuff, FALSE); + + return lcd; +} +static lcd_t* lcd_mem_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { + lcd_t* lcd = lcd_mem_create(w, h, FALSE); + lcd_mem_t* mem = (lcd_mem_t*)lcd; + lcd_mem_set_online_fb(mem, online_fb); lcd_mem_set_offline_fb(mem, offline_fb); + + mem->should_destroy_fb_bitmaps = TRUE; + mem->fb_bitmaps[0] = bitmap_create_ex2(w, h, 0, LCD_FORMAT, online_fb, FALSE); + mem->fb_bitmaps[1] = bitmap_create_ex2(w, h, 0, LCD_FORMAT, offline_fb, FALSE); return lcd; } @@ -825,16 +847,53 @@ static lcd_t* lcd_mem_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ lcd_mem_set_online_fb(mem, online_fb); lcd_mem_set_offline_fb(mem, offline_fb); + mem->should_destroy_fb_bitmaps = TRUE; + mem->fb_bitmaps[0] = bitmap_create_ex2(w, h, 0, LCD_FORMAT, online_fb, FALSE); + mem->fb_bitmaps[1] = bitmap_create_ex2(w, h, 0, LCD_FORMAT, offline_fb, FALSE); + mem->fb_bitmaps[2] = bitmap_create_ex2(w, h, 0, LCD_FORMAT, next_fb, FALSE); + return lcd; } -static lcd_t* lcd_mem_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { - lcd_t* lcd = lcd_mem_create(w, h, FALSE); - lcd_mem_t* mem = (lcd_mem_t*)lcd; +static lcd_t* lcd_mem_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + lcd_t* lcd = NULL; + return_value_if_fail(offline_fb_bitmap != NULL, NULL); + assert(offline_fb_bitmap->format == LCD_FORMAT); + lcd = lcd_mem_create(offline_fb_bitmap->w, offline_fb_bitmap->h, FALSE); + return_value_if_fail(lcd != NULL, NULL); - lcd_mem_set_offline_fb(mem, fbuff); - mem->online_fb = NULL; + lcd_mem_set_single_fb_bitmap(lcd, offline_fb_bitmap); lcd->flush = NULL; + log_debug("lcd_mem_create_single_fb_bitmap: %u %u %u\n", offline_fb_bitmap->w, offline_fb_bitmap->h, offline_fb_bitmap->format); return lcd; } + +static lcd_t* lcd_mem_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + lcd_t* lcd = NULL; + return_value_if_fail(online_fb_bitmap != NULL && offline_fb_bitmap != NULL, NULL); + assert(online_fb_bitmap->format == LCD_FORMAT); + lcd = lcd_mem_create(offline_fb_bitmap->w, offline_fb_bitmap->h, FALSE); + return_value_if_fail(lcd != NULL, NULL); + + lcd_mem_set_double_fb_bitmap(lcd, online_fb_bitmap, offline_fb_bitmap); + log_debug("lcd_mem_create_double_fb_bitmap: %u %u %u\n", offline_fb_bitmap->w, offline_fb_bitmap->h, offline_fb_bitmap->format); + + return lcd; +} + +static lcd_t* lcd_mem_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + lcd_t* lcd = NULL; + return_value_if_fail(online_fb_bitmap != NULL && offline_fb_bitmap != NULL && next_fb_bitmap != NULL, NULL); + assert(next_fb_bitmap->format == LCD_FORMAT); + assert(online_fb_bitmap->format == LCD_FORMAT); + lcd = lcd_mem_create(offline_fb_bitmap->w, offline_fb_bitmap->h, FALSE); + return_value_if_fail(lcd != NULL, NULL); + + lcd_mem_set_three_fb_bitmap(lcd, online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); + log_debug("lcd_mem_create_three_fb_bitmap: %u %u %u\n", offline_fb_bitmap->w, offline_fb_bitmap->h, offline_fb_bitmap->format); + + return lcd; +} + diff --git a/src/lcd/lcd_mem_bgr565.c b/src/lcd/lcd_mem_bgr565.c index 16fbfb9f8d..31c6487b28 100644 --- a/src/lcd/lcd_mem_bgr565.c +++ b/src/lcd/lcd_mem_bgr565.c @@ -42,8 +42,8 @@ lcd_t* lcd_mem_bgr565_create(wh_t w, wh_t h, bool_t alloc) { return lcd_mem_create(w, h, alloc); } -lcd_t* lcd_mem_bgr565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { - return lcd_mem_create_single_fb(w, h, fbuff); +lcd_t* lcd_mem_bgr565_create_single_fb(wh_t w, wh_t h, uint8_t* offline_fb) { + return lcd_mem_create_single_fb(w, h, offline_fb); } lcd_t* lcd_mem_bgr565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { @@ -54,3 +54,16 @@ lcd_t* lcd_mem_bgr565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ uint8_t* next_fb) { return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb); } + +lcd_t* lcd_mem_bgr565_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_single_fb_bitmap(offline_fb_bitmap); +} + +lcd_t* lcd_mem_bgr565_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_double_fb_bitmap(online_fb_bitmap, offline_fb_bitmap); +} + +lcd_t* lcd_mem_bgr565_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + return lcd_mem_create_three_fb_bitmap(online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); +} diff --git a/src/lcd/lcd_mem_bgr565.h b/src/lcd/lcd_mem_bgr565.h index e3cb7df6ea..4bf0f2f7f5 100644 --- a/src/lcd/lcd_mem_bgr565.h +++ b/src/lcd/lcd_mem_bgr565.h @@ -52,11 +52,11 @@ lcd_t* lcd_mem_bgr565_create(wh_t w, wh_t h, bool_t alloc); * * @param {wh_t} w 宽度。 * @param {wh_t} h 高度。 - * @param {uint8_t*} fbuff 帧率缓冲区。 + * @param {uint8_t*} offline_fb 帧率缓冲区。 * * @return {lcd_t*} 返回lcd对象。 */ -lcd_t* lcd_mem_bgr565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff); +lcd_t* lcd_mem_bgr565_create_single_fb(wh_t w, wh_t h, uint8_t* offline_fb); /** * @method lcd_mem_bgr565_create_double_fb @@ -102,6 +102,42 @@ lcd_t* lcd_mem_bgr565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ */ lcd_t* lcd_mem_bgr565_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc); +/** + * @method lcd_mem_bgr565_create_single_fb_bitmap + * + * 创建single fb lcd对象。 + * + * @param {bitmap_t*} offline_fb_bitmap 帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgr565_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_bgr565_create_double_fb_bitmap + * + * 创建double fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgr565_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_bgr565_create_three_fb_bitmap + * + * 创建three fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * @param {bitmap_t*} next_fb_bitmap 待显示的帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgr565_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap); END_C_DECLS #endif /*TK_LCD_MEM_BGR565_H*/ diff --git a/src/lcd/lcd_mem_bgr888.c b/src/lcd/lcd_mem_bgr888.c index 4e36689bb0..c33fccbf95 100644 --- a/src/lcd/lcd_mem_bgr888.c +++ b/src/lcd/lcd_mem_bgr888.c @@ -54,3 +54,16 @@ lcd_t* lcd_mem_bgr888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ uint8_t* next_fb) { return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb); } + +lcd_t* lcd_mem_bgr888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_single_fb_bitmap(offline_fb_bitmap); +} + +lcd_t* lcd_mem_bgr888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_double_fb_bitmap(online_fb_bitmap, offline_fb_bitmap); +} + +lcd_t* lcd_mem_bgr888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + return lcd_mem_create_three_fb_bitmap(online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); +} diff --git a/src/lcd/lcd_mem_bgr888.h b/src/lcd/lcd_mem_bgr888.h index 7486178503..2a61a8f9dd 100644 --- a/src/lcd/lcd_mem_bgr888.h +++ b/src/lcd/lcd_mem_bgr888.h @@ -102,6 +102,42 @@ lcd_t* lcd_mem_bgr888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ */ lcd_t* lcd_mem_bgr888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc); +/** + * @method lcd_mem_bgr888_create_single_fb_bitmap + * + * 创建single fb lcd对象。 + * + * @param {bitmap_t*} offline_fb_bitmap 帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgr888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_bgr888_create_double_fb_bitmap + * + * 创建double fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgr888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_bgr888_create_three_fb_bitmap + * + * 创建three fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * @param {bitmap_t*} next_fb_bitmap 待显示的帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgr888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap); END_C_DECLS #endif /*TK_LCD_MEM_BGR888_H*/ diff --git a/src/lcd/lcd_mem_bgra8888.c b/src/lcd/lcd_mem_bgra8888.c index 748fbcb34d..0d4e56f148 100644 --- a/src/lcd/lcd_mem_bgra8888.c +++ b/src/lcd/lcd_mem_bgra8888.c @@ -42,8 +42,8 @@ lcd_t* lcd_mem_bgra8888_create(wh_t w, wh_t h, bool_t alloc) { return lcd_mem_create(w, h, alloc); } -lcd_t* lcd_mem_bgra8888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { - return lcd_mem_create_single_fb(w, h, fbuff); +lcd_t* lcd_mem_bgra8888_create_single_fb(wh_t w, wh_t h, uint8_t* offline_fb) { + return lcd_mem_create_single_fb(w, h, offline_fb); } lcd_t* lcd_mem_bgra8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { @@ -54,3 +54,16 @@ lcd_t* lcd_mem_bgra8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint uint8_t* next_fb) { return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb); } + +lcd_t* lcd_mem_bgra8888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_single_fb_bitmap(offline_fb_bitmap); +} + +lcd_t* lcd_mem_bgra8888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_double_fb_bitmap(online_fb_bitmap, offline_fb_bitmap); +} + +lcd_t* lcd_mem_bgra8888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + return lcd_mem_create_three_fb_bitmap(online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); +} diff --git a/src/lcd/lcd_mem_bgra8888.h b/src/lcd/lcd_mem_bgra8888.h index 817a0d8550..d73831817d 100644 --- a/src/lcd/lcd_mem_bgra8888.h +++ b/src/lcd/lcd_mem_bgra8888.h @@ -102,6 +102,43 @@ lcd_t* lcd_mem_bgra8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint */ lcd_t* lcd_mem_bgra8888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc); + +/** + * @method lcd_mem_bgra8888_create_single_fb_bitmap + * + * 创建single fb lcd对象。 + * + * @param {bitmap_t*} offline_fb_bitmap 帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgra8888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_bgra8888_create_double_fb_bitmap + * + * 创建double fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgra8888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_bgra8888_create_three_fb_bitmap + * + * 创建three fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * @param {bitmap_t*} next_fb_bitmap 待显示的帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_bgra8888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap); END_C_DECLS #endif /*TK_LCD_MEM_BGRA8888_H*/ diff --git a/src/lcd/lcd_mem_rgb565.c b/src/lcd/lcd_mem_rgb565.c index 59c936a42c..8af0648e59 100644 --- a/src/lcd/lcd_mem_rgb565.c +++ b/src/lcd/lcd_mem_rgb565.c @@ -42,8 +42,8 @@ lcd_t* lcd_mem_rgb565_create(wh_t w, wh_t h, bool_t alloc) { return lcd_mem_create(w, h, alloc); } -lcd_t* lcd_mem_rgb565_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { - return lcd_mem_create_single_fb(w, h, fbuff); +lcd_t* lcd_mem_rgb565_create_single_fb(wh_t w, wh_t h, uint8_t* offline_fb) { + return lcd_mem_create_single_fb(w, h, offline_fb); } lcd_t* lcd_mem_rgb565_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { @@ -54,3 +54,16 @@ lcd_t* lcd_mem_rgb565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ uint8_t* next_fb) { return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb); } + +lcd_t* lcd_mem_rgb565_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_single_fb_bitmap(offline_fb_bitmap); +} + +lcd_t* lcd_mem_rgb565_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_double_fb_bitmap(online_fb_bitmap, offline_fb_bitmap); +} + +lcd_t* lcd_mem_rgb565_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + return lcd_mem_create_three_fb_bitmap(online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); +} diff --git a/src/lcd/lcd_mem_rgb565.h b/src/lcd/lcd_mem_rgb565.h index 16e01da3d0..69b395e6bc 100644 --- a/src/lcd/lcd_mem_rgb565.h +++ b/src/lcd/lcd_mem_rgb565.h @@ -102,6 +102,42 @@ lcd_t* lcd_mem_rgb565_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ */ lcd_t* lcd_mem_rgb565_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc); +/** + * @method lcd_mem_rgb565_create_single_fb_bitmap + * + * 创建single fb lcd对象。 + * + * @param {bitmap_t*} offline_fb_bitmap 帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgb565_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_rgb565_create_double_fb_bitmap + * + * 创建double fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgb565_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_rgb565_create_three_fb_bitmap + * + * 创建three fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * @param {bitmap_t*} next_fb_bitmap 待显示的帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgb565_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap); END_C_DECLS #endif /*TK_LCD_MEM_RGB565_H*/ diff --git a/src/lcd/lcd_mem_rgb888.c b/src/lcd/lcd_mem_rgb888.c index 41a93a1d98..e9b1c63dd4 100644 --- a/src/lcd/lcd_mem_rgb888.c +++ b/src/lcd/lcd_mem_rgb888.c @@ -42,8 +42,8 @@ lcd_t* lcd_mem_rgb888_create(wh_t w, wh_t h, bool_t alloc) { return lcd_mem_create(w, h, alloc); } -lcd_t* lcd_mem_rgb888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { - return lcd_mem_create_single_fb(w, h, fbuff); +lcd_t* lcd_mem_rgb888_create_single_fb(wh_t w, wh_t h, uint8_t* offline_fb) { + return lcd_mem_create_single_fb(w, h, offline_fb); } lcd_t* lcd_mem_rgb888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { @@ -54,3 +54,16 @@ lcd_t* lcd_mem_rgb888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ uint8_t* next_fb) { return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb); } + +lcd_t* lcd_mem_rgb888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_single_fb_bitmap(offline_fb_bitmap); +} + +lcd_t* lcd_mem_rgb888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_double_fb_bitmap(online_fb_bitmap, offline_fb_bitmap); +} + +lcd_t* lcd_mem_rgb888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + return lcd_mem_create_three_fb_bitmap(online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); +} diff --git a/src/lcd/lcd_mem_rgb888.h b/src/lcd/lcd_mem_rgb888.h index 8b608fe1ed..47caf22018 100644 --- a/src/lcd/lcd_mem_rgb888.h +++ b/src/lcd/lcd_mem_rgb888.h @@ -102,6 +102,43 @@ lcd_t* lcd_mem_rgb888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_ */ lcd_t* lcd_mem_rgb888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc); + +/** + * @method lcd_mem_rgb888_create_single_fb_bitmap + * + * 创建single fb lcd对象。 + * + * @param {bitmap_t*} offline_fb_bitmap 帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgb888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_rgb888_create_double_fb_bitmap + * + * 创建double fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgb888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_rgb888_create_three_fb_bitmap + * + * 创建three fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * @param {bitmap_t*} next_fb_bitmap 待显示的帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgb888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap); END_C_DECLS #endif /*TK_LCD_MEM_RGB888_H*/ diff --git a/src/lcd/lcd_mem_rgba8888.c b/src/lcd/lcd_mem_rgba8888.c index d851706f9a..378465a0c2 100644 --- a/src/lcd/lcd_mem_rgba8888.c +++ b/src/lcd/lcd_mem_rgba8888.c @@ -42,8 +42,8 @@ lcd_t* lcd_mem_rgba8888_create(wh_t w, wh_t h, bool_t alloc) { return lcd_mem_create(w, h, alloc); } -lcd_t* lcd_mem_rgba8888_create_single_fb(wh_t w, wh_t h, uint8_t* fbuff) { - return lcd_mem_create_single_fb(w, h, fbuff); +lcd_t* lcd_mem_rgba8888_create_single_fb(wh_t w, wh_t h, uint8_t* offline_fb) { + return lcd_mem_create_single_fb(w, h, offline_fb); } lcd_t* lcd_mem_rgba8888_create_double_fb(wh_t w, wh_t h, uint8_t* online_fb, uint8_t* offline_fb) { @@ -54,3 +54,16 @@ lcd_t* lcd_mem_rgba8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint uint8_t* next_fb) { return lcd_mem_create_three_fb(w, h, online_fb, offline_fb, next_fb); } + +lcd_t* lcd_mem_rgba8888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_single_fb_bitmap(offline_fb_bitmap); +} + +lcd_t* lcd_mem_rgba8888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap) { + return lcd_mem_create_double_fb_bitmap(online_fb_bitmap, offline_fb_bitmap); +} + +lcd_t* lcd_mem_rgba8888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap) { + return lcd_mem_create_three_fb_bitmap(online_fb_bitmap, offline_fb_bitmap, next_fb_bitmap); +} diff --git a/src/lcd/lcd_mem_rgba8888.h b/src/lcd/lcd_mem_rgba8888.h index 74452c841e..290bfa377f 100644 --- a/src/lcd/lcd_mem_rgba8888.h +++ b/src/lcd/lcd_mem_rgba8888.h @@ -102,6 +102,43 @@ lcd_t* lcd_mem_rgba8888_create_three_fb(wh_t w, wh_t h, uint8_t* online_fb, uint */ lcd_t* lcd_mem_rgba8888_init(lcd_mem_t* lcd, wh_t w, wh_t h, bool_t alloc); + +/** + * @method lcd_mem_rgba8888_create_single_fb_bitmap + * + * 创建single fb lcd对象。 + * + * @param {bitmap_t*} offline_fb_bitmap 帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgba8888_create_single_fb_bitmap(bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_rgba8888_create_double_fb_bitmap + * + * 创建double fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgba8888_create_double_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap); + +/** + * @method lcd_mem_rgba8888_create_three_fb_bitmap + * + * 创建three fb lcd对象。 + * + * @param {bitmap_t*} online_fb_bitmap 在线帧率缓冲区。 + * @param {bitmap_t*} offline_fb_bitmap 离线帧率缓冲区。 + * @param {bitmap_t*} next_fb_bitmap 待显示的帧率缓冲区。 + * + * @return {lcd_t*} 返回lcd对象。 + */ +lcd_t* lcd_mem_rgba8888_create_three_fb_bitmap(bitmap_t* online_fb_bitmap, bitmap_t* offline_fb_bitmap, + bitmap_t* next_fb_bitmap); END_C_DECLS #endif /*TK_LCD_MEM_RGBA8888_H*/