mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-26 19:23:46 +08:00
Feature/nema updates (#7245)
This commit is contained in:
parent
3513ac41da
commit
d3a685943c
@ -177,7 +177,16 @@ static int32_t nema_gfx_evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * ta
|
||||
#endif
|
||||
case LV_DRAW_TASK_TYPE_IMAGE: {
|
||||
lv_draw_image_dsc_t * draw_image_dsc = (lv_draw_image_dsc_t *) task->draw_dsc;
|
||||
if(draw_image_dsc->blend_mode == LV_BLEND_MODE_NORMAL || draw_image_dsc->blend_mode == LV_BLEND_MODE_ADDITIVE) {
|
||||
/*Guard for previous NemaGFX Version*/
|
||||
#ifndef NEMA_BLOP_RECOLOR
|
||||
if(draw_image_dsc->recolor_opa > LV_OPA_MIN)
|
||||
break;
|
||||
#endif
|
||||
const lv_image_dsc_t * img_dsc = draw_image_dsc->src;
|
||||
if(!lv_nemagfx_is_cf_supported(img_dsc->header.cf))
|
||||
break;
|
||||
|
||||
if(draw_image_dsc->blend_mode != LV_BLEND_MODE_SUBTRACTIVE) {
|
||||
if(task->preference_score > 80) {
|
||||
task->preference_score = 80;
|
||||
task->preferred_draw_unit_id = DRAW_UNIT_ID_NEMA_GFX;
|
||||
@ -246,11 +255,11 @@ static int32_t nema_gfx_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer)
|
||||
|
||||
/* Return 0 is no selection, some tasks can be supported by other units. */
|
||||
if(t == NULL || t->preferred_draw_unit_id != DRAW_UNIT_ID_NEMA_GFX)
|
||||
return 0;
|
||||
return LV_DRAW_UNIT_IDLE;
|
||||
|
||||
void * buf = lv_draw_layer_alloc_buf(layer);
|
||||
if(buf == NULL)
|
||||
return -1;
|
||||
return LV_DRAW_UNIT_IDLE;
|
||||
|
||||
t->state = LV_DRAW_TASK_STATE_IN_PROGRESS;
|
||||
draw_nema_gfx_unit->base_unit.target_layer = layer;
|
||||
|
@ -45,6 +45,8 @@ static void _draw_nema_gfx_tile(lv_draw_unit_t * draw_unit, const lv_draw_image_
|
||||
|
||||
static void _draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
static uint32_t lv_nemagfx_mask_cf_to_nema(lv_color_format_t cf);
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -114,7 +116,7 @@ static void _draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_d
|
||||
lv_area_move(&rel_clip_area, -layer->buf_area.x1, -layer->buf_area.y1);
|
||||
|
||||
bool has_transform = (dsc->rotation != 0 || dsc->scale_x != LV_SCALE_NONE || dsc->scale_y != LV_SCALE_NONE);
|
||||
/* bool recolor = (dsc->recolor_opa > LV_OPA_MIN); */
|
||||
bool recolor = (dsc->recolor_opa > LV_OPA_MIN);
|
||||
|
||||
/*Make the blend area relative to the buffer*/
|
||||
lv_area_move(&blend_area, -layer->buf_area.x1, -layer->buf_area.y1);
|
||||
@ -151,12 +153,15 @@ static void _draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_d
|
||||
nema_bind_src_tex((uintptr_t)(src_buf), tex_w, tex_h, src_nema_cf, src_stride,
|
||||
dsc->antialias ? NEMA_FILTER_BL : NEMA_FILTER_PS);
|
||||
|
||||
/* if(recolor) {
|
||||
lv_color32_t col32 = lv_color_to_32(dsc->recolor, LV_OPA_MIX2(dsc->recolor_opa, dsc->opa));
|
||||
uint32_t color = nema_rgba(col32.red, col32.green, col32.blue, col32.alpha);
|
||||
nema_set_recolor_color(color);
|
||||
blending_mode |= NEMA_BLOP_RECOLOR;
|
||||
} */
|
||||
/*Guard for previous NemaGFX Version*/
|
||||
#ifdef NEMA_BLOP_RECOLOR
|
||||
if(recolor) {
|
||||
lv_color32_t col32 = lv_color_to_32(dsc->recolor, LV_OPA_MIX2(dsc->recolor_opa, dsc->opa));
|
||||
uint32_t color = nema_rgba(col32.red, col32.green, col32.blue, col32.alpha);
|
||||
nema_set_recolor_color(color);
|
||||
blending_mode |= NEMA_BLOP_RECOLOR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(dsc->opa < 255) {
|
||||
uint32_t rgba = ((uint32_t)dsc->opa << 24U) | ((uint32_t)dsc->opa << 16U) | ((uint32_t)dsc->opa << 8U) | ((
|
||||
@ -165,6 +170,15 @@ static void _draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_d
|
||||
blending_mode |= NEMA_BLOP_MODULATE_A;
|
||||
}
|
||||
|
||||
if(dsc->bitmap_mask_src != NULL) {
|
||||
blending_mode |= NEMA_BLOP_STENCIL_TXTY;
|
||||
const lv_image_dsc_t * mask = dsc->bitmap_mask_src;
|
||||
const void * mask_buf = mask->data;
|
||||
nema_bind_tex(NEMA_TEX3, (uintptr_t)NEMA_VIRT2PHYS(mask_buf), mask->header.w, mask->header.h,
|
||||
lv_nemagfx_mask_cf_to_nema(mask->header.cf),
|
||||
mask->header.stride, NEMA_FILTER_BL);
|
||||
}
|
||||
|
||||
nema_set_blend_blit(blending_mode);
|
||||
|
||||
if(!has_transform) {
|
||||
@ -208,6 +222,26 @@ static void _draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_d
|
||||
nema_cl_submit(&(draw_nema_gfx_unit->cl));
|
||||
|
||||
}
|
||||
|
||||
/*NemaGFX does mask operations with A8,A4,A2 and A1 formats*/
|
||||
static uint32_t lv_nemagfx_mask_cf_to_nema(lv_color_format_t cf)
|
||||
{
|
||||
switch(cf) {
|
||||
case LV_COLOR_FORMAT_A1:
|
||||
return NEMA_A1;
|
||||
case LV_COLOR_FORMAT_A2:
|
||||
return NEMA_A2;
|
||||
case LV_COLOR_FORMAT_A4:
|
||||
return NEMA_A4;
|
||||
case LV_COLOR_FORMAT_A8:
|
||||
case LV_COLOR_FORMAT_L8:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NEMA_A8;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
@ -78,6 +78,11 @@ uint32_t lv_nemagfx_cf_to_nema(lv_color_format_t cf)
|
||||
return NEMA_TSC12;
|
||||
case LV_COLOR_FORMAT_NEMA_TSC12A:
|
||||
return NEMA_TSC12A;
|
||||
/*Guard for previous NemaGFX Version*/
|
||||
#ifdef NEMA_TSC6AP
|
||||
case LV_COLOR_FORMAT_NEMA_TSC6AP:
|
||||
return NEMA_TSC6AP;
|
||||
#endif
|
||||
default:
|
||||
return LV_NEMA_GFX_COLOR_FORMAT;
|
||||
}
|
||||
@ -93,6 +98,9 @@ uint32_t lv_nemagfx_blending_mode(lv_blend_mode_t lv_blend_mode)
|
||||
case LV_BLEND_MODE_ADDITIVE:
|
||||
blending_mode = NEMA_BL_ADD;
|
||||
break;
|
||||
case LV_BLEND_MODE_MULTIPLY:
|
||||
blending_mode = nema_blending_mode(NEMA_BF_DESTCOLOR, NEMA_BF_INVSRCALPHA, NEMA_BLOP_SRC_PREMULT);
|
||||
break;
|
||||
default:
|
||||
blending_mode = NEMA_BL_SIMPLE;
|
||||
break;
|
||||
@ -119,4 +127,17 @@ void lv_nemagfx_grad_set(NEMA_VG_GRAD_HANDLE gradient, lv_grad_dsc_t lv_grad, lv
|
||||
nema_vg_grad_set(gradient, cnt, stops, colors);
|
||||
}
|
||||
|
||||
bool lv_nemagfx_is_cf_supported(lv_color_format_t cf)
|
||||
{
|
||||
|
||||
switch(cf) {
|
||||
case LV_COLOR_FORMAT_ARGB8565:
|
||||
case LV_COLOR_FORMAT_RGB565A8:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_NEMA_GFX*/
|
@ -82,6 +82,13 @@ uintptr_t NEMA_VIRT2PHYS(void * addr);
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Check if `lv_color_format_t` is supported.
|
||||
* @param cf The LVGL color format
|
||||
* @return True/false
|
||||
*/
|
||||
bool lv_nemagfx_is_cf_supported(lv_color_format_t cf);
|
||||
|
||||
/**
|
||||
* Convert a `lv_color_format_t` to a Nema color format.
|
||||
* @param cf The LVGL color format
|
||||
|
@ -183,8 +183,9 @@ typedef enum {
|
||||
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_TSC6AP = 0x33,
|
||||
LV_COLOR_FORMAT_NEMA_TSC12 = 0x34,
|
||||
LV_COLOR_FORMAT_NEMA_TSC12A = 0x35,
|
||||
LV_COLOR_FORMAT_NEMA_TSC_END = LV_COLOR_FORMAT_NEMA_TSC12A,
|
||||
|
||||
/*Color formats in which LVGL can render*/
|
||||
|
Loading…
Reference in New Issue
Block a user