From 07854b1d0b6268b42fe54a054519fe8a4bad8112 Mon Sep 17 00:00:00 2001 From: liamHowatt Date: Tue, 15 Oct 2024 10:49:55 +0200 Subject: [PATCH] feat(NemaGFX): add TSC color formats --- docs/overview/renderers/nema_gfx.rst | 21 +++++++++++++++++++++ src/draw/dma2d/lv_draw_dma2d.c | 3 ++- src/draw/nema_gfx/lv_draw_nema_gfx_img.c | 4 +++- src/draw/nema_gfx/lv_draw_nema_gfx_utils.c | 10 ++++++++++ src/draw/nxp/pxp/lv_draw_pxp.c | 3 +++ src/draw/nxp/vglite/lv_draw_vglite.c | 4 ++++ src/draw/opengles/lv_draw_opengles.c | 5 +++++ src/draw/renesas/dave2d/lv_draw_dave2d.c | 5 +++++ src/draw/sdl/lv_draw_sdl.c | 5 +++++ src/draw/sw/lv_draw_sw.c | 4 ++++ src/misc/lv_color.h | 10 ++++++++++ 11 files changed, 72 insertions(+), 2 deletions(-) diff --git a/docs/overview/renderers/nema_gfx.rst b/docs/overview/renderers/nema_gfx.rst index 913c3cac3..9b53ab8f5 100644 --- a/docs/overview/renderers/nema_gfx.rst +++ b/docs/overview/renderers/nema_gfx.rst @@ -54,6 +54,27 @@ no locking is done). It may conflict with existing definitions if you have an existing Nema HAL implementation. You may simply be able to remove yours. +TSC Images +********** + +TSC (ThinkSillicon Compression) images can be drawn by this renderer. The +TSC 4/6/6A/12/12A color formats are part of :cpp:type:`lv_color_format_t`. +All other renderers will ignore images with these color formats. +Define an image descriptor variable with the corresponding +TSC color format and the GPU will be able to draw it directly. +Stride does not need to be specified because it will be computed by the +renderer. + +.. code-block:: c + + const lv_image_dsc_t img_demo_widgets_avatar_tsc6a = { + .header.cf = LV_COLOR_FORMAT_NEMA_TSC6A, + .header.w = 144, + .header.h = 144, + .data = img_demo_widgets_avatar_tsc6a_map, + .data_size = sizeof(img_demo_widgets_avatar_tsc6a_map), + }; + DMA2D ***** diff --git a/src/draw/dma2d/lv_draw_dma2d.c b/src/draw/dma2d/lv_draw_dma2d.c index f616d5b82..0c65aa519 100644 --- a/src/draw/dma2d/lv_draw_dma2d.c +++ b/src/draw/dma2d/lv_draw_dma2d.c @@ -292,7 +292,8 @@ static int32_t evaluate_cb(lv_draw_unit_t * draw_unit, lv_draw_task_t * task) break; case LV_DRAW_TASK_TYPE_IMAGE: { lv_draw_image_dsc_t * dsc = task->draw_dsc; - if(!(dsc->clip_radius == 0 + if(!(dsc->header.cf < LV_COLOR_FORMAT_PROPRIETARY_START + && dsc->clip_radius == 0 && dsc->bitmap_mask_src == NULL && dsc->sup == NULL && dsc->tile == 0 diff --git a/src/draw/nema_gfx/lv_draw_nema_gfx_img.c b/src/draw/nema_gfx/lv_draw_nema_gfx_img.c index e6eaa21b7..32ebba854 100644 --- a/src/draw/nema_gfx/lv_draw_nema_gfx_img.c +++ b/src/draw/nema_gfx/lv_draw_nema_gfx_img.c @@ -140,7 +140,9 @@ static void _draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_d } uint32_t src_nema_cf = lv_nemagfx_cf_to_nema(src_cf); - uint32_t src_stride = img_dsc->header.stride; + /* the stride should be computed internally for NEMA_TSC images and images missing a stride value */ + uint32_t src_stride = (src_cf >= LV_COLOR_FORMAT_NEMA_TSC_START && src_cf <= LV_COLOR_FORMAT_NEMA_TSC_END) + || img_dsc->header.stride == 0 ? -1 : img_dsc->header.stride; nema_bind_dst_tex((uintptr_t)NEMA_VIRT2PHYS(layer->draw_buf->data), lv_area_get_width(&(layer->buf_area)), lv_area_get_height(&(layer->buf_area)), dst_nema_cf, diff --git a/src/draw/nema_gfx/lv_draw_nema_gfx_utils.c b/src/draw/nema_gfx/lv_draw_nema_gfx_utils.c index db8deae68..0a6daca24 100644 --- a/src/draw/nema_gfx/lv_draw_nema_gfx_utils.c +++ b/src/draw/nema_gfx/lv_draw_nema_gfx_utils.c @@ -68,6 +68,16 @@ uint32_t lv_nemagfx_cf_to_nema(lv_color_format_t cf) return NEMA_BGRA8888; case LV_COLOR_FORMAT_XRGB8888: return NEMA_BGRX8888; + case LV_COLOR_FORMAT_NEMA_TSC4: + return NEMA_TSC4; + case LV_COLOR_FORMAT_NEMA_TSC6: + return NEMA_TSC6; + case LV_COLOR_FORMAT_NEMA_TSC6A: + return NEMA_TSC6A; + case LV_COLOR_FORMAT_NEMA_TSC12: + return NEMA_TSC12; + case LV_COLOR_FORMAT_NEMA_TSC12A: + return NEMA_TSC12A; default: return LV_NEMA_GFX_COLOR_FORMAT; } diff --git a/src/draw/nxp/pxp/lv_draw_pxp.c b/src/draw/nxp/pxp/lv_draw_pxp.c index 800d834e9..9ad876575 100644 --- a/src/draw/nxp/pxp/lv_draw_pxp.c +++ b/src/draw/nxp/pxp/lv_draw_pxp.c @@ -288,6 +288,9 @@ static int32_t _pxp_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t) lv_draw_image_dsc_t * draw_dsc = (lv_draw_image_dsc_t *) t->draw_dsc; const lv_image_dsc_t * img_dsc = draw_dsc->src; + if(img_dsc->header.cf >= LV_COLOR_FORMAT_PROPRIETARY_START) + return 0; + if(draw_dsc->tile) return 0; diff --git a/src/draw/nxp/vglite/lv_draw_vglite.c b/src/draw/nxp/vglite/lv_draw_vglite.c index 34b7c4fda..e3f8bbe7e 100644 --- a/src/draw/nxp/vglite/lv_draw_vglite.c +++ b/src/draw/nxp/vglite/lv_draw_vglite.c @@ -252,6 +252,10 @@ static int32_t _vglite_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t) lv_draw_image_dsc_t * draw_dsc = (lv_draw_image_dsc_t *) t->draw_dsc; const lv_image_dsc_t * img_dsc = draw_dsc->src; + if(img_dsc->header.cf >= LV_COLOR_FORMAT_PROPRIETARY_START) { + return 0; + } + #if LV_USE_VGLITE_BLIT_SPLIT bool has_transform = (draw_dsc->rotation != 0 || draw_dsc->scale_x != LV_SCALE_NONE || draw_dsc->scale_y != LV_SCALE_NONE); diff --git a/src/draw/opengles/lv_draw_opengles.c b/src/draw/opengles/lv_draw_opengles.c index 9d1e83a64..7f8fa7337 100644 --- a/src/draw/opengles/lv_draw_opengles.c +++ b/src/draw/opengles/lv_draw_opengles.c @@ -219,6 +219,11 @@ static int32_t evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task) { LV_UNUSED(draw_unit); + if(task->type == LV_DRAW_TASK_TYPE_IMAGE && + ((lv_draw_image_dsc_t *)task->draw_dsc)->header.cf >= LV_COLOR_FORMAT_PROPRIETARY_START) { + return 0; + } + /*If not refreshing the display probably it's a canvas rendering *which his not support in SDL as it's not a texture.*/ if(lv_refr_get_disp_refreshing() == NULL) return 0; diff --git a/src/draw/renesas/dave2d/lv_draw_dave2d.c b/src/draw/renesas/dave2d/lv_draw_dave2d.c index 66cf8fa5d..c29300903 100644 --- a/src/draw/renesas/dave2d/lv_draw_dave2d.c +++ b/src/draw/renesas/dave2d/lv_draw_dave2d.c @@ -243,6 +243,11 @@ static int32_t _dave2d_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t) } case LV_DRAW_TASK_TYPE_IMAGE: { + lv_draw_image_dsc_t * dsc = t->draw_dsc; + if(dsc->header.cf >= LV_COLOR_FORMAT_PROPRIETARY_START) { + ret = 0; + break; + } #if USE_D2 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D; t->preference_score = 0; diff --git a/src/draw/sdl/lv_draw_sdl.c b/src/draw/sdl/lv_draw_sdl.c index a6098c7dc..93e3ccc36 100644 --- a/src/draw/sdl/lv_draw_sdl.c +++ b/src/draw/sdl/lv_draw_sdl.c @@ -168,6 +168,11 @@ static int32_t evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task) { LV_UNUSED(draw_unit); + if(task->type == LV_DRAW_TASK_TYPE_IMAGE && + ((lv_draw_image_dsc_t *)task->draw_dsc)->header.cf >= LV_COLOR_FORMAT_PROPRIETARY_START) { + return 0; + } + /*If not refreshing the display probably it's a canvas rendering *which his not support in SDL as it's not a texture.*/ if(lv_refr_get_disp_refreshing() == NULL) return 0; diff --git a/src/draw/sw/lv_draw_sw.c b/src/draw/sw/lv_draw_sw.c index 44df64eae..5e656c4bd 100644 --- a/src/draw/sw/lv_draw_sw.c +++ b/src/draw/sw/lv_draw_sw.c @@ -414,6 +414,10 @@ static int32_t evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task) if(masked && (cf == LV_COLOR_FORMAT_A8 || cf == LV_COLOR_FORMAT_RGB565A8)) { return 0; } + + if(cf >= LV_COLOR_FORMAT_PROPRIETARY_START) { + return 0; + } } break; default: diff --git a/src/misc/lv_color.h b/src/misc/lv_color.h index d5222400e..3a939b90f 100644 --- a/src/misc/lv_color.h +++ b/src/misc/lv_color.h @@ -171,6 +171,16 @@ typedef enum { LV_COLOR_FORMAT_YUV_END = LV_COLOR_FORMAT_UYVY, + LV_COLOR_FORMAT_PROPRIETARY_START = 0x30, + + LV_COLOR_FORMAT_NEMA_TSC_START = LV_COLOR_FORMAT_PROPRIETARY_START, + LV_COLOR_FORMAT_NEMA_TSC4 = LV_COLOR_FORMAT_NEMA_TSC_START, + LV_COLOR_FORMAT_NEMA_TSC6 = 0x31, + LV_COLOR_FORMAT_NEMA_TSC6A = 0x32, + LV_COLOR_FORMAT_NEMA_TSC12 = 0x33, + LV_COLOR_FORMAT_NEMA_TSC12A = 0x34, + LV_COLOR_FORMAT_NEMA_TSC_END = LV_COLOR_FORMAT_NEMA_TSC12A, + /*Color formats in which LVGL can render*/ #if LV_COLOR_DEPTH == 1 LV_COLOR_FORMAT_NATIVE = LV_COLOR_FORMAT_I1,