Skip to content

Commit

Permalink
feature(lvgl_port): Initial support for ppa rendering in lvgl
Browse files Browse the repository at this point in the history
      Mainly supports the following features:
       - color blend (simple fill)
       - color blend with opa
       - blend normal (blend with argb8888)
       - blend normal (color convert / memcpy)
  • Loading branch information
ThunderDai committed Oct 24, 2024
1 parent 29bebaf commit 24e762a
Show file tree
Hide file tree
Showing 10 changed files with 1,602 additions and 26 deletions.
21 changes: 16 additions & 5 deletions components/esp_lvgl_port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ if("usb_host_hid" IN_LIST build_components)
endif()

# Include SIMD assembly source code for rendering, only for (9.1.0 <= LVG_version < 9.2.0) and only for esp32 and esp32s3
if((lvgl_ver VERSION_GREATER_EQUAL "9.1.0") AND (lvgl_ver VERSION_LESS "9.2.0"))
if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S3)
if((lvgl_ver VERSION_GREATER_EQUAL "9.1.0") AND (lvgl_ver VERSION_LESS_EQUAL "9.2.0"))
if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S3 OR CONFIG_IDF_TARGET_ESP32P4)
message(VERBOSE "Compiling SIMD")
if(CONFIG_IDF_TARGET_ESP32S3)
file(GLOB_RECURSE ASM_SRCS ${PORT_PATH}/simd/*_esp32s3.S) # Select only esp32s3 related files
else()
elseif(CONFIG_IDF_TARGET_ESP32)
file(GLOB_RECURSE ASM_SRCS ${PORT_PATH}/simd/*_esp32.S) # Select only esp32 related files
endif()
list(APPEND ADD_SRCS ${ASM_SRCS})
Expand All @@ -91,9 +91,16 @@ if((lvgl_ver VERSION_GREATER_EQUAL "9.1.0") AND (lvgl_ver VERSION_LESS "9.2.0"))
idf_component_get_property(lvgl_lib ${lvgl_name} COMPONENT_LIB)
target_include_directories(${lvgl_lib} PRIVATE "include")

if(CONFIG_IDF_TARGET_ESP32P4)
file(GLOB_RECURSE PPA_SRCS ${PORT_PATH}/ppa/*)
list(APPEND ADD_SRCS ${PPA_SRCS})
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u lv_malloc_core")
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u esp_ppa_fill_for_lvgl")
else()
# Force link .S files
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u lv_color_blend_to_argb8888_esp")
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u lv_color_blend_to_rgb565_esp")
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u lv_color_blend_to_argb8888_esp")
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u lv_color_blend_to_rgb565_esp")
endif()
endif()
endif()

Expand All @@ -114,5 +121,9 @@ target_link_libraries(lvgl_port_lib PRIVATE
${ADD_LIBS}
)

if(CONFIG_IDF_TARGET_ESP32P4)
target_link_libraries(lvgl_port_lib PRIVATE idf::esp_driver_ppa idf::esp_mm)
endif()

# Finally, link the lvgl_port_lib its esp-idf interface library
target_link_libraries(${COMPONENT_LIB} INTERFACE lvgl_port_lib)
87 changes: 75 additions & 12 deletions components/esp_lvgl_port/include/esp_lvgl_port_lv_blend.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extern "C" {
#warning "esp_lvgl_port_lv_blend.h included, but CONFIG_LV_DRAW_SW_ASM_CUSTOM not set. Assembly rendering not used"
#else

#include "lv_version.h"

/*********************
* DEFINES
*********************/
Expand Down Expand Up @@ -53,31 +55,92 @@ typedef struct {
* GLOBAL PROTOTYPES
**********************/

#if ((LVGL_VERSION_MAJOR == 9) && (LVGL_VERSION_MINOR == 1))

typedef struct {
void * dest_buf;
int32_t dest_w;
int32_t dest_h;
int32_t dest_stride;
const lv_opa_t * mask_buf;
int32_t mask_stride;
lv_color_t color;
lv_opa_t opa;
} bsp_blend_fill_dsc_t;

typedef struct {
void * dest_buf;
int32_t dest_w;
int32_t dest_h;
int32_t dest_stride;
const lv_opa_t * mask_buf;
int32_t mask_stride;
const void * src_buf;
int32_t src_stride;
lv_color_format_t src_color_format;
lv_opa_t opa;
lv_blend_mode_t blend_mode;
} bsp_blend_image_dsc_t;

#elif ((LVGL_VERSION_MAJOR == 9) && (LVGL_VERSION_MINOR == 2))

typedef struct {
void * dest_buf;
int32_t dest_w;
int32_t dest_h;
int32_t dest_stride;
const lv_opa_t * mask_buf;
int32_t mask_stride;
lv_color_t color;
lv_opa_t opa;
lv_area_t relative_area;
} bsp_blend_fill_dsc_t;

typedef struct {
void * dest_buf;
int32_t dest_w;
int32_t dest_h;
int32_t dest_stride;
const lv_opa_t * mask_buf;
int32_t mask_stride;
const void * src_buf;
int32_t src_stride;
lv_color_format_t src_color_format;
lv_opa_t opa;
lv_blend_mode_t blend_mode;
lv_area_t relative_area; /**< The blend area relative to the layer's buffer area. */
lv_area_t src_area; /**< The original src area. */
} bsp_blend_image_dsc_t;

#endif

extern int lv_color_blend_to_argb8888_esp(asm_dsc_t *asm_dsc);

static inline lv_result_t _lv_color_blend_to_argb8888_esp(_lv_draw_sw_blend_fill_dsc_t *dsc)
static inline lv_result_t _lv_color_blend_to_argb8888_esp(void *dsc)
{
bsp_blend_fill_dsc_t * fill_dsc = (bsp_blend_fill_dsc_t *) dsc;
asm_dsc_t asm_dsc = {
.dst_buf = dsc->dest_buf,
.dst_w = dsc->dest_w,
.dst_h = dsc->dest_h,
.dst_stride = dsc->dest_stride,
.src_buf = &dsc->color,
.dst_buf = fill_dsc->dest_buf,
.dst_w = fill_dsc->dest_w,
.dst_h = fill_dsc->dest_h,
.dst_stride = fill_dsc->dest_stride,
.src_buf = &fill_dsc->color,
};

return lv_color_blend_to_argb8888_esp(&asm_dsc);
}

extern int lv_color_blend_to_rgb565_esp(asm_dsc_t *asm_dsc);

static inline lv_result_t _lv_color_blend_to_rgb565_esp(_lv_draw_sw_blend_fill_dsc_t *dsc)
static inline lv_result_t _lv_color_blend_to_rgb565_esp(void *dsc)
{
bsp_blend_fill_dsc_t * fill_dsc = (bsp_blend_fill_dsc_t *) dsc;
asm_dsc_t asm_dsc = {
.dst_buf = dsc->dest_buf,
.dst_w = dsc->dest_w,
.dst_h = dsc->dest_h,
.dst_stride = dsc->dest_stride,
.src_buf = &dsc->color,
.dst_buf = fill_dsc->dest_buf,
.dst_w = fill_dsc->dest_w,
.dst_h = fill_dsc->dest_h,
.dst_stride = fill_dsc->dest_stride,
.src_buf = &fill_dsc->color,
};

return lv_color_blend_to_rgb565_esp(&asm_dsc);
Expand Down
Loading

0 comments on commit 24e762a

Please sign in to comment.