feat(draw): add SIMD draw support. #4463 (#4590)

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
This commit is contained in:
terry.rong
2023-10-19 16:13:17 +08:00
committed by GitHub
parent 865a2f64a0
commit 505eeeaeb5
6 changed files with 1760 additions and 0 deletions

28
Kconfig
View File

@@ -220,6 +220,34 @@ menu "LVGL configuration"
with the given opacity. Note that `bg_opa`, `text_opa` etc
don't require buffering into layer.
choice LV_USE_DRAW_SW_ASM
prompt "Asm mode in sw draw"
default LV_DRAW_SW_ASM_NONE
help
ASM mode to be used.
config LV_DRAW_SW_ASM_NONE
bool "0: NONE"
config LV_DRAW_SW_ASM_NEON
bool "1: NEON"
config LV_DRAW_SW_ASM_MVE
bool "2: MVE"
config LV_DRAW_SW_ASM_CUSTOM
bool "255: CUSTOM"
endchoice
config LV_USE_DRAW_SW_ASM
int
default 0 if LV_DRAW_SW_ASM_NONE
default 1 if LV_DRAW_SW_ASM_NEON
default 2 if LV_DRAW_SW_ASM_MVE
default 255 if LV_DRAW_SW_ASM_CUSTOM
config LV_DRAW_SW_ASM_CUSTOM_INCLUDE
string "Set the custom asm include file"
default ""
depends on LV_DRAW_SW_ASM_CUSTOM
config LV_IMG_CACHE_DEF_SIZE
int "Default image cache size. 0 to disable caching."
default 0

View File

@@ -117,6 +117,12 @@
* 0: to disable caching */
#define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4
#endif
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM
#define LV_DRAW_SW_ASM_CUSTOM_INCLUDE ""
#endif
#endif
/* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */

View File

@@ -16,6 +16,12 @@
#include "../../../misc/lv_color.h"
#include "../../../stdlib/lv_string.h"
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_NEON
#include "neon/lv_blend_to_rgb888_neon.h"
#elif LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM
#include LV_DRAW_SW_ASM_CUSTOM_INCLUDE
#endif
/*********************
* DEFINES
*********************/
@@ -63,8 +69,20 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi
int32_t x;
int32_t y;
LV_UNUSED(w);
LV_UNUSED(h);
LV_UNUSED(x);
LV_UNUSED(y);
LV_UNUSED(opa);
LV_UNUSED(mask);
LV_UNUSED(mask_stride);
LV_UNUSED(dest_stride);
/*Simple fill*/
if(mask == NULL && opa >= LV_OPA_MAX) {
#ifdef LV_DRAW_SW_COLOR_BLEND_TO_RGB888
LV_DRAW_SW_COLOR_BLEND_TO_RGB888(dsc, dest_px_size);
#else
if(dest_px_size == 3) {
uint8_t * dest_buf_u8 = dsc->dest_buf;
uint8_t * dest_buf_ori = dsc->dest_buf;
@@ -116,9 +134,13 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi
dest_buf_u32 += dest_stride;
}
}
#endif
}
/*Opacity only*/
else if(mask == NULL && opa < LV_OPA_MAX) {
#ifdef LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_OPA
LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_OPA(dsc, dest_px_size);
#else
uint32_t color32 = lv_color_to_u32(dsc->color);
uint8_t * dest_buf = dsc->dest_buf;
dest_stride *= dest_px_size;
@@ -129,9 +151,13 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi
}
dest_buf += dest_stride;
}
#endif
}
/*Masked with full opacity*/
else if(mask && opa >= LV_OPA_MAX) {
#ifdef LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_MASK
LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_MASK(dsc, dest_px_size);
#else
uint32_t color32 = lv_color_to_u32(dsc->color);
uint8_t * dest_buf = dsc->dest_buf;
dest_stride *= dest_px_size;
@@ -145,9 +171,13 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi
dest_buf += dest_stride;
mask += mask_stride;
}
#endif
}
/*Masked with opacity*/
else {
#ifdef LV_DRAW_SW_COLOR_BLEND_TO_RGB888_MIX_MASK_OPA
LV_DRAW_SW_COLOR_BLEND_TO_RGB888_MIX_MASK_OPA(dsc, dest_px_size);
#else
uint32_t color32 = lv_color_to_u32(dsc->color);
uint8_t * dest_buf = dsc->dest_buf;
dest_stride *= dest_px_size;
@@ -161,6 +191,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_color_to_rgb888(_lv_draw_sw_blend_fi
dest_buf += dest_stride;
mask += mask_stride;
}
#endif
}
}
@@ -387,6 +418,9 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d
if(dsc->blend_mode == LV_BLEND_MODE_NORMAL) {
if(mask_buf == NULL && opa >= LV_OPA_MAX) {
#ifdef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888
LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888(dsc, dest_px_size);
#else
for(y = 0; y < h; y++) {
for(dest_x = 0, src_x = 0; src_x < w; dest_x += dest_px_size, src_x++) {
lv_color_24_24_mix((const uint8_t *)&src_buf_c32[src_x], &dest_buf[dest_x], src_buf_c32[src_x].alpha);
@@ -394,8 +428,12 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d
dest_buf += dest_stride;
src_buf_c32 += src_stride;
}
#endif
}
else if(mask_buf == NULL && opa < LV_OPA_MAX) {
#ifdef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_OPA
LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_OPA(dsc, dest_px_size);
#else
for(y = 0; y < h; y++) {
for(dest_x = 0, src_x = 0; src_x < w; dest_x += dest_px_size, src_x++) {
lv_color_24_24_mix((const uint8_t *)&src_buf_c32[src_x], &dest_buf[dest_x], LV_OPA_MIX2(src_buf_c32[src_x].alpha, opa));
@@ -403,8 +441,12 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d
dest_buf += dest_stride;
src_buf_c32 += src_stride;
}
#endif
}
else if(mask_buf && opa >= LV_OPA_MAX) {
#ifdef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_MASK
LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_MASK(dsc, dest_px_size);
#else
for(y = 0; y < h; y++) {
for(dest_x = 0, src_x = 0; src_x < w; dest_x += dest_px_size, src_x++) {
lv_color_24_24_mix((const uint8_t *)&src_buf_c32[src_x], &dest_buf[dest_x],
@@ -414,8 +456,12 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d
src_buf_c32 += src_stride;
mask_buf += mask_stride;
}
#endif
}
else if(mask_buf && opa < LV_OPA_MAX) {
#ifdef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA
LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA(dsc, dest_px_size);
#else
for(y = 0; y < h; y++) {
for(dest_x = 0, src_x = 0; src_x < w; dest_x += dest_px_size, src_x++) {
lv_color_24_24_mix((const uint8_t *)&src_buf_c32[src_x], &dest_buf[dest_x],
@@ -425,6 +471,7 @@ LV_ATTRIBUTE_FAST_MEM static void argb8888_image_blend(_lv_draw_sw_blend_image_d
src_buf_c32 += src_stride;
mask_buf += mask_stride;
}
#endif
}
}
else {

File diff suppressed because it is too large Load Diff

View File

@@ -297,6 +297,24 @@
#endif
#endif
#endif
#ifndef LV_USE_DRAW_SW_ASM
#ifdef CONFIG_LV_USE_DRAW_SW_ASM
#define LV_USE_DRAW_SW_ASM CONFIG_LV_USE_DRAW_SW_ASM
#else
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
#endif
#endif
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM
#ifndef LV_DRAW_SW_ASM_CUSTOM_INCLUDE
#ifdef CONFIG_LV_DRAW_SW_ASM_CUSTOM_INCLUDE
#define LV_DRAW_SW_ASM_CUSTOM_INCLUDE CONFIG_LV_DRAW_SW_ASM_CUSTOM_INCLUDE
#else
#define LV_DRAW_SW_ASM_CUSTOM_INCLUDE ""
#endif
#endif
#endif
#endif
/* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */

View File

@@ -44,6 +44,11 @@ extern "C" {
#define LV_STDLIB_MICROPYTHON 2
#define LV_STDLIB_CUSTOM 255
#define LV_DRAW_SW_ASM_NONE 0
#define LV_DRAW_SW_ASM_NEON 1
#define LV_DRAW_SW_ASM_MVE 2
#define LV_DRAW_SW_ASM_CUSTOM 255
/**********************
* TYPEDEFS
**********************/