From d5759a092633d1e36300db7cab92a14032294cb3 Mon Sep 17 00:00:00 2001 From: jeremy-baker <54705580+jeremy-baker@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:05:00 +0000 Subject: [PATCH] fix(dave2d): required when using LVGL with LV_COLOR_DEPTH 32 (#7323) --- src/draw/renesas/dave2d/lv_draw_dave2d.c | 10 ++++ .../renesas/dave2d/lv_draw_dave2d_utils.c | 48 +++++++++++++++++-- .../renesas/dave2d/lv_draw_dave2d_utils.h | 2 + 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/draw/renesas/dave2d/lv_draw_dave2d.c b/src/draw/renesas/dave2d/lv_draw_dave2d.c index 2994dda2b..d7ee3ee92 100644 --- a/src/draw/renesas/dave2d/lv_draw_dave2d.c +++ b/src/draw/renesas/dave2d/lv_draw_dave2d.c @@ -217,6 +217,11 @@ static int32_t _dave2d_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t) LV_UNUSED(u); int32_t ret = 0; + lv_draw_dsc_base_t * draw_dsc_base = (lv_draw_dsc_base_t *) t->draw_dsc; + + if(!lv_draw_dave2d_is_dest_cf_supported(draw_dsc_base->layer->color_format)) + return 0; + switch(t->type) { case LV_DRAW_TASK_TYPE_FILL: { #if USE_D2 @@ -367,6 +372,11 @@ static int32_t lv_draw_dave2d_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * return LV_DRAW_UNIT_IDLE; /*Couldn't start rendering*/ } + /* Return if target buffer format is not supported. */ + if(!lv_draw_dave2d_is_dest_cf_supported(layer->color_format)) { + return LV_DRAW_UNIT_IDLE; /*Couldn't start rendering*/ + } + void * buf = lv_draw_layer_alloc_buf(layer); if(buf == NULL) { return LV_DRAW_UNIT_IDLE; /*Couldn't start rendering*/ diff --git a/src/draw/renesas/dave2d/lv_draw_dave2d_utils.c b/src/draw/renesas/dave2d/lv_draw_dave2d_utils.c index 98fb80609..28c91c81e 100644 --- a/src/draw/renesas/dave2d/lv_draw_dave2d_utils.c +++ b/src/draw/renesas/dave2d/lv_draw_dave2d_utils.c @@ -75,7 +75,7 @@ d2_s32 lv_draw_dave2d_cf_fb_get(void) d2_fb_mode = d2_mode_argb8888; break; case DISPLAY_IN_FORMAT_32BITS_RGB888: ///< RGB888, 32 bits - d2_fb_mode = d2_mode_rgb888; + d2_fb_mode = d2_mode_argb8888; //GLCDC ignores Alpha when configured for RGB888 break; case DISPLAY_IN_FORMAT_16BITS_ARGB4444: ///< ARGB4444, 16 bits d2_fb_mode = d2_mode_argb4444; @@ -99,18 +99,39 @@ d2_u32 lv_draw_dave2d_lv_colour_fmt_to_d2_fmt(lv_color_format_t colour_format) d2_u32 d2_lvgl_mode = 0; switch(colour_format) { + case(LV_COLOR_FORMAT_I1): + d2_lvgl_mode = d2_mode_i1; + break; + case(LV_COLOR_FORMAT_I2): + d2_lvgl_mode = d2_mode_i2; + break; + case(LV_COLOR_FORMAT_I4): + d2_lvgl_mode = d2_mode_i4; + break; + case(LV_COLOR_FORMAT_I8): + d2_lvgl_mode = d2_mode_i4; + break; case(LV_COLOR_FORMAT_A8): - d2_lvgl_mode = d2_mode_alpha8; //? + d2_lvgl_mode = d2_mode_alpha8; break; case(LV_COLOR_FORMAT_RGB565): d2_lvgl_mode = d2_mode_rgb565; break; case(LV_COLOR_FORMAT_RGB888): - d2_lvgl_mode = d2_mode_argb8888; //? + d2_lvgl_mode = d2_mode_rgb888; + break; + case(LV_COLOR_FORMAT_ARGB1555): + d2_lvgl_mode = d2_mode_argb1555; + break; + case(LV_COLOR_FORMAT_ARGB4444): + d2_lvgl_mode = d2_mode_argb4444; break; case(LV_COLOR_FORMAT_ARGB8888): d2_lvgl_mode = d2_mode_argb8888; break; + case(LV_COLOR_FORMAT_XRGB8888): + d2_lvgl_mode = d2_mode_argb8888; + break; default: LV_ASSERT(0); @@ -133,6 +154,27 @@ void d2_framebuffer_from_layer(d2_device * handle, lv_layer_t * layer) lv_draw_dave2d_lv_colour_fmt_to_d2_fmt(layer->color_format)); } +bool lv_draw_dave2d_is_dest_cf_supported(lv_color_format_t cf) +{ + bool result; + + switch(cf) { + case LV_COLOR_FORMAT_A8: + case LV_COLOR_FORMAT_RGB565: + case LV_COLOR_FORMAT_ARGB8888: + case LV_COLOR_FORMAT_XRGB8888: + case LV_COLOR_FORMAT_ARGB4444: + result = true; + break; + + default: + result = false; + break; + } + + return result; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/draw/renesas/dave2d/lv_draw_dave2d_utils.h b/src/draw/renesas/dave2d/lv_draw_dave2d_utils.h index 67c510267..db9a17817 100644 --- a/src/draw/renesas/dave2d/lv_draw_dave2d_utils.h +++ b/src/draw/renesas/dave2d/lv_draw_dave2d_utils.h @@ -34,6 +34,8 @@ d2_u32 lv_draw_dave2d_lv_colour_fmt_to_d2_fmt(lv_color_format_t colour_format); void d2_framebuffer_from_layer(d2_device * handle, lv_layer_t * layer); +bool lv_draw_dave2d_is_dest_cf_supported(lv_color_format_t cf); + /********************** * MACROS **********************/