diff --git a/Kconfig b/Kconfig index 0bf17500ad..273433c248 100644 --- a/Kconfig +++ b/Kconfig @@ -369,37 +369,6 @@ menu "LVGL configuration" default "" depends on LV_DRAW_SW_ASM_CUSTOM - config LV_USE_DRAW_VGLITE - bool "Use NXP's VG-Lite GPU on iMX RTxxx platforms" - default n - - config LV_USE_VGLITE_BLIT_SPLIT - bool "Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels" - depends on LV_USE_DRAW_VGLITE - default n - - config LV_USE_VGLITE_DRAW_THREAD - bool "Use additional draw thread for VG-Lite processing" - depends on LV_USE_DRAW_VGLITE && !LV_OS_NONE - default y - - config LV_USE_VGLITE_DRAW_ASYNC - bool "Enable VGLite draw async" - depends on LV_USE_VGLITE_DRAW_THREAD - default y - help - Queue multiple tasks and flash them once to the GPU. The task ready state will be send asynchronous to dispatcher. - - config LV_USE_VGLITE_ASSERT - bool "Enable VGLite asserts" - depends on LV_USE_DRAW_VGLITE - default n - - config LV_USE_VGLITE_CHECK_ERROR - bool "Enable VGLite error checks" - depends on LV_USE_DRAW_VGLITE - default n - config LV_USE_PXP bool "Use NXP's PXP on iMX RTxxx platforms" default n diff --git a/env_support/cmsis-pack/lv_conf_cmsis.h b/env_support/cmsis-pack/lv_conf_cmsis.h index 772eb8f633..1657721a0b 100644 --- a/env_support/cmsis-pack/lv_conf_cmsis.h +++ b/env_support/cmsis-pack/lv_conf_cmsis.h @@ -253,27 +253,6 @@ #endif #endif -/** Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ -#if LV_USE_DRAW_VGLITE - /** Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ - #define LV_USE_VGLITE_BLIT_SPLIT 0 - - #if LV_USE_OS - /** Use additional draw thread for VG-Lite processing. */ - #define LV_USE_VGLITE_DRAW_THREAD 1 - - #if LV_USE_VGLITE_DRAW_THREAD - /** Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ - #define LV_USE_VGLITE_DRAW_ASYNC 1 - #endif - #endif - - /** Enable VGLite asserts. */ - #define LV_USE_VGLITE_ASSERT 0 - - /** Enable VGLite error checks. */ - #define LV_USE_VGLITE_CHECK_ERROR 0 -#endif /** Use NXP's PXP on iMX RTxxx platforms. */ #if LV_USE_PXP diff --git a/lv_conf_template.h b/lv_conf_template.h index 40fae356fc..ebcc0c2d1e 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -250,30 +250,6 @@ #endif #endif -/** Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ -#define LV_USE_DRAW_VGLITE 0 - -#if LV_USE_DRAW_VGLITE - /** Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ - #define LV_USE_VGLITE_BLIT_SPLIT 0 - - #if LV_USE_OS - /** Use additional draw thread for VG-Lite processing. */ - #define LV_USE_VGLITE_DRAW_THREAD 1 - - #if LV_USE_VGLITE_DRAW_THREAD - /** Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ - #define LV_USE_VGLITE_DRAW_ASYNC 1 - #endif - #endif - - /** Enable VGLite asserts. */ - #define LV_USE_VGLITE_ASSERT 0 - - /** Enable VGLite error checks. */ - #define LV_USE_VGLITE_CHECK_ERROR 0 -#endif - /** Use NXP's PXP on iMX RTxxx platforms. */ #define LV_USE_PXP 0 @@ -318,7 +294,6 @@ /** Use VG-Lite GPU. */ #define LV_USE_DRAW_VG_LITE 0 - #if LV_USE_DRAW_VG_LITE /** Enable VG-Lite custom external 'gpu_init()' function */ #define LV_VG_LITE_USE_GPU_INIT 0 @@ -346,11 +321,47 @@ /** Disable linear gradient extension for some older versions of drivers. */ #define LV_VG_LITE_DISABLE_LINEAR_GRADIENT_EXT 0 + + /** Enable usage of the LVGL's built-in vg_lite driver */ + #define LV_USE_VG_LITE_DRIVER 0 + #if LV_USE_VG_LITE_DRIVER + /** Used to pick the correct GPU series folder valid options are gc255, gc355 and gc555*/ + #define LV_VG_LITE_HAL_GPU_SERIES gc255 + + /** Used to pick the correct GPU revision header it depends on the vendor */ + #define LV_VG_LITE_HAL_GPU_REVISION 0x40 + + /** Base memory address of the GPU IP it depends on SoC, + * default value is for NXP based devices */ + #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS 0x40240000 + #endif /*LV_USE_VG_LITE_DRIVER*/ + + /** Use ThorVG (a software vector library) as VG-Lite driver to allow testing VGLite on PC + * Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ + #define LV_USE_VG_LITE_THORVG 0 + #if LV_USE_VG_LITE_THORVG + /** Enable LVGL's blend mode support */ + #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 + + /** Enable YUV color format support */ + #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 + + /** Enable Linear gradient extension support */ + #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 + + /** Enable alignment on 16 pixels */ + #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 + + /** Buffer address alignment */ + #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 + + /** Enable multi-thread render */ + #define LV_VG_LITE_THORVG_THREAD_RENDER 0 + #endif /*LV_USE_VG_LITE_THORVG*/ #endif /** Accelerate blends, fills, etc. with STM32 DMA2D */ #define LV_USE_DRAW_DMA2D 0 - #if LV_USE_DRAW_DMA2D #define LV_DRAW_DMA2D_HAL_INCLUDE "stm32h7xx_hal.h" @@ -362,7 +373,6 @@ /** Draw using cached OpenGLES textures. Requires LV_USE_OPENGLES */ #define LV_USE_DRAW_OPENGLES 0 - #if LV_USE_DRAW_OPENGLES #define LV_DRAW_OPENGLES_TEXTURE_CACHE_COUNT 64 #endif @@ -375,7 +385,6 @@ /* Use EVE FT81X GPU. */ #define LV_USE_DRAW_EVE 0 - #if LV_USE_DRAW_EVE /* EVE_GEN value: 2, 3, or 4 */ #define LV_DRAW_EVE_EVE_GENERATION 4 @@ -521,46 +530,6 @@ /** Enable property name support. */ #define LV_USE_OBJ_PROPERTY_NAME 1 -/* Use VG-Lite Simulator. - * - Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ -#define LV_USE_VG_LITE_THORVG 0 - -#if LV_USE_VG_LITE_THORVG - /** Enable LVGL's blend mode support */ - #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 - - /** Enable YUV color format support */ - #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 - - /** Enable Linear gradient extension support */ - #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 - - /** Enable alignment on 16 pixels */ - #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 - - /** Buffer address alignment */ - #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 - - /** Enable multi-thread render */ - #define LV_VG_LITE_THORVG_THREAD_RENDER 0 -#endif - -/* Enable usage of the LVGL's vg_lite spec driver */ -#define LV_USE_VG_LITE_DRIVER 0 - -#if LV_USE_VG_LITE_DRIVER - - /* Used to pick the correct GPU series folder valid options are gc255, gc355 and gc555*/ - #define LV_VG_LITE_HAL_GPU_SERIES gc255 - - /* Used to pick the correct GPU revision header it depends on the vendor */ - #define LV_VG_LITE_HAL_GPU_REVISION 0x40 - - /* Base memory address of the GPU IP it depends on SoC, default value is for NXP based devices */ - #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS 0x40240000 - -#endif - /* Enable the multi-touch gesture recognition feature */ /* Gesture recognition requires the use of floats */ #define LV_USE_GESTURE_RECOGNITION 0 @@ -1012,12 +981,17 @@ #define LV_USE_GLTF 0 /** Enable Vector Graphic APIs - * - Requires `LV_USE_MATRIX = 1` */ + * Requires `LV_USE_MATRIX = 1` */ #define LV_USE_VECTOR_GRAPHIC 0 -/** Enable ThorVG (vector graphics library) from the src/libs folder */ +/** Enable ThorVG (vector graphics library) from the src/libs folder. + * Requires LV_USE_VECTOR_GRAPHIC */ #define LV_USE_THORVG_INTERNAL 0 +/** Enable ThorVG by assuming that its installed and linked to the project + * Requires LV_USE_VECTOR_GRAPHIC */ +#define LV_USE_THORVG_EXTERNAL 0 + /** Enable ThorVG by assuming that its installed and linked to the project */ #define LV_USE_THORVG_EXTERNAL 0 diff --git a/scripts/lv_conf_internal_gen.py b/scripts/lv_conf_internal_gen.py index 225297ab48..7b481d7f91 100755 --- a/scripts/lv_conf_internal_gen.py +++ b/scripts/lv_conf_internal_gen.py @@ -196,6 +196,15 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN); #undef LV_KCONFIG_PRESENT +/* Disable VGLite drivers if VGLite drawing is disabled */ +#ifndef LV_USE_VG_LITE_DRIVER + #define LV_USE_VG_LITE_DRIVER 0 +#endif + +#ifndef LV_USE_VG_LITE_THORVG + #define LV_USE_VG_LITE_THORVG 0 +#endif + /* Set some defines if a dependency is disabled. */ #if LV_USE_LOG == 0 #define LV_LOG_LEVEL LV_LOG_LEVEL_NONE diff --git a/src/draw/nxp/vglite/lv_draw_buf_vglite.c b/src/draw/nxp/vglite/lv_draw_buf_vglite.c deleted file mode 100644 index f42bf6fb14..0000000000 --- a/src/draw/nxp/vglite/lv_draw_buf_vglite.c +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file lv_draw_buf_vglite.c - * - */ - -/** - * Copyright 2023-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "../../lv_draw_buf_private.h" -#include "lv_vglite_buf.h" -#include "lv_vglite_utils.h" - -#include "lvgl_support.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area); -static uint32_t _width_to_stride(uint32_t w, lv_color_format_t cf); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_buf_vglite_init_handlers(void) -{ - lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers(); - lv_draw_buf_handlers_t * font_handlers = lv_draw_buf_get_font_handlers(); - lv_draw_buf_handlers_t * image_handlers = lv_draw_buf_get_image_handlers(); - - handlers->invalidate_cache_cb = _invalidate_cache; - font_handlers->invalidate_cache_cb = _invalidate_cache; - image_handlers->invalidate_cache_cb = _invalidate_cache; - - handlers->width_to_stride_cb = _width_to_stride; - font_handlers->width_to_stride_cb = _width_to_stride; - image_handlers->width_to_stride_cb = _width_to_stride; - -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area) -{ - const lv_image_header_t * header = &draw_buf->header; - uint32_t stride = header->stride; - lv_color_format_t cf = header->cf; - - if(area->y1 == 0) { - uint32_t size = stride * lv_area_get_height(area); - - /* Invalidate full buffer. */ - DEMO_CleanInvalidateCacheByAddr((void *)draw_buf->data, size); - return; - } - - const uint8_t * buf_u8 = draw_buf->data; - /* ARM require a 32 byte aligned address. */ - uint8_t align_bytes = 32; - uint8_t bits_per_pixel = lv_color_format_get_bpp(cf); - - uint16_t align_pixels = align_bytes * 8 / bits_per_pixel; - uint16_t offset_x = 0; - - if(area->x1 >= (int32_t)(area->x1 % align_pixels)) { - uint16_t shift_x = area->x1 - (area->x1 % align_pixels); - - offset_x = area->x1 - shift_x; - buf_u8 += (shift_x * bits_per_pixel) / 8; - } - - if(area->y1) { - uint16_t shift_y = area->y1; - - buf_u8 += shift_y * stride; - } - - /* Area to clear can start from a different offset in buffer. - * Invalidate the area line by line. - */ - uint16_t line_pixels = offset_x + lv_area_get_width(area); - uint16_t line_size = (line_pixels * bits_per_pixel) / 8; - uint16_t area_height = lv_area_get_height(area); - - for(uint16_t y = 0; y < area_height; y++) { - const void * line_addr = buf_u8 + y * stride; - - DEMO_CleanInvalidateCacheByAddr((void *)line_addr, line_size); - } -} - -static uint32_t _width_to_stride(uint32_t w, lv_color_format_t cf) -{ - uint8_t bits_per_pixel = lv_color_format_get_bpp(cf); - uint32_t width_bits = LV_ROUND_UP(w * bits_per_pixel, 8); - uint32_t width_bytes = width_bits / 8; - uint8_t align_bytes = vglite_get_stride_alignment(cf); - - return LV_ROUND_UP(width_bytes, align_bytes); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite.c b/src/draw/nxp/vglite/lv_draw_vglite.c deleted file mode 100644 index fec91cac18..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite.c +++ /dev/null @@ -1,638 +0,0 @@ -/** - * @file lv_draw_vglite.c - * - */ - -/** - * Copyright 2023-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_utils.h" - -#include "../../../core/lv_global.h" - -/********************* - * DEFINES - *********************/ - -#define DRAW_UNIT_ID_VGLITE 2 - -#if LV_USE_VGLITE_DRAW_ASYNC - #define VGLITE_TASK_BUF_SIZE 100 -#endif - -/********************** - * TYPEDEFS - **********************/ - -#if LV_USE_VGLITE_DRAW_ASYNC -/** - * Structure of pending vglite draw task - */ -typedef struct _vglite_flush_task { - vglite_draw_task_t * task; - bool flushed; -} vglite_flush_task_t; -#endif - -/********************** - * STATIC PROTOTYPES - **********************/ - -static inline void _vglite_cleanup_task(vglite_draw_task_t * task); - -/* - * Evaluate a task and set the score and preferred VGLite draw unit. - * Return 1 if task is preferred, 0 otherwise (task is not supported). - */ -static int32_t _vglite_evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task); - -/* - * Dispatch (assign) a task to VGLite draw unit (itself). - * Return 1 if task was dispatched, 0 otherwise (task not supported). - */ -static int32_t _vglite_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer); - -/* - * Wait for VG-Lite draw unit to finish. - */ -#if LV_USE_VGLITE_DRAW_ASYNC - static int32_t _vglite_wait_for_finish(lv_draw_unit_t * draw_unit); -#endif - -/* - * Delete the VGLite draw unit. - */ -static int32_t _vglite_delete(lv_draw_unit_t * draw_unit); - -#if LV_USE_VGLITE_DRAW_THREAD - static void _vglite_render_thread_cb(void * ptr); -#endif - -static void _vglite_execute_drawing(lv_draw_vglite_unit_t * u); - -/********************** - * STATIC VARIABLES - **********************/ - -#define _draw_info LV_GLOBAL_DEFAULT()->draw_info - -#if LV_USE_VGLITE_DRAW_ASYNC - /* - * Circular buffer to hold the queued and the flushed tasks. - * Two indexes, _head and _tail, are used to signal the beginning - * and the end of the valid tasks that are pending. - */ - static vglite_flush_task_t _draw_task_buf[VGLITE_TASK_BUF_SIZE]; - static volatile int _head = 0; - static volatile int _tail = 0; -#endif - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_init(void) -{ - lv_draw_buf_vglite_init_handlers(); - - lv_draw_vglite_unit_t * draw_vglite_unit = lv_draw_create_unit(sizeof(lv_draw_vglite_unit_t)); - draw_vglite_unit->base_unit.evaluate_cb = _vglite_evaluate; - draw_vglite_unit->base_unit.dispatch_cb = _vglite_dispatch; -#if LV_USE_VGLITE_DRAW_ASYNC - draw_vglite_unit->base_unit.wait_for_finish_cb = _vglite_wait_for_finish; -#endif - draw_vglite_unit->base_unit.delete_cb = _vglite_delete; - draw_vglite_unit->base_unit.name = "NXP_VGLITE"; - -#if LV_USE_VGLITE_DRAW_THREAD - lv_thread_init(&draw_vglite_unit->thread, "vglitedraw", LV_DRAW_THREAD_PRIO, _vglite_render_thread_cb, 4 * 1024, - draw_vglite_unit); -#endif -} - -void lv_draw_vglite_deinit(void) -{ -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static inline bool _vglite_src_cf_supported(lv_color_format_t cf) -{ - bool is_cf_supported = false; - - switch(cf) { -#if CHIPID == 0x255 || CHIPID == 0x555 - case LV_COLOR_FORMAT_I1: - case LV_COLOR_FORMAT_I2: - case LV_COLOR_FORMAT_I4: - case LV_COLOR_FORMAT_I8: -#endif - case LV_COLOR_FORMAT_A4: - case LV_COLOR_FORMAT_A8: - case LV_COLOR_FORMAT_L8: - case LV_COLOR_FORMAT_RGB565: -#if CHIPID == 0x555 - case LV_COLOR_FORMAT_ARGB8565: - case LV_COLOR_FORMAT_RGB888: -#endif - case LV_COLOR_FORMAT_ARGB8888: - case LV_COLOR_FORMAT_XRGB8888: - is_cf_supported = true; - break; - default: - break; - } - - return is_cf_supported; -} - -static inline bool _vglite_dest_cf_supported(lv_color_format_t cf) -{ - bool is_cf_supported = false; - - switch(cf) { - case LV_COLOR_FORMAT_A8: -#if CHIPID == 0x255 || CHIPID == 0x555 - case LV_COLOR_FORMAT_L8: -#endif - case LV_COLOR_FORMAT_RGB565: -#if CHIPID == 0x555 - case LV_COLOR_FORMAT_ARGB8565: - case LV_COLOR_FORMAT_RGB888: -#endif - case LV_COLOR_FORMAT_ARGB8888: - case LV_COLOR_FORMAT_XRGB8888: - is_cf_supported = true; - break; - default: - break; - } - - return is_cf_supported; -} - -static int32_t _vglite_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t) -{ - LV_UNUSED(u); - - const lv_draw_dsc_base_t * draw_dsc_base = (lv_draw_dsc_base_t *) t->draw_dsc; - - if(!_vglite_dest_cf_supported(draw_dsc_base->layer->color_format)) - return 0; - - switch(t->type) { - case LV_DRAW_TASK_TYPE_FILL: - if(t->preference_score > 80) { - t->preference_score = 80; - t->preferred_draw_unit_id = DRAW_UNIT_ID_VGLITE; - } - return 1; - - case LV_DRAW_TASK_TYPE_LINE: - case LV_DRAW_TASK_TYPE_ARC: - case LV_DRAW_TASK_TYPE_TRIANGLE: - if(t->preference_score > 90) { - t->preference_score = 90; - t->preferred_draw_unit_id = DRAW_UNIT_ID_VGLITE; - } - return 1; - - case LV_DRAW_TASK_TYPE_LABEL: - if(t->preference_score > 95) { - t->preference_score = 95; - t->preferred_draw_unit_id = DRAW_UNIT_ID_VGLITE; - } - return 1; - - case LV_DRAW_TASK_TYPE_BORDER: { - if(t->preference_score > 90) { - t->preference_score = 90; - t->preferred_draw_unit_id = DRAW_UNIT_ID_VGLITE; - } - return 1; - } - - case LV_DRAW_TASK_TYPE_LAYER: { - const lv_draw_image_dsc_t * draw_dsc = (lv_draw_image_dsc_t *) t->draw_dsc; - lv_layer_t * layer_to_draw = (lv_layer_t *)draw_dsc->src; - -#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); -#endif - if(!_vglite_src_cf_supported(layer_to_draw->color_format) -#if LV_USE_VGLITE_BLIT_SPLIT - || has_transform -#endif - ) - return 0; - - if(t->preference_score > 80) { - t->preference_score = 80; - t->preferred_draw_unit_id = DRAW_UNIT_ID_VGLITE; - } - return 1; - } - - case LV_DRAW_TASK_TYPE_IMAGE: { - 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 CHIPID == 0x255 - if(draw_dsc->tile) - return 0; -#endif -#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); - bool is_tiled = draw_dsc->tile; -#endif - - if((!_vglite_src_cf_supported(img_dsc->header.cf)) -#if LV_USE_VGLITE_BLIT_SPLIT - || has_transform || is_tiled -#endif - || (!vglite_src_buf_aligned(img_dsc->data, img_dsc->header.stride, img_dsc->header.cf)) - ) - return 0; - - if(t->preference_score > 80) { - t->preference_score = 80; - t->preferred_draw_unit_id = DRAW_UNIT_ID_VGLITE; - } - return 1; - } - default: - return 0; - } - - return 0; -} - -static int32_t _vglite_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer) -{ - lv_draw_vglite_unit_t * draw_vglite_unit = (lv_draw_vglite_unit_t *) draw_unit; - - /* Return immediately if draw unit is busy. */ - if(draw_vglite_unit->task_act -#if LV_USE_VGLITE_DRAW_ASYNC - || draw_vglite_unit->wait_for_finish -#endif - ) - return 0; - - /* Try to get an ready to draw. */ - lv_draw_task_t * t = lv_draw_get_available_task(layer, NULL, DRAW_UNIT_ID_VGLITE); - - if(t == NULL) - return LV_DRAW_UNIT_IDLE; - - if(t->preferred_draw_unit_id != DRAW_UNIT_ID_VGLITE) { - /* Let the preferred known unit to draw this task. */ - if(t->preferred_draw_unit_id != LV_DRAW_UNIT_NONE) { - return LV_DRAW_UNIT_IDLE; - } - else { - /* Fake unsupported tasks as ready. */ - t->state = LV_DRAW_TASK_STATE_FINISHED; - /* Request a new dispatching as it can get a new task. */ - lv_draw_dispatch_request(); - - return 1; - } - } - vglite_draw_task_t * vglite_task = lv_malloc_zeroed(sizeof(vglite_draw_task_t)); - LV_ASSERT_MALLOC(vglite_task); - - vglite_task->t = t; - - if(lv_draw_layer_alloc_buf(layer) == NULL) - return LV_DRAW_UNIT_IDLE; - t->state = LV_DRAW_TASK_STATE_IN_PROGRESS; - draw_vglite_unit->task_act = vglite_task; - -#if LV_USE_VGLITE_DRAW_THREAD - /* Let the render thread work. */ - if(draw_vglite_unit->inited) - lv_thread_sync_signal(&draw_vglite_unit->sync); -#else - _vglite_execute_drawing(draw_vglite_unit); - - draw_vglite_unit->task_act->t->state = LV_DRAW_TASK_STATE_FINISHED; - _vglite_cleanup_task(draw_vglite_unit->task_act); - draw_vglite_unit->task_act = NULL; - - /* The draw unit is free now. Request a new dispatching as it can get a new task. */ - lv_draw_dispatch_request(); -#endif - - return 1; -} - -#if LV_USE_VGLITE_DRAW_ASYNC -static int32_t _vglite_wait_for_finish(lv_draw_unit_t * draw_unit) -{ - lv_draw_vglite_unit_t * draw_vglite_unit = (lv_draw_vglite_unit_t *) draw_unit; - draw_vglite_unit->wait_for_finish = true; - - /* Signal draw unit to finish its tasks and return READY state after completion. */ - if(draw_vglite_unit->inited) - lv_thread_sync_signal(&draw_vglite_unit->sync); - - /* Wait for finish now. */ - lv_draw_dispatch_wait_for_request(); - - return 1; -} -#endif - -static int32_t _vglite_delete(lv_draw_unit_t * draw_unit) -{ -#if LV_USE_VGLITE_DRAW_THREAD - lv_draw_vglite_unit_t * draw_vglite_unit = (lv_draw_vglite_unit_t *) draw_unit; - - LV_LOG_INFO("Cancel VGLite draw thread."); - draw_vglite_unit->exit_status = true; - - if(draw_vglite_unit->inited) - lv_thread_sync_signal(&draw_vglite_unit->sync); - - lv_result_t res = lv_thread_delete(&draw_vglite_unit->thread); - - return res; -#else - LV_UNUSED(draw_unit); - - return 1; -#endif -} - -static void _vglite_execute_drawing(lv_draw_vglite_unit_t * u) -{ - vglite_draw_task_t * vglite_task = u->task_act; - lv_layer_t * layer = vglite_task->t->target_layer; - lv_draw_buf_t * draw_buf = layer->draw_buf; - - /* Set target buffer */ - vglite_set_dest_buf(draw_buf->data, draw_buf->header.w, draw_buf->header.h, draw_buf->header.stride, - draw_buf->header.cf); - - lv_area_t clip_area; - lv_area_copy(&clip_area, &vglite_task->t->clip_area); - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t draw_area; - lv_area_copy(&draw_area, &vglite_task->t->area); - lv_area_move(&draw_area, -layer->buf_area.x1, -layer->buf_area.y1); - - if(!lv_area_intersect(&draw_area, &draw_area, &clip_area)) - return; /*Fully clipped, nothing to do*/ - - if(_draw_info.unit_cnt > 1) - lv_draw_buf_invalidate_cache(draw_buf, &draw_area); - -#if LV_USE_PARALLEL_DRAW_DEBUG - /* remember draw unit for debug purposes */ - vglite_task->t->draw_unit = &u->base_unit; -#endif - - /* Set scissor area, excluding the split blit case */ -#if LV_USE_VGLITE_BLIT_SPLIT - if(vglite_task->t->type != LV_DRAW_TASK_TYPE_IMAGE || vglite_task->t->type != LV_DRAW_TASK_TYPE_LAYER) -#endif - vglite_set_scissor(&clip_area); - - switch(vglite_task->t->type) { - case LV_DRAW_TASK_TYPE_LABEL: - lv_draw_vglite_label(vglite_task); - break; - case LV_DRAW_TASK_TYPE_FILL: - lv_draw_vglite_fill(vglite_task); - break; - case LV_DRAW_TASK_TYPE_BORDER: - lv_draw_vglite_border(vglite_task); - break; - case LV_DRAW_TASK_TYPE_IMAGE: - lv_draw_vglite_img(vglite_task); - break; - case LV_DRAW_TASK_TYPE_ARC: - lv_draw_vglite_arc(vglite_task); - break; - case LV_DRAW_TASK_TYPE_LINE: - lv_draw_vglite_line(vglite_task); - break; - case LV_DRAW_TASK_TYPE_LAYER: - lv_draw_vglite_layer(vglite_task); - break; - case LV_DRAW_TASK_TYPE_TRIANGLE: - lv_draw_vglite_triangle(vglite_task); - break; - default: - break; - } - - /* Disable scissor */ - vglite_set_scissor(&layer->buf_area); - -#if LV_USE_PARALLEL_DRAW_DEBUG - /*Layers manage it for themselves*/ - if(vglite_task->t->type != LV_DRAW_TASK_TYPE_LAYER) { - lv_area_t draw_area; - if(!lv_area_intersect(&draw_area, &vglite_task->t->area, &vglite_task->t->clip_area)) - return; - - int32_t idx = u->base_unit.idx; - - lv_draw_rect_dsc_t rect_dsc; - lv_draw_rect_dsc_init(&rect_dsc); - rect_dsc.bg_color = lv_palette_main(idx % LV_PALETTE_LAST); - rect_dsc.border_color = rect_dsc.bg_color; - rect_dsc.bg_opa = LV_OPA_10; - rect_dsc.border_opa = LV_OPA_80; - rect_dsc.border_width = 1; - lv_draw_sw_fill(vglite_task->t, &rect_dsc, &draw_area); - - lv_point_t txt_size; - lv_text_get_size(&txt_size, "W", LV_FONT_DEFAULT, 0, 0, 100, LV_TEXT_FLAG_NONE); - - lv_area_t txt_area; - txt_area.x1 = draw_area.x1; - txt_area.y1 = draw_area.y1; - txt_area.x2 = draw_area.x1 + txt_size.x - 1; - txt_area.y2 = draw_area.y1 + txt_size.y - 1; - - lv_draw_rect_dsc_init(&rect_dsc); - rect_dsc.bg_color = lv_color_white(); - lv_draw_sw_fill(vglite_task->t, &rect_dsc, &txt_area); - - char buf[8]; - lv_snprintf(buf, sizeof(buf), "%d", idx); - lv_draw_label_dsc_t label_dsc; - lv_draw_label_dsc_init(&label_dsc); - label_dsc.color = lv_color_black(); - label_dsc.text = buf; - lv_draw_sw_label(vglite_task->t, &label_dsc, &txt_area); - } -#endif -} - -static inline void _vglite_cleanup_task(vglite_draw_task_t * task) -{ - if(task->path != NULL) { - VGLITE_CHECK_ERROR(vg_lite_clear_path(task->path)); - lv_free(task->path); - } - if(task->gradient != NULL) { - VGLITE_CHECK_ERROR(vg_lite_clear_grad(task->gradient)); - lv_free(task->gradient); - } - if(task->path_data != NULL) - lv_free(task->path_data); - - lv_free(task); -} - -#if LV_USE_VGLITE_DRAW_ASYNC -static inline void _vglite_queue_task(vglite_draw_task_t * task) -{ - VGLITE_ASSERT_MSG(((_tail + 1) % VGLITE_TASK_BUF_SIZE) != _head, "VGLite task buffer full."); - - _draw_task_buf[_tail].task = task; - _draw_task_buf[_tail].flushed = false; - _tail = (_tail + 1) % VGLITE_TASK_BUF_SIZE; -} - -static inline void _vglite_signal_task_ready(vglite_draw_task_t * task) -{ - /* Signal the ready state to dispatcher. */ - task->t->state = LV_DRAW_TASK_STATE_FINISHED; - _head = (_head + 1) % VGLITE_TASK_BUF_SIZE; - - _vglite_cleanup_task(task); - /* No need to cleanup the tasks in buffer as we advance with the _head. */ -} - -static inline void _vglite_signal_all_task_ready(void) -{ - int end = (_head <= _tail) ? _tail : _tail + VGLITE_TASK_BUF_SIZE; - - for(int i = _head; i < end; i++) { - vglite_draw_task_t * task = _draw_task_buf[i % VGLITE_TASK_BUF_SIZE].task; - - _vglite_signal_task_ready(task); - } -} - -static inline void _vglite_signal_flushed_task_ready(void) -{ - if(vglite_cmd_buf_is_flushed()) { - int end = (_head <= _tail) ? _tail : _tail + VGLITE_TASK_BUF_SIZE; - - for(int i = _head; i < end; i++) { - if(_draw_task_buf[i % VGLITE_TASK_BUF_SIZE].flushed) { - vglite_draw_task_t * task = _draw_task_buf[i % VGLITE_TASK_BUF_SIZE].task; - - _vglite_signal_task_ready(task); - - } - else { - /* Those tasks have been flushed now. */ - _draw_task_buf[i % VGLITE_TASK_BUF_SIZE].flushed = true; - } - } - } -} -#endif - -#if LV_USE_VGLITE_DRAW_THREAD -static void _vglite_render_thread_cb(void * ptr) -{ - lv_draw_vglite_unit_t * u = ptr; - - lv_thread_sync_init(&u->sync); - u->inited = true; - - while(1) { - /* Wait for sync if there is no task set. */ - while(u->task_act == NULL -#if LV_USE_VGLITE_DRAW_ASYNC - /* - * Wait for sync if wait_for_finish is triggered. - * The thread will have to run and mark as complete any pending tasks. - */ - && !u->wait_for_finish -#endif - ) { - if(u->exit_status) - break; - - lv_thread_sync_wait(&u->sync); - } - - if(u->exit_status) { - LV_LOG_INFO("Ready to exit VGLite draw thread."); - break; - } - - if(u->task_act) { -#if LV_USE_VGLITE_DRAW_ASYNC - _vglite_queue_task((void *)u->task_act); -#endif - _vglite_execute_drawing(u); - } -#if LV_USE_VGLITE_DRAW_ASYNC - if(u->wait_for_finish) { - vglite_wait_for_finish(); - _vglite_signal_all_task_ready(); - } - else { /* u->task_act */ - _vglite_signal_flushed_task_ready(); - } -#else - /* Signal the ready state to dispatcher. */ - u->task_act->t->state = LV_DRAW_TASK_STATE_FINISHED; - _vglite_cleanup_task(u->task_act); -#endif - - /* Cleanup draw unit running condition. */ -#if LV_USE_VGLITE_DRAW_ASYNC - if(u->wait_for_finish) - u->wait_for_finish = false; - else - u->task_act = NULL; -#else - u->task_act = NULL; -#endif - - /* The draw unit is free now. Request a new dispatching as it can get a new task. */ - lv_draw_dispatch_request(); - } - - u->inited = false; - lv_thread_sync_delete(&u->sync); - LV_LOG_INFO("Exit VGLite draw thread."); -} -#endif - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite.h b/src/draw/nxp/vglite/lv_draw_vglite.h deleted file mode 100644 index 61dd1cd0d5..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file lv_draw_vglite.h - * - */ - -/** - * Copyright 2023-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -#ifndef LV_DRAW_VGLITE_H -#define LV_DRAW_VGLITE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ - -#include "../../../lv_conf_internal.h" - -#if LV_USE_DRAW_VGLITE -#include "../../lv_draw_private.h" -#include "../../../display/lv_display_private.h" -#include "../../../misc/lv_area_private.h" - -#include "../../lv_draw_triangle.h" -#include "../../lv_draw_label.h" -#include "../../lv_draw_image.h" -#include "../../lv_draw_line.h" -#include "../../lv_draw_arc.h" -#include "vg_lite.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -typedef struct vglite_draw_task { - lv_draw_task_t * t; - vg_lite_path_t * path; - vg_lite_linear_gradient_t * gradient; - int32_t * path_data; -} vglite_draw_task_t; - -typedef struct lv_draw_vglite_unit { - lv_draw_unit_t base_unit; - vglite_draw_task_t * task_act; -#if LV_USE_OS - lv_thread_sync_t sync; - lv_thread_t thread; - volatile bool inited; - volatile bool exit_status; -#endif -#if LV_USE_VGLITE_DRAW_ASYNC - volatile bool wait_for_finish; -#endif -} lv_draw_vglite_unit_t; - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -void lv_draw_buf_vglite_init_handlers(void); - -void lv_draw_vglite_init(void); - -void lv_draw_vglite_deinit(void); - -void lv_draw_vglite_arc(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_border(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_fill(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_img(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_label(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_layer(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_line(vglite_draw_task_t * vglite_task); - -void lv_draw_vglite_triangle(vglite_draw_task_t * vglite_task); - -/********************** - * MACROS - **********************/ -#endif /*LV_USE_DRAW_VGLITE*/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_DRAW_VGLITE_H*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_arc.c b/src/draw/nxp/vglite/lv_draw_vglite_arc.c deleted file mode 100644 index cbd2808a32..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_arc.c +++ /dev/null @@ -1,684 +0,0 @@ -/** - * @file lv_draw_vglite_arc.c - * - */ - -/** - * Copyright 2021-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_path.h" -#include "lv_vglite_utils.h" - -#include "../../../stdlib/lv_string.h" -#include - -/********************* - * DEFINES - *********************/ - -#define T_FRACTION 16384.0f - -#define DICHOTO_ITER 5 - -static const uint16_t TperDegree[90] = { - 0, 174, 348, 522, 697, 873, 1049, 1226, 1403, 1581, - 1759, 1938, 2117, 2297, 2477, 2658, 2839, 3020, 3202, 3384, - 3567, 3749, 3933, 4116, 4300, 4484, 4668, 4852, 5037, 5222, - 5407, 5592, 5777, 5962, 6148, 6334, 6519, 6705, 6891, 7077, - 7264, 7450, 7636, 7822, 8008, 8193, 8378, 8564, 8750, 8936, - 9122, 9309, 9495, 9681, 9867, 10052, 10238, 10424, 10609, 10794, - 10979, 11164, 11349, 11534, 11718, 11902, 12086, 12270, 12453, 12637, - 12819, 13002, 13184, 13366, 13547, 13728, 13909, 14089, 14269, 14448, - 14627, 14805, 14983, 15160, 15337, 15513, 15689, 15864, 16038, 16212 -}; - -/********************** - * TYPEDEFS - **********************/ - -/* intermediate arc params */ -typedef struct _vg_arc { - uint32_t angle; /* angle <90deg */ - int32_t quarter; /* 0-3 counter-clockwise */ - int32_t rad; /* radius */ - int32_t p0x; /* point P0 */ - int32_t p0y; - int32_t p1x; /* point P1 */ - int32_t p1y; - int32_t p2x; /* point P2 */ - int32_t p2y; - int32_t p3x; /* point P3 */ - int32_t p3y; -} vg_arc; - -typedef struct _cubic_cont_pt { - float p0; - float p1; - float p2; - float p3; -} cubic_cont_pt; - -/********************** - * STATIC PROTOTYPES - **********************/ - -/** - * Draw arc shape with effects - * - * @param[in] center Arc center with relative coordinates - * @param[in] clip_area Clip area with relative coordinates to dest buff - * @param[in] dsc Arc description structure (width, rounded ending, opacity) - * - */ -static void _vglite_draw_arc(vglite_draw_task_t * vglite_task, const lv_point_t * center, - const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_arc(vglite_draw_task_t * vglite_task) -{ - lv_draw_task_t * t = vglite_task->t; - const lv_draw_arc_dsc_t * dsc = t->draw_dsc; - - if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) - return; - if(dsc->width == 0) - return; - if(dsc->start_angle == dsc->end_angle) - return; - - lv_layer_t * layer = t->target_layer; - lv_point_t center = {dsc->center.x - layer->buf_area.x1, dsc->center.y - layer->buf_area.y1}; - - lv_area_t clip_area; - lv_area_copy(&clip_area, &t->clip_area); - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - _vglite_draw_arc(vglite_task, ¢er, &clip_area, dsc); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _copy_arc(vg_arc * dst, vg_arc * src) -{ - dst->quarter = src->quarter; - dst->rad = src->rad; - dst->angle = src->angle; - dst->p0x = src->p0x; - dst->p1x = src->p1x; - dst->p2x = src->p2x; - dst->p3x = src->p3x; - dst->p0y = src->p0y; - dst->p1y = src->p1y; - dst->p2y = src->p2y; - dst->p3y = src->p3y; -} - -/** - * Rotate the point according given rotation angle rotation center is 0,0 - */ -static void _rotate_point(int16_t angle, int32_t * x, int32_t * y) -{ - int32_t ori_x = *x; - int32_t ori_y = *y; - int16_t alpha = angle; - *x = ((lv_trigo_cos(alpha) * ori_x) / LV_TRIGO_SIN_MAX) - ((lv_trigo_sin(alpha) * ori_y) / LV_TRIGO_SIN_MAX); - *y = ((lv_trigo_sin(alpha) * ori_x) / LV_TRIGO_SIN_MAX) + ((lv_trigo_cos(alpha) * ori_y) / LV_TRIGO_SIN_MAX); -} - -/** - * Set full arc control points depending on quarter. - * Control points match the best approximation of a circle. - * Arc Quarter position is: - * Q2 | Q3 - * ---+--- - * Q1 | Q0 - */ -static void _set_full_arc(vg_arc * fullarc) -{ - /* the tangent length for the bezier circle approx */ - float tang = ((float)fullarc->rad) * BEZIER_OPTIM_CIRCLE; - switch(fullarc->quarter) { - case 0: - /* first quarter */ - fullarc->p0x = fullarc->rad; - fullarc->p0y = 0; - fullarc->p1x = fullarc->rad; - fullarc->p1y = (int32_t)tang; - fullarc->p2x = (int32_t)tang; - fullarc->p2y = fullarc->rad; - fullarc->p3x = 0; - fullarc->p3y = fullarc->rad; - break; - case 1: - /* second quarter */ - fullarc->p0x = 0; - fullarc->p0y = fullarc->rad; - fullarc->p1x = 0 - (int32_t)tang; - fullarc->p1y = fullarc->rad; - fullarc->p2x = 0 - fullarc->rad; - fullarc->p2y = (int32_t)tang; - fullarc->p3x = 0 - fullarc->rad; - fullarc->p3y = 0; - break; - case 2: - /* third quarter */ - fullarc->p0x = 0 - fullarc->rad; - fullarc->p0y = 0; - fullarc->p1x = 0 - fullarc->rad; - fullarc->p1y = 0 - (int32_t)tang; - fullarc->p2x = 0 - (int32_t)tang; - fullarc->p2y = 0 - fullarc->rad; - fullarc->p3x = 0; - fullarc->p3y = 0 - fullarc->rad; - break; - case 3: - /* fourth quarter */ - fullarc->p0x = 0; - fullarc->p0y = 0 - fullarc->rad; - fullarc->p1x = (int32_t)tang; - fullarc->p1y = 0 - fullarc->rad; - fullarc->p2x = fullarc->rad; - fullarc->p2y = 0 - (int32_t)tang; - fullarc->p3x = fullarc->rad; - fullarc->p3y = 0; - break; - default: - VGLITE_ASSERT_MSG(false, "Invalid arc quarter."); - break; - } -} - -/** - * Linear interpolation between two points 'a' and 'b' - * 't' parameter is the proportion ratio expressed in range [0 ; T_FRACTION ] - */ -static inline float _lerp(float coord_a, float coord_b, uint16_t t) -{ - float tf = (float)t; - return ((T_FRACTION - tf) * coord_a + tf * coord_b) / T_FRACTION; -} - -/** - * Computes a point of bezier curve given 't' param - */ -static inline float _comp_bezier_point(float t, cubic_cont_pt cp) -{ - float t_sq = t * t; - float inv_t_sq = (1.0f - t) * (1.0f - t); - float apt = (1.0f - t) * inv_t_sq * cp.p0 + 3.0f * inv_t_sq * t * cp.p1 + 3.0f * (1.0f - t) * t_sq * cp.p2 + t * t_sq * - cp.p3; - return apt; -} - -/** - * Find parameter 't' in curve at point 'pt' - * proceed by dichotomy on only 1 dimension, - * works only if the curve is monotonic - * bezier curve is defined by control points [p0 p1 p2 p3] - * 'dec' tells if curve is decreasing (true) or increasing (false) - */ -static uint16_t _get_bez_t_from_pos(float pt, cubic_cont_pt cp, bool dec) -{ - /* initialize dichotomy with boundary 't' values */ - float t_low = 0.0f; - float t_mid = 0.5f; - float t_hig = 1.0f; - float a_pt; - /* dichotomy loop */ - for(int i = 0; i < DICHOTO_ITER; i++) { - a_pt = _comp_bezier_point(t_mid, cp); - /* check mid-point position on bezier curve versus targeted point */ - if((a_pt > pt) != dec) { - t_hig = t_mid; - } - else { - t_low = t_mid; - } - /* define new 't' param for mid-point */ - t_mid = (t_low + t_hig) / 2.0f; - } - /* return parameter 't' in integer range [0 ; T_FRACTION] */ - return (uint16_t)floorf(t_mid * T_FRACTION + 0.5f); -} - -/** - * Gives relative coords of the control points - * for the sub-arc starting at angle with given angle span - */ -static void _get_subarc_control_points(vg_arc * arc, uint32_t span) -{ - vg_arc fullarc = {0}; - fullarc.angle = arc->angle; - fullarc.quarter = arc->quarter; - fullarc.rad = arc->rad; - _set_full_arc(&fullarc); - - /* special case of full arc */ - if(arc->angle == 90) { - _copy_arc(arc, &fullarc); - return; - } - - /* compute 1st arc using the geometric construction of curve */ - uint16_t t2 = TperDegree[arc->angle + span]; - - /* lerp for A */ - float a2x = _lerp((float)fullarc.p0x, (float)fullarc.p1x, t2); - float a2y = _lerp((float)fullarc.p0y, (float)fullarc.p1y, t2); - /* lerp for B */ - float b2x = _lerp((float)fullarc.p1x, (float)fullarc.p2x, t2); - float b2y = _lerp((float)fullarc.p1y, (float)fullarc.p2y, t2); - /* lerp for C */ - float c2x = _lerp((float)fullarc.p2x, (float)fullarc.p3x, t2); - float c2y = _lerp((float)fullarc.p2y, (float)fullarc.p3y, t2); - - /* lerp for D */ - float d2x = _lerp(a2x, b2x, t2); - float d2y = _lerp(a2y, b2y, t2); - /* lerp for E */ - float e2x = _lerp(b2x, c2x, t2); - float e2y = _lerp(b2y, c2y, t2); - - float pt2x = _lerp(d2x, e2x, t2); - float pt2y = _lerp(d2y, e2y, t2); - - /* compute sub-arc using the geometric construction of curve */ - uint16_t t1 = TperDegree[arc->angle]; - - /* lerp for A */ - float a1x = _lerp((float)fullarc.p0x, (float)fullarc.p1x, t1); - float a1y = _lerp((float)fullarc.p0y, (float)fullarc.p1y, t1); - /* lerp for B */ - float b1x = _lerp((float)fullarc.p1x, (float)fullarc.p2x, t1); - float b1y = _lerp((float)fullarc.p1y, (float)fullarc.p2y, t1); - /* lerp for C */ - float c1x = _lerp((float)fullarc.p2x, (float)fullarc.p3x, t1); - float c1y = _lerp((float)fullarc.p2y, (float)fullarc.p3y, t1); - - /* lerp for D */ - float d1x = _lerp(a1x, b1x, t1); - float d1y = _lerp(a1y, b1y, t1); - /* lerp for E */ - float e1x = _lerp(b1x, c1x, t1); - float e1y = _lerp(b1y, c1y, t1); - - float pt1x = _lerp(d1x, e1x, t1); - float pt1y = _lerp(d1y, e1y, t1); - - /* find the 't3' parameter for point P(t1) on the sub-arc [P0 A2 D2 P(t2)] using dichotomy - * use position of x axis only */ - uint16_t t3; - t3 = _get_bez_t_from_pos(pt1x, - (cubic_cont_pt) { - .p0 = ((float)fullarc.p0x), .p1 = a2x, .p2 = d2x, .p3 = pt2x - }, - (bool)(pt2x < (float)fullarc.p0x)); - - /* lerp for B */ - float b3x = _lerp(a2x, d2x, t3); - float b3y = _lerp(a2y, d2y, t3); - /* lerp for C */ - float c3x = _lerp(d2x, pt2x, t3); - float c3y = _lerp(d2y, pt2y, t3); - - /* lerp for E */ - float e3x = _lerp(b3x, c3x, t3); - float e3y = _lerp(b3y, c3y, t3); - - arc->p0x = (int32_t)floorf(0.5f + pt1x); - arc->p0y = (int32_t)floorf(0.5f + pt1y); - arc->p1x = (int32_t)floorf(0.5f + e3x); - arc->p1y = (int32_t)floorf(0.5f + e3y); - arc->p2x = (int32_t)floorf(0.5f + c3x); - arc->p2y = (int32_t)floorf(0.5f + c3y); - arc->p3x = (int32_t)floorf(0.5f + pt2x); - arc->p3y = (int32_t)floorf(0.5f + pt2y); -} - -/** - * Gives relative coords of the control points - */ -static void _get_arc_control_points(vg_arc * arc, bool start) -{ - vg_arc fullarc = {0}; - fullarc.angle = arc->angle; - fullarc.quarter = arc->quarter; - fullarc.rad = arc->rad; - _set_full_arc(&fullarc); - - /* special case of full arc */ - if(arc->angle == 90) { - _copy_arc(arc, &fullarc); - return; - } - - /* compute sub-arc using the geometric construction of curve */ - uint16_t t = TperDegree[arc->angle]; - /* lerp for A */ - float ax = _lerp((float)fullarc.p0x, (float)fullarc.p1x, t); - float ay = _lerp((float)fullarc.p0y, (float)fullarc.p1y, t); - /* lerp for B */ - float bx = _lerp((float)fullarc.p1x, (float)fullarc.p2x, t); - float by = _lerp((float)fullarc.p1y, (float)fullarc.p2y, t); - /* lerp for C */ - float cx = _lerp((float)fullarc.p2x, (float)fullarc.p3x, t); - float cy = _lerp((float)fullarc.p2y, (float)fullarc.p3y, t); - - /* lerp for D */ - float dx = _lerp(ax, bx, t); - float dy = _lerp(ay, by, t); - /* lerp for E */ - float ex = _lerp(bx, cx, t); - float ey = _lerp(by, cy, t); - - /* sub-arc's control points are tangents of DeCasteljau's algorithm */ - if(start) { - arc->p0x = (int32_t)floorf(0.5f + _lerp(dx, ex, t)); - arc->p0y = (int32_t)floorf(0.5f + _lerp(dy, ey, t)); - arc->p1x = (int32_t)floorf(0.5f + ex); - arc->p1y = (int32_t)floorf(0.5f + ey); - arc->p2x = (int32_t)floorf(0.5f + cx); - arc->p2y = (int32_t)floorf(0.5f + cy); - arc->p3x = fullarc.p3x; - arc->p3y = fullarc.p3y; - } - else { - arc->p0x = fullarc.p0x; - arc->p0y = fullarc.p0y; - arc->p1x = (int32_t)floorf(0.5f + ax); - arc->p1y = (int32_t)floorf(0.5f + ay); - arc->p2x = (int32_t)floorf(0.5f + dx); - arc->p2y = (int32_t)floorf(0.5f + dy); - arc->p3x = (int32_t)floorf(0.5f + _lerp(dx, ex, t)); - arc->p3y = (int32_t)floorf(0.5f + _lerp(dy, ey, t)); - } -} - -/** - * Add the arc control points into the path data for vglite, - * taking into account the real center of the arc (translation). - * arc_path: (in/out) the path data array for vglite - * pidx: (in/out) index of last element added in arc_path - * q_arc: (in) the arc data containing control points - * center: (in) the center of the circle in draw coordinates - * cw: (in) true if arc is clockwise - */ -static void _add_split_arc_path(int32_t * arc_path, uint32_t * pidx, vg_arc * q_arc, const lv_point_t * center, bool cw) -{ - /* assumes first control point already in array arc_path[] */ - uint32_t idx = *pidx; - if(cw) { -#if BEZIER_DBG_CONTROL_POINTS - arc_path[idx++] = VLC_OP_LINE; - arc_path[idx++] = q_arc->p1x + center->x; - arc_path[idx++] = q_arc->p1y + center->y; - arc_path[idx++] = VLC_OP_LINE; - arc_path[idx++] = q_arc->p2x + center->x; - arc_path[idx++] = q_arc->p2y + center->y; - arc_path[idx++] = VLC_OP_LINE; - arc_path[idx++] = q_arc->p3x + center->x; - arc_path[idx++] = q_arc->p3y + center->y; -#else - arc_path[idx++] = VLC_OP_CUBIC; - arc_path[idx++] = q_arc->p1x + center->x; - arc_path[idx++] = q_arc->p1y + center->y; - arc_path[idx++] = q_arc->p2x + center->x; - arc_path[idx++] = q_arc->p2y + center->y; - arc_path[idx++] = q_arc->p3x + center->x; - arc_path[idx++] = q_arc->p3y + center->y; -#endif - } - else { /* reverse points order when counter-clockwise */ -#if BEZIER_DBG_CONTROL_POINTS - arc_path[idx++] = VLC_OP_LINE; - arc_path[idx++] = q_arc->p2x + center->x; - arc_path[idx++] = q_arc->p2y + center->y; - arc_path[idx++] = VLC_OP_LINE; - arc_path[idx++] = q_arc->p1x + center->x; - arc_path[idx++] = q_arc->p1y + center->y; - arc_path[idx++] = VLC_OP_LINE; - arc_path[idx++] = q_arc->p0x + center->x; - arc_path[idx++] = q_arc->p0y + center->y; -#else - arc_path[idx++] = VLC_OP_CUBIC; - arc_path[idx++] = q_arc->p2x + center->x; - arc_path[idx++] = q_arc->p2y + center->y; - arc_path[idx++] = q_arc->p1x + center->x; - arc_path[idx++] = q_arc->p1y + center->y; - arc_path[idx++] = q_arc->p0x + center->x; - arc_path[idx++] = q_arc->p0y + center->y; -#endif - } - /* update index i n path array*/ - *pidx = idx; -} - -static void _add_arc_path(int32_t * arc_path, uint32_t * pidx, uint32_t radius, - int32_t start_angle, int32_t end_angle, const lv_point_t * center, bool cw) -{ - /* set number of arcs to draw */ - vg_arc q_arc; - int32_t start_arc_angle = start_angle % 90; - int32_t end_arc_angle = end_angle % 90; - int32_t inv_start_arc_angle = (start_arc_angle > 0) ? (90 - start_arc_angle) : 0; - int32_t nbarc = (end_angle - start_angle - inv_start_arc_angle - end_arc_angle) / 90; - q_arc.rad = radius; - - /* handle special case of start & end point in the same quarter */ - if(((start_angle / 90) == (end_angle / 90)) && (nbarc <= 0)) { - q_arc.quarter = (start_angle / 90) % 4; - q_arc.angle = start_arc_angle; - _get_subarc_control_points(&q_arc, end_arc_angle - start_arc_angle); - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - return; - } - - if(cw) { - /* partial starting arc */ - if(start_arc_angle > 0) { - q_arc.quarter = (start_angle / 90) % 4; - q_arc.angle = start_arc_angle; - /* get cubic points relative to center */ - _get_arc_control_points(&q_arc, true); - /* put cubic points in arc_path */ - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - } - /* full arcs */ - for(uint32_t q = 0; q < nbarc ; q++) { - q_arc.quarter = (q + ((start_angle + 89) / 90)) % 4; - q_arc.angle = 90; - /* get cubic points relative to center */ - _get_arc_control_points(&q_arc, true); /* 2nd parameter 'start' ignored */ - /* put cubic points in arc_path */ - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - } - /* partial ending arc */ - if(end_arc_angle > 0) { - q_arc.quarter = (end_angle / 90) % 4; - q_arc.angle = end_arc_angle; - /* get cubic points relative to center */ - _get_arc_control_points(&q_arc, false); - /* put cubic points in arc_path */ - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - } - - } - else { /* counter clockwise */ - - /* partial ending arc */ - if(end_arc_angle > 0) { - q_arc.quarter = (end_angle / 90) % 4; - q_arc.angle = end_arc_angle; - /* get cubic points relative to center */ - _get_arc_control_points(&q_arc, false); - /* put cubic points in arc_path */ - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - } - /* full arcs */ - for(int32_t q = nbarc - 1; q >= 0; q--) { - q_arc.quarter = (q + ((start_angle + 89) / 90)) % 4; - q_arc.angle = 90; - /* get cubic points relative to center */ - _get_arc_control_points(&q_arc, true); /* 2nd parameter 'start' ignored */ - /* put cubic points in arc_path */ - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - } - /* partial starting arc */ - if(start_arc_angle > 0) { - q_arc.quarter = (start_angle / 90) % 4; - q_arc.angle = start_arc_angle; - /* get cubic points relative to center */ - _get_arc_control_points(&q_arc, true); - /* put cubic points in arc_path */ - _add_split_arc_path(arc_path, pidx, &q_arc, center, cw); - } - } -} - -static void _vglite_draw_arc(vglite_draw_task_t * vglite_task, const lv_point_t * center, - const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc) -{ - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - int16_t start_angle = dsc->start_angle; - int16_t end_angle = dsc->end_angle; - - /* be sure end_angle > start_angle */ - if(end_angle < start_angle) - end_angle += 360; - - bool donut = ((end_angle - start_angle) % 360 == 0) ? true : false; - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - - int32_t * arc_path = lv_malloc_zeroed(ARC_PATH_DATA_MAX_SIZE * sizeof(int32_t)); - LV_ASSERT_MALLOC(arc_path); - vglite_task->path_data = arc_path; - - /*** Init path ***/ - int32_t width = dsc->width; /* inner arc radius = outer arc radius - width */ - uint16_t radius = dsc->radius; - - if(width > radius) - width = radius; - - uint32_t pidx = 0; - int32_t cp_x, cp_y; /* control point coords */ - - /* first control point of curve */ - cp_x = radius; - cp_y = 0; - _rotate_point(start_angle, &cp_x, &cp_y); - arc_path[pidx++] = VLC_OP_MOVE; - arc_path[pidx++] = center->x + cp_x; - arc_path[pidx++] = center->y + cp_y; - - /* draw 1-5 outer quarters */ - _add_arc_path(arc_path, &pidx, radius, start_angle, end_angle, center, true); - - if(donut) { - /* close outer circle */ - cp_x = radius; - cp_y = 0; - _rotate_point(start_angle, &cp_x, &cp_y); - arc_path[pidx++] = VLC_OP_LINE; - arc_path[pidx++] = center->x + cp_x; - arc_path[pidx++] = center->y + cp_y; - /* start inner circle */ - cp_x = radius - width; - cp_y = 0; - _rotate_point(start_angle, &cp_x, &cp_y); - arc_path[pidx++] = VLC_OP_MOVE; - arc_path[pidx++] = center->x + cp_x; - arc_path[pidx++] = center->y + cp_y; - - } - else if(dsc->rounded != 0U) { /* 1st rounded arc ending */ - cp_x = radius - width / 2; - cp_y = 0; - _rotate_point(end_angle, &cp_x, &cp_y); - lv_point_t round_center = {center->x + cp_x, center->y + cp_y}; - _add_arc_path(arc_path, &pidx, width / 2, end_angle, (end_angle + 180), - &round_center, true); - - } - else { /* 1st flat ending */ - cp_x = radius - width; - cp_y = 0; - _rotate_point(end_angle, &cp_x, &cp_y); - arc_path[pidx++] = VLC_OP_LINE; - arc_path[pidx++] = center->x + cp_x; - arc_path[pidx++] = center->y + cp_y; - } - - /* draw 1-5 inner quarters */ - _add_arc_path(arc_path, &pidx, radius - width, start_angle, end_angle, center, false); - - /* last control point of curve */ - if(donut) { /* close the loop */ - cp_x = radius - width; - cp_y = 0; - _rotate_point(start_angle, &cp_x, &cp_y); - arc_path[pidx++] = VLC_OP_LINE; - arc_path[pidx++] = center->x + cp_x; - arc_path[pidx++] = center->y + cp_y; - - } - else if(dsc->rounded != 0U) { /* 2nd rounded arc ending */ - cp_x = radius - width / 2; - cp_y = 0; - _rotate_point(start_angle, &cp_x, &cp_y); - lv_point_t round_center = {center->x + cp_x, center->y + cp_y}; - _add_arc_path(arc_path, &pidx, width / 2, (start_angle + 180), (start_angle + 360), - &round_center, true); - - } - else { /* 2nd flat ending */ - cp_x = radius; - cp_y = 0; - _rotate_point(start_angle, &cp_x, &cp_y); - arc_path[pidx++] = VLC_OP_LINE; - arc_path[pidx++] = center->x + cp_x; - arc_path[pidx++] = center->y + cp_y; - } - - arc_path[pidx++] = VLC_OP_END; - - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, VG_LITE_HIGH, (uint32_t)pidx * sizeof(int32_t), arc_path, - (vg_lite_float_t)clip_area->x1, (vg_lite_float_t)clip_area->y1, - ((vg_lite_float_t)clip_area->x2) + 1.0f, ((vg_lite_float_t)clip_area->y2) + 1.0f)); - - lv_color32_t col32 = lv_color_to_32(dsc->color, dsc->opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - /*** Draw arc ***/ - VGLITE_CHECK_ERROR(vg_lite_draw(dest_buf, path, VG_LITE_FILL_NON_ZERO, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - - vglite_run(); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_border.c b/src/draw/nxp/vglite/lv_draw_vglite_border.c deleted file mode 100644 index c04c9926cf..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_border.c +++ /dev/null @@ -1,248 +0,0 @@ -/** - * @file lv_draw_vglite_border.c - * - */ - -/** - * Copyright 2022-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_path.h" -#include "lv_vglite_utils.h" - -#include - -/********************* - * DEFINES - *********************/ - -/********************* - * DEFINES - *********************/ - -/*** Define maximum numbers of rectangles needed to clip partial borders ***/ -#define MAX_NUM_RECTANGLES 4 - -/********************** - * TYPEDEFS - **********************/ - -typedef struct scissoring_rects { - vg_lite_rectangle_t rect[MAX_NUM_RECTANGLES]; - uint32_t num_rect; -} scissoring_rects_t ; - -/********************** - * STATIC PROTOTYPES - **********************/ - -/** - * Draw rectangle border/outline shape with effects (rounded corners, opacity) - * - * @param[in] coords Coordinates of the rectangle border/outline (relative to dest buff) - * @param[in] clip_area Clip area with relative coordinates to dest buff - * @param[in] dsc Description of the rectangle border/outline - * - */ -static void _vglite_draw_border(vglite_draw_task_t * task, const lv_area_t * coords, - const lv_area_t * clip_area, const lv_draw_border_dsc_t * dsc); - -/** - * Create scissor area based on the border side - * - * @param[in] coords Coordinates of the rectangle border/outline (relative to dest buff) - * @param[in] line_width Width of the line - * @param[in] border_side Sides of the border - * @param[in] radius Radius of the border - * @param[out] scissoring_rects Struct that contains the array of scissors - * - */ - -static void _border_set_scissoring(const lv_area_t * coords, int32_t line_width, - uint32_t border_side, int32_t radius, - scissoring_rects_t * scissoring_rects); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_border(vglite_draw_task_t * vglite_task) -{ - const lv_draw_border_dsc_t * dsc = vglite_task->t->draw_dsc; - const lv_area_t * coords = &vglite_task->t->area; - - if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) - return; - if(dsc->width == 0) - return; - if(dsc->side == (lv_border_side_t)LV_BORDER_SIDE_NONE) - return; - - lv_layer_t * layer = vglite_task->t->target_layer; - lv_area_t inward_coords; - int32_t width = dsc->width; - - /* Move border inwards to align with software rendered border */ - inward_coords.x1 = coords->x1 + ceil(width / 2.0f); - inward_coords.x2 = coords->x2 - floor(width / 2.0f); - inward_coords.y1 = coords->y1 + ceil(width / 2.0f); - inward_coords.y2 = coords->y2 - floor(width / 2.0f); - - lv_area_move(&inward_coords, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t clip_area; - lv_area_copy(&clip_area, &vglite_task->t->clip_area); - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t clipped_coords; - if(!lv_area_intersect(&clipped_coords, &inward_coords, &clip_area)) - return; /*Fully clipped, nothing to do*/ - - _vglite_draw_border(vglite_task, &inward_coords, &clip_area, dsc); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _border_set_scissoring(const lv_area_t * coords, int32_t line_width, - uint32_t border_side, int32_t radius, - scissoring_rects_t * scissoring_rects) -{ - int32_t rect_width = coords->x2 - coords->x1; - int32_t rect_height = coords->y2 - coords->y1; - int32_t shortest_side = LV_MIN(rect_width, rect_height); - int32_t final_radius = LV_MIN(radius, shortest_side / 2); - - if(border_side & LV_BORDER_SIDE_TOP) { - scissoring_rects->rect[scissoring_rects->num_rect].x = coords->x1 - ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].y = coords->y1 - ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].width = coords->x2 - coords->x1 + line_width; - scissoring_rects->rect[scissoring_rects->num_rect].height = final_radius + ceil(line_width / 2.0f); - scissoring_rects->num_rect++; - } - - if(border_side & LV_BORDER_SIDE_LEFT) { - scissoring_rects->rect[scissoring_rects->num_rect].x = coords->x1 - ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].y = coords->y1 - ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].width = final_radius + ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].height = coords->y2 - coords->y1 + line_width + 1; - scissoring_rects->num_rect++; - } - - if(border_side & LV_BORDER_SIDE_RIGHT) { - scissoring_rects->rect[scissoring_rects->num_rect].x = coords->x2 - final_radius + 1; - scissoring_rects->rect[scissoring_rects->num_rect].y = coords->y1 - ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].width = final_radius + ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].height = coords->y2 - coords->y1 + line_width + 1; - scissoring_rects->num_rect++; - } - - if(border_side & LV_BORDER_SIDE_BOTTOM) { - scissoring_rects->rect[scissoring_rects->num_rect].x = coords->x1 - ceil(line_width / 2.0f); - scissoring_rects->rect[scissoring_rects->num_rect].y = coords->y2 - final_radius + 1; - scissoring_rects->rect[scissoring_rects->num_rect].width = coords->x2 - coords->x1 + line_width; - scissoring_rects->rect[scissoring_rects->num_rect].height = final_radius + ceil(line_width / 2.0f); - scissoring_rects->num_rect++; - } -} - -static void _vglite_draw_border(vglite_draw_task_t * vglite_task, const lv_area_t * coords, - const lv_area_t * clip_area, const lv_draw_border_dsc_t * dsc) -{ - int32_t radius = dsc->radius; - vg_lite_buffer_t * buf = vglite_get_dest_buf(); - - if(radius < 0) - return; - - int32_t border_half = (int32_t)floor(dsc->width / 2.0f); - if(radius > border_half) - radius = radius - border_half; - - vg_lite_cap_style_t cap_style = (radius) ? VG_LITE_CAP_ROUND : VG_LITE_CAP_BUTT; - vg_lite_join_style_t join_style = (radius) ? VG_LITE_JOIN_ROUND : VG_LITE_JOIN_MITER; - - /*** Init path ***/ - int32_t * path_data = lv_malloc_zeroed(RECT_PATH_DATA_MAX_SIZE * sizeof(int32_t)); - LV_ASSERT_MALLOC(path_data); - vglite_task->path_data = path_data; - - uint32_t path_data_size; - vglite_create_rect_path_data(path_data, &path_data_size, radius, coords); - vg_lite_quality_t path_quality = radius > 0 ? VG_LITE_HIGH : VG_LITE_MEDIUM; - - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, path_quality, path_data_size, path_data, - (vg_lite_float_t)clip_area->x1, (vg_lite_float_t)clip_area->y1, - ((vg_lite_float_t)clip_area->x2) + 1.0f, ((vg_lite_float_t)clip_area->y2) + 1.0f)); - - lv_color32_t col32 = lv_color_to_32(dsc->color, dsc->opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - int32_t line_width = dsc->width; - lv_border_side_t border_side = dsc->side; - - scissoring_rects_t scissoring_rects; - scissoring_rects.num_rect = 0; - - bool has_vg_mask_feat = vg_lite_query_feature(gcFEATURE_BIT_VG_MASK); - - VGLITE_CHECK_ERROR(vg_lite_set_draw_path_type(path, VG_LITE_DRAW_STROKE_PATH)); - - VGLITE_CHECK_ERROR(vg_lite_set_stroke(path, cap_style, join_style, line_width, 8, NULL, 0, 0, vgcol)); - - VGLITE_CHECK_ERROR(vg_lite_update_stroke(path)); - - if(border_side != LV_BORDER_SIDE_FULL) { - _border_set_scissoring(coords, line_width, border_side, radius, &scissoring_rects); - - if(has_vg_mask_feat) { - /*** Enable scissor and apply scissor rects ***/ - VGLITE_CHECK_ERROR(vg_lite_enable_scissor()); - VGLITE_CHECK_ERROR(vg_lite_scissor_rects(buf, scissoring_rects.num_rect, scissoring_rects.rect)); - - /*** Draw border ***/ - VGLITE_CHECK_ERROR(vg_lite_draw(buf, path, VG_LITE_FILL_NON_ZERO, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - - /*** Disable scissor ***/ - VGLITE_CHECK_ERROR(vg_lite_disable_scissor()); - } - else { - for(uint32_t i = 0; i < scissoring_rects.num_rect; i++) { - VGLITE_CHECK_ERROR(vg_lite_set_scissor(scissoring_rects.rect[i].x, scissoring_rects.rect[i].y, - scissoring_rects.rect[i].x + scissoring_rects.rect[i].width, - scissoring_rects.rect[i].y + scissoring_rects.rect[i].height)); - VGLITE_CHECK_ERROR(vg_lite_draw(buf, path, VG_LITE_FILL_NON_ZERO, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - } - } - } - else { - /*** Draw border ***/ - VGLITE_CHECK_ERROR(vg_lite_draw(buf, path, VG_LITE_FILL_NON_ZERO, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - } - - vglite_run(); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_fill.c b/src/draw/nxp/vglite/lv_draw_vglite_fill.c deleted file mode 100644 index c58c09fce7..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_fill.c +++ /dev/null @@ -1,269 +0,0 @@ -/** - * @file lv_draw_vglite_fill.c - * - */ - -/** - * Copyright 2020-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_path.h" -#include "lv_vglite_utils.h" - -#include "../../../stdlib/lv_string.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/** - * Set rectangle path data - * - * @param[in/out] path_data Coordinates of the rectangle - * @param[in/out] path_data_size Size of path_data (bytes) - * @param[in] p Points of the rectangle - * - */ -static void _vglite_set_rectangle(int32_t * path_data, uint32_t * path_data_size, - const lv_area_t * dest_area); - -/** - * Fill area, with optional opacity. - * - * @param[in] dest_area Area with relative coordinates of destination buffer - * @param[in] dsc Description of the area to fill (color, opa) - * - */ -static void _vglite_fill(vglite_draw_task_t * task, const lv_area_t * dest_area, - const lv_draw_fill_dsc_t * dsc); - -/** - * Draw rectangle background with effects (rounded corners, gradient) - * - * @param[in] coords Coordinates of the rectangle background (relative to dest buff) - * @param[in] clip_area Clip area with relative coordinates to dest buff - * @param[in] dsc Description of the rectangle background - * - */ -static void _vglite_draw_rect(vglite_draw_task_t * task, const lv_area_t * coords, - const lv_area_t * clip_area, const lv_draw_fill_dsc_t * dsc); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_fill(vglite_draw_task_t * vglite_task) -{ - const lv_draw_fill_dsc_t * dsc = vglite_task->t->draw_dsc; - const lv_area_t * coords = &vglite_task->t->area; - - if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) - return; - - lv_layer_t * layer = vglite_task->t->target_layer; - lv_area_t relative_coords; - lv_area_copy(&relative_coords, coords); - lv_area_move(&relative_coords, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t clip_area; - lv_area_copy(&clip_area, &vglite_task->t->clip_area); - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t clipped_coords; - if(!lv_area_intersect(&clipped_coords, &relative_coords, &clip_area)) - return; /*Fully clipped, nothing to do*/ - - /* - * Most simple case: just a plain rectangle (no radius, no gradient) - */ - if((dsc->radius == 0) && (dsc->grad.dir == (lv_grad_dir_t)LV_GRAD_DIR_NONE)) - _vglite_fill(vglite_task, &clipped_coords, dsc); - else - _vglite_draw_rect(vglite_task, &relative_coords, &clip_area, dsc); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _vglite_set_rectangle(int32_t * path_data, uint32_t * path_data_size, const lv_area_t * dest_area) -{ - uint32_t pidx = 0; - path_data[pidx++] = VLC_OP_MOVE; - path_data[pidx++] = dest_area->x1; - path_data[pidx++] = dest_area->y1; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = dest_area->x2 + 1; - path_data[pidx++] = dest_area->y1; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = dest_area->x2 + 1; - path_data[pidx++] = dest_area->y2 + 1; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = dest_area->x1; - path_data[pidx++] = dest_area->y2 + 1; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = dest_area->x1; - path_data[pidx++] = dest_area->y1; - path_data[pidx++] = VLC_OP_END; - - *path_data_size = pidx * sizeof(int32_t); -} - -static void _vglite_fill(vglite_draw_task_t * vglite_task, const lv_area_t * dest_area, - const lv_draw_fill_dsc_t * dsc) -{ - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - - lv_color32_t col32 = lv_color_to_32(dsc->color, dsc->opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - if(dsc->opa >= (lv_opa_t)LV_OPA_MAX) { /*Opaque fill*/ - vg_lite_rectangle_t rect = { - .x = dest_area->x1, - .y = dest_area->y1, - .width = lv_area_get_width(dest_area), - .height = lv_area_get_height(dest_area) - }; - - VGLITE_CHECK_ERROR(vg_lite_clear(dest_buf, &rect, vgcol)); - - vglite_run(); - } - else { /*fill with transparency*/ - - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - - uint32_t path_data_size; - int32_t * path_data = lv_malloc_zeroed(16 * sizeof(int32_t)); - LV_ASSERT_MALLOC(path_data); - vglite_task->path_data = path_data; - _vglite_set_rectangle(path_data, &path_data_size, dest_area); - - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, VG_LITE_MEDIUM, path_data_size, path_data, - (vg_lite_float_t) dest_area->x1, (vg_lite_float_t) dest_area->y1, - ((vg_lite_float_t) dest_area->x2) + 1.0f, ((vg_lite_float_t) dest_area->y2) + 1.0f)); - - /*Draw rectangle*/ - VGLITE_CHECK_ERROR(vg_lite_draw(dest_buf, path, VG_LITE_FILL_EVEN_ODD, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - - vglite_run(); - } -} - -static void _vglite_draw_rect(vglite_draw_task_t * vglite_task, const lv_area_t * coords, - const lv_area_t * clip_area, const lv_draw_fill_dsc_t * dsc) -{ - int32_t width = lv_area_get_width(coords); - int32_t height = lv_area_get_height(coords); - int32_t radius = dsc->radius; - lv_opa_t opa = dsc->opa; - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - - if(dsc->radius < 0) - return; - - /*** Init path ***/ - int32_t * path_data = lv_malloc_zeroed(RECT_PATH_DATA_MAX_SIZE * sizeof(int32_t)); - LV_ASSERT_MALLOC(path_data); - vglite_task->path_data = path_data; - - uint32_t path_data_size; - vglite_create_rect_path_data(path_data, &path_data_size, radius, coords); - vg_lite_quality_t path_quality = dsc->radius > 0 ? VG_LITE_HIGH : VG_LITE_MEDIUM; - - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, path_quality, path_data_size, path_data, - (vg_lite_float_t)clip_area->x1, (vg_lite_float_t)clip_area->y1, - ((vg_lite_float_t)clip_area->x2) + 1.0f, ((vg_lite_float_t)clip_area->y2) + 1.0f)); - - /*** Init Color ***/ - lv_color32_t col32 = lv_color_to_32(dsc->color, opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - vg_lite_linear_gradient_t * gradient; - bool has_gradient = (dsc->grad.dir != (lv_grad_dir_t)LV_GRAD_DIR_NONE); - - /*** Init Gradient ***/ - if(has_gradient) { - gradient = lv_malloc_zeroed(sizeof(vg_lite_linear_gradient_t)); - LV_ASSERT_MALLOC(gradient); - vglite_task->gradient = gradient; - - vg_lite_matrix_t * grad_matrix; - - vg_lite_uint32_t colors[LV_GRADIENT_MAX_STOPS]; - vg_lite_uint32_t stops[LV_GRADIENT_MAX_STOPS]; - lv_color32_t col32[LV_GRADIENT_MAX_STOPS]; - - /* Gradient setup */ - vg_lite_uint32_t cnt = LV_MIN(dsc->grad.stops_count, LV_GRADIENT_MAX_STOPS); - lv_opa_t opa; - - for(uint8_t i = 0; i < cnt; i++) { - stops[i] = dsc->grad.stops[i].frac; - - opa = LV_OPA_MIX2(dsc->grad.stops[i].opa, dsc->opa); - - col32[i] = lv_color_to_32(dsc->grad.stops[i].color, opa); - colors[i] = vglite_get_color(col32[i], true); - } - - VGLITE_CHECK_ERROR(vg_lite_init_grad(gradient)); - - VGLITE_CHECK_ERROR(vg_lite_set_grad(gradient, cnt, colors, stops)); - - VGLITE_CHECK_ERROR(vg_lite_update_grad(gradient)); - - grad_matrix = vg_lite_get_grad_matrix(gradient); - vg_lite_identity(grad_matrix); - vg_lite_translate((float)coords->x1, (float)coords->y1, grad_matrix); - - if(dsc->grad.dir == (lv_grad_dir_t)LV_GRAD_DIR_VER) { - vg_lite_scale(1.0f, (float)height / 256.0f, grad_matrix); - vg_lite_rotate(90.0f, grad_matrix); - } - else { /*LV_GRAD_DIR_HOR*/ - vg_lite_scale((float)width / 256.0f, 1.0f, grad_matrix); - } - - VGLITE_CHECK_ERROR(vg_lite_draw_gradient(dest_buf, path, VG_LITE_FILL_EVEN_ODD, NULL, gradient, - VG_LITE_BLEND_SRC_OVER)); - } - else { - VGLITE_CHECK_ERROR(vg_lite_draw(dest_buf, path, VG_LITE_FILL_EVEN_ODD, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - } - - vglite_run(); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_img.c b/src/draw/nxp/vglite/lv_draw_vglite_img.c deleted file mode 100644 index de1c6736c6..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_img.c +++ /dev/null @@ -1,449 +0,0 @@ -/** - * @file lv_draw_vglite_img.c - * - */ - -/** - * Copyright 2020-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_matrix.h" -#include "lv_vglite_utils.h" -#include "lv_vglite_path.h" - -#include "../../../misc/lv_log.h" - -/********************* - * DEFINES - *********************/ - -#if LV_USE_VGLITE_BLIT_SPLIT -/** -* BLIT split threshold - BLITs with width or height higher than this value will -* be done in multiple steps. Value must be multiple of stride alignment in px. -* For most color formats the alignment is 16px (except the index formats). -*/ -#define VGLITE_BLIT_SPLIT_THR 352 - -/* Enable for logging debug traces. */ -#define VGLITE_LOG_TRACE 0 - -#if VGLITE_LOG_TRACE -#define VGLITE_TRACE(fmt, ...) \ - do { \ - LV_LOG(fmt, ##__VA_ARGS__); \ - } while (0) -#else -#define VGLITE_TRACE(fmt, ...) \ - do { \ - } while (0) -#endif -#endif /*LV_USE_VGLITE_BLIT_SPLIT*/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -#if LV_USE_VGLITE_BLIT_SPLIT -/** - * Move buffer pointer as close as possible to area, but with respect to alignment requirements. - * - * @param[in] buf Buffer address pointer - * @param[in] area Area with relative coordinates to the buffer - * @param[in] stride Stride of buffer in bytes - * @param[in] cf Color format of buffer - */ -static void _move_buf_close_to_area(void ** buf, lv_area_t * area, uint32_t stride, lv_color_format_t cf); - -/** - * BLock Image Transfer - copy rectangular image from src_buf to dest_buf with effects. - * By default, image is copied directly, with optional opacity. - * - * @param dest_buf Destination buffer - * @param[in] dest_area Destination area with relative coordinates to dest buffer - * @param[in] dest_stride Stride of destination buffer in bytes - * @param[in] dest_cf Color format of destination buffer - * @param[in] src_buf Source buffer - * @param[in] src_area Source area with relative coordinates to src buffer - * @param[in] src_stride Stride of source buffer in bytes - * @param[in] src_cf Color format of source buffer - * @param[in] dsc Image descriptor - * - */ -static void _vglite_blit_split(void * dest_buf, lv_area_t * dest_area, uint32_t dest_stride, lv_color_format_t dest_cf, - const void * src_buf, lv_area_t * src_area, uint32_t src_stride, lv_color_format_t src_cf, - const lv_draw_image_dsc_t * dsc); -#endif /*LV_USE_VGLITE_BLIT_SPLIT*/ - -/** - * VGlite blit - fill a path with an image pattern - * - * - * @param[in] dest_area Destination area with relative coordinates to dest buffer - * @param[in] clip_area Clip area with relative coordinates to dest buff - * @param[in] coords Coordinates of the image (relative to dest buff) - * @param[in] dsc Image descriptor - * - */ -static void _vglite_draw_pattern(vglite_draw_task_t * vglite_task, const lv_area_t * clip_area, - const lv_area_t * coords, - const lv_draw_image_dsc_t * dsc); - -/** - * BLock Image Transfer - copy rectangular image from src_buf to dest_buf with or without effects. - * - * @param[in] src_area Source area with relative coordinates to src buffer - * @param[in] dsc Image descriptor - * - */ -static void _vglite_blit(const lv_area_t * src_area, const lv_draw_image_dsc_t * dsc); - -static vg_lite_color_t _vglite_recolor(const lv_draw_image_dsc_t * dsc); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_img(vglite_draw_task_t * vglite_task) -{ - const lv_draw_image_dsc_t * dsc = vglite_task->t->draw_dsc; - const lv_area_t * coords = &vglite_task->t->area; - - if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) - return; - - lv_layer_t * layer = vglite_task->t->target_layer; - const lv_image_dsc_t * img_dsc = dsc->src; - - lv_area_t relative_coords; - lv_area_copy(&relative_coords, coords); - lv_area_move(&relative_coords, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t clip_area; - lv_area_copy(&clip_area, &vglite_task->t->clip_area); - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t blend_area; - bool has_transform = (dsc->rotation != 0 || dsc->scale_x != LV_SCALE_NONE || dsc->scale_y != LV_SCALE_NONE); - if(has_transform) - lv_area_copy(&blend_area, &relative_coords); - else if(!lv_area_intersect(&blend_area, &relative_coords, &clip_area)) - return; /*Fully clipped, nothing to do*/ - - const void * src_buf = img_dsc->data; - - lv_area_t src_area; - src_area.x1 = blend_area.x1 - (coords->x1 - layer->buf_area.x1); - src_area.y1 = blend_area.y1 - (coords->y1 - layer->buf_area.y1); - src_area.x2 = img_dsc->header.w - 1; - src_area.y2 = img_dsc->header.h - 1; - - lv_color_format_t src_cf = img_dsc->header.cf; - uint32_t src_stride = img_dsc->header.stride; - - /* Set src_buf structure. */ - vglite_set_src_buf(src_buf, img_dsc->header.w, img_dsc->header.h, src_stride, src_cf); - -#if LV_USE_VGLITE_BLIT_SPLIT - void * dest_buf = layer->draw_buf->data; - uint32_t dest_stride = layer->draw_buf->header.stride; - lv_color_format_t dest_cf = layer->draw_buf->header.cf; - - if(!has_transform) - _vglite_blit_split(dest_buf, &blend_area, dest_stride, dest_cf, - src_buf, &src_area, src_stride, src_cf, dsc); -#else - vglite_set_transformation_matrix(&blend_area, dsc); - bool is_tiled = dsc->tile; - if(is_tiled) - _vglite_draw_pattern(vglite_task, &clip_area, &relative_coords, dsc); - else - _vglite_blit(&src_area, dsc); -#endif /*LV_USE_VGLITE_BLIT_SPLIT*/ -} - -/********************** - * STATIC FUNCTIONS - **********************/ -static void _vglite_blit(const lv_area_t * src_area, const lv_draw_image_dsc_t * dsc) -{ - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - vg_lite_buffer_t * src_buf = vglite_get_src_buf(); - - vg_lite_rectangle_t rect = { - .x = (vg_lite_int32_t)src_area->x1, - .y = (vg_lite_int32_t)src_area->y1, - .width = (vg_lite_int32_t)lv_area_get_width(src_area), - .height = (vg_lite_int32_t)lv_area_get_height(src_area) - }; - - src_buf->image_mode = VG_LITE_MULTIPLY_IMAGE_MODE; - src_buf->transparency_mode = VG_LITE_IMAGE_TRANSPARENT; - - vg_lite_color_t vgcol = _vglite_recolor(dsc); - - vg_lite_matrix_t * matrix = vglite_get_matrix(); - vg_lite_blend_t vgblend = vglite_get_blend_mode(dsc->blend_mode); - - VGLITE_CHECK_ERROR(vg_lite_blit_rect(dest_buf, src_buf, &rect, matrix, vgblend, vgcol, VG_LITE_FILTER_POINT)); - - vglite_run(); -} - -#if LV_USE_VGLITE_BLIT_SPLIT -static void _move_buf_close_to_area(void ** buf, lv_area_t * area, uint32_t stride, lv_color_format_t cf) -{ - uint8_t ** buf_u8 = (uint8_t **)buf; - uint8_t align_bytes = vglite_get_stride_alignment(cf); - uint8_t bits_per_pixel = lv_color_format_get_bpp(cf); - - uint16_t align_pixels = align_bytes * 8 / bits_per_pixel; - - if(area->x1 >= (int32_t)(area->x1 % align_pixels)) { - uint16_t shift_x = area->x1 - (area->x1 % align_pixels); - - area->x1 -= shift_x; - area->x2 -= shift_x; - *buf_u8 += (shift_x * bits_per_pixel) / 8; - } - - if(area->y1) { - uint16_t shift_y = area->y1; - - area->y1 -= shift_y; - area->y2 -= shift_y; - *buf_u8 += shift_y * stride; - } -} - -static void _vglite_blit_split(void * dest_buf, lv_area_t * dest_area, uint32_t dest_stride, lv_color_format_t dest_cf, - const void * src_buf, lv_area_t * src_area, uint32_t src_stride, lv_color_format_t src_cf, - const lv_draw_image_dsc_t * dsc) -{ - VGLITE_TRACE("Blit " - "Area: ([%d,%d], [%d,%d]) -> ([%d,%d], [%d,%d]) | " - "Size: ([%dx%d] -> [%dx%d]) | " - "Addr: (0x%x -> 0x%x)", - src_area->x1, src_area->y1, src_area->x2, src_area->y2, - dest_area->x1, dest_area->y1, dest_area->x2, dest_area->y2, - lv_area_get_width(src_area), lv_area_get_height(src_area), - lv_area_get_width(dest_area), lv_area_get_height(dest_area), - (uintptr_t)src_buf, (uintptr_t)dest_buf); - - /* Move starting pointers as close as possible to [x1, y1], so coordinates are as small as possible */ - _move_buf_close_to_area((void **)&src_buf, src_area, src_stride, src_cf); - _move_buf_close_to_area(&dest_buf, dest_area, dest_stride, dest_cf); - - /* Set clip area */ - vglite_set_scissor(dest_area); - - /* If we're in limit, do a single BLIT */ - if((src_area->x2 < VGLITE_BLIT_SPLIT_THR) && - (src_area->y2 < VGLITE_BLIT_SPLIT_THR)) { - - /* Set new dest_buf and src_buf memory addresses */ - vglite_set_dest_buf_ptr(dest_buf); - vglite_set_src_buf_ptr(src_buf); - - vglite_set_transformation_matrix(dest_area, dsc); - _vglite_blit(src_area, dsc); - - VGLITE_TRACE("Single " - "Area: ([%d,%d], [%d,%d]) -> ([%d,%d], [%d,%d]) | " - "Size: ([%dx%d] -> [%dx%d]) | " - "Addr: (0x%x -> 0x%x)", - src_area->x1, src_area->y1, src_area->x2, src_area->y2, - dest_area->x1, dest_area->y1, dest_area->x2, dest_area->y2, - lv_area_get_width(src_area), lv_area_get_height(src_area), - lv_area_get_width(dest_area), lv_area_get_height(dest_area), - (uintptr_t)src_buf, (uintptr_t)dest_buf); - - return; - }; - - /* Split the BLIT into multiple tiles */ - VGLITE_TRACE("Split " - "Area: ([%d,%d], [%d,%d]) -> ([%d,%d], [%d,%d]) | " - "Size: ([%dx%d] -> [%dx%d]) | " - "Addr: (0x%x -> 0x%x)", - src_area->x1, src_area->y1, src_area->x2, src_area->y2, - dest_area->x1, dest_area->y1, dest_area->x2, dest_area->y2, - lv_area_get_width(src_area), lv_area_get_height(src_area), - lv_area_get_width(dest_area), lv_area_get_height(dest_area), - (uintptr_t)src_buf, (uintptr_t)dest_buf); - - int32_t width = LV_MIN(lv_area_get_width(src_area), lv_area_get_width(dest_area)); - int32_t height = LV_MIN(lv_area_get_height(src_area), lv_area_get_height(dest_area)); - - /* Number of tiles needed */ - uint8_t total_tiles_x = (src_area->x1 + width + VGLITE_BLIT_SPLIT_THR - 1) / - VGLITE_BLIT_SPLIT_THR; - uint8_t total_tiles_y = (src_area->y1 + height + VGLITE_BLIT_SPLIT_THR - 1) / - VGLITE_BLIT_SPLIT_THR; - - uint16_t shift_src_x = src_area->x1; - uint16_t shift_dest_x = dest_area->x1; - - VGLITE_TRACE("X shift: src: %d, dst: %d", shift_src_x, shift_dest_x); - - uint8_t * tile_dest_buf; - lv_area_t tile_dest_area; - const uint8_t * tile_src_buf; - lv_area_t tile_src_area; - - for(uint8_t y = 0; y < total_tiles_y; y++) { - /* y1 always start from 0 */ - tile_src_area.y1 = 0; - - /* Calculate y2 coordinates */ - if(y < total_tiles_y - 1) - tile_src_area.y2 = VGLITE_BLIT_SPLIT_THR - 1; - else - tile_src_area.y2 = height - y * VGLITE_BLIT_SPLIT_THR - 1; - - /* No vertical shift, dest y is always in sync with src y */ - tile_dest_area.y1 = tile_src_area.y1; - tile_dest_area.y2 = tile_src_area.y2; - - /* Advance start pointer for every tile, except the first column (y = 0) */ - tile_src_buf = (uint8_t *)src_buf + y * VGLITE_BLIT_SPLIT_THR * src_stride; - tile_dest_buf = (uint8_t *)dest_buf + y * VGLITE_BLIT_SPLIT_THR * dest_stride; - - for(uint8_t x = 0; x < total_tiles_x; x++) { - /* x1 always start from the same shift */ - tile_src_area.x1 = shift_src_x; - tile_dest_area.x1 = shift_dest_x; - if(x > 0) { - /* Advance start pointer for every tile, except the first raw (x = 0) */ - tile_src_buf += VGLITE_BLIT_SPLIT_THR * lv_color_format_get_bpp(src_cf) / 8; - tile_dest_buf += VGLITE_BLIT_SPLIT_THR * lv_color_format_get_bpp(dest_cf) / 8; - } - - /* Calculate x2 coordinates */ - if(x < total_tiles_x - 1) - tile_src_area.x2 = VGLITE_BLIT_SPLIT_THR - 1; - else - tile_src_area.x2 = width - x * VGLITE_BLIT_SPLIT_THR - 1; - - tile_dest_area.x2 = tile_src_area.x2; - - /* Shift x2 coordinates */ - tile_src_area.x2 += shift_src_x; - tile_dest_area.x2 += shift_dest_x; - - /* Set new dest_buf and src_buf memory addresses */ - vglite_set_dest_buf_ptr(tile_dest_buf); - vglite_set_src_buf_ptr(tile_src_buf); - - vglite_set_transformation_matrix(&tile_dest_area, dsc); - _vglite_blit(&tile_src_area, dsc); - - VGLITE_TRACE("Tile [%d, %d] " - "Area: ([%d,%d], [%d,%d]) -> ([%d,%d], [%d,%d]) | " - "Size: ([%dx%d] -> [%dx%d]) | " - "Addr: (0x%x -> 0x%x)", - x, y, - tile_src_area.x1, tile_src_area.y1, tile_src_area.x2, tile_src_area.y2, - tile_dest_area.x1, tile_dest_area.y1, tile_dest_area.x2, tile_dest_area.y2, - lv_area_get_width(&tile_src_area), lv_area_get_height(&tile_src_area), - lv_area_get_width(&tile_dest_area), lv_area_get_height(&tile_dest_area), - (uintptr_t)tile_src_buf, (uintptr_t)tile_dest_buf); - } - } -} -#endif /*LV_USE_VGLITE_BLIT_SPLIT*/ - -static void _vglite_draw_pattern(vglite_draw_task_t * vglite_task, const lv_area_t * clip_area, - const lv_area_t * coords, - const lv_draw_image_dsc_t * dsc) -{ - /* Target buffer */ - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - - /* Path to draw */ - int32_t * path_data = lv_malloc_zeroed(RECT_PATH_DATA_MAX_SIZE * sizeof(int32_t)); - LV_ASSERT_MALLOC(path_data); - vglite_task->path_data = path_data; - - uint32_t path_data_size; - vglite_create_rect_path_data(path_data, &path_data_size, dsc->clip_radius, coords); - vg_lite_quality_t path_quality = VG_LITE_MEDIUM; - - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, path_quality, path_data_size, path_data, - (vg_lite_float_t)clip_area->x1, (vg_lite_float_t)clip_area->y1, - ((vg_lite_float_t)clip_area->x2) + 1.0f, ((vg_lite_float_t)clip_area->y2) + 1.0f)); - - /* Pattern Image */ - vg_lite_buffer_t * src_buf = vglite_get_src_buf(); - src_buf->image_mode = VG_LITE_MULTIPLY_IMAGE_MODE; - src_buf->transparency_mode = VG_LITE_IMAGE_TRANSPARENT; - - /* Pattern matrix */ - vg_lite_matrix_t matrix; - vg_lite_identity(&matrix); - vg_lite_translate((vg_lite_float_t)dsc->image_area.x1, (vg_lite_float_t)dsc->image_area.y1, &matrix); - - /* Blend mode */ - vg_lite_blend_t vgblend = vglite_get_blend_mode(dsc->blend_mode); - - vg_lite_color_t vgcol = _vglite_recolor(dsc); - - /* Filter */ - bool has_transform = (dsc->rotation != 0 || dsc->scale_x != LV_SCALE_NONE || dsc->scale_y != LV_SCALE_NONE); - vg_lite_filter_t filter = has_transform ? VG_LITE_FILTER_BI_LINEAR : VG_LITE_FILTER_POINT; - - /* Draw Pattern */ - VGLITE_CHECK_ERROR(vg_lite_draw_pattern(dest_buf, path, VG_LITE_FILL_NON_ZERO, NULL, - src_buf, &matrix, vgblend, VG_LITE_PATTERN_REPEAT, - 0, vgcol, filter)); - vglite_run(); -} - -static vg_lite_color_t _vglite_recolor(const lv_draw_image_dsc_t * dsc) -{ - lv_color_t color; - lv_opa_t opa; - - bool has_recolor = (dsc->recolor_opa > LV_OPA_MIN); - if(has_recolor) { - color = dsc->recolor; - opa = LV_OPA_MIX2(dsc->recolor_opa, dsc->opa); - } - else { - color.red = 0xFF; - color.green = 0xFF; - color.blue = 0xFF; - opa = dsc->opa; - } - - lv_color32_t col32 = lv_color_to_32(color, opa); - - return vglite_get_color(col32, false); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_label.c b/src/draw/nxp/vglite/lv_draw_vglite_label.c deleted file mode 100644 index da6a6ce8e7..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_label.c +++ /dev/null @@ -1,270 +0,0 @@ -/** - * @file lv_draw_vglite_label.c - * - */ - -/** - * Copyright 2023-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_matrix.h" -#include "lv_vglite_utils.h" - -#include "../../lv_draw_label_private.h" -#include "../../../stdlib/lv_string.h" -#include "../../../font/lv_font_fmt_txt_private.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -static void _draw_vglite_letter(lv_draw_task_t * t, lv_draw_glyph_dsc_t * glyph_draw_dsc, - lv_draw_fill_dsc_t * fill_draw_dsc, const lv_area_t * fill_area); - -/** - * Draw letter (character bitmap blend) with optional color and opacity - * - * @param[in] mask_area Mask area with relative coordinates of source buffer - * @param[in] color Color - * @param[in] opa Opacity - * - */ -static void _vglite_draw_letter(const lv_area_t * mask_area, lv_color_t color, lv_opa_t opa); - -/********************** - * STATIC VARIABLES - **********************/ - -static bool _use_static_bitmap = false; - -/********************** - * GLOBAL VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_label(vglite_draw_task_t * vglite_task) -{ - const lv_draw_label_dsc_t * dsc = vglite_task->t->draw_dsc; - const lv_area_t * coords = &vglite_task->t->area; - - if(dsc->opa <= LV_OPA_MIN) return; - - lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *)dsc->font->dsc; - bool is_src_buf_aligned = vglite_src_buf_aligned(fdsc->glyph_bitmap, fdsc->stride, LV_COLOR_FORMAT_A8); - bool has_static_bitmap = lv_font_has_static_bitmap(dsc->font); - - _use_static_bitmap = is_src_buf_aligned & has_static_bitmap; - - lv_draw_label_iterate_characters(vglite_task->t, dsc, coords, _draw_vglite_letter); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _draw_vglite_letter(lv_draw_task_t * t, lv_draw_glyph_dsc_t * glyph_draw_dsc, - lv_draw_fill_dsc_t * fill_draw_dsc, const lv_area_t * fill_area) -{ - if(glyph_draw_dsc) { - - switch(glyph_draw_dsc->format) { - - case LV_FONT_GLYPH_FORMAT_NONE: { -#if LV_USE_FONT_PLACEHOLDER - /* Draw a placeholder rectangle*/ - vglite_draw_task_t * vglite_task = lv_malloc_zeroed(sizeof(vglite_draw_task_t)); - LV_ASSERT_MALLOC(vglite_task); - - lv_draw_border_dsc_t border_draw_dsc; - - lv_draw_border_dsc_init(&border_draw_dsc); - border_draw_dsc.opa = glyph_draw_dsc->opa; - border_draw_dsc.color = glyph_draw_dsc->color; - border_draw_dsc.width = 1; - - vglite_task->t = t; - vglite_task->t->draw_dsc = &border_draw_dsc; - vglite_task->t->area = *glyph_draw_dsc->bg_coords; - - lv_draw_vglite_border(vglite_task); - - /** Cleanup for vglite_task */ - VGLITE_CHECK_ERROR(vg_lite_finish()); - if(vglite_task->path) { - VGLITE_CHECK_ERROR(vg_lite_clear_path(vglite_task->path)); - lv_free(vglite_task->path_data); - lv_free(vglite_task->path); - } - lv_free(vglite_task); -#endif - } - break; - case LV_FONT_GLYPH_FORMAT_A1 ... LV_FONT_GLYPH_FORMAT_A8: { - /*Do not draw transparent things*/ - if(glyph_draw_dsc->opa <= LV_OPA_MIN) - return; - - lv_layer_t * layer = t->target_layer; - - lv_area_t blend_area; - if(!lv_area_intersect(&blend_area, glyph_draw_dsc->letter_coords, &t->clip_area)) - return; - lv_area_move(&blend_area, -layer->buf_area.x1, -layer->buf_area.y1); - - const void * mask_buf = NULL; - const lv_draw_buf_t * draw_buf = NULL; - uint32_t mask_stride; - if(!_use_static_bitmap) { - draw_buf = lv_font_get_glyph_bitmap(glyph_draw_dsc->g, glyph_draw_dsc->_draw_buf); - if(draw_buf != NULL) { - mask_buf = draw_buf->data; - } - else { - return; - } - mask_stride = draw_buf->header.stride; - } - else { - glyph_draw_dsc->g->req_raw_bitmap = 1; - mask_buf = lv_font_get_glyph_static_bitmap(glyph_draw_dsc->g); - mask_stride = glyph_draw_dsc->g->stride; - } - - uint32_t mask_width = lv_area_get_width(glyph_draw_dsc->letter_coords); - uint32_t mask_height = lv_area_get_height(glyph_draw_dsc->letter_coords); - - lv_area_t mask_area; - mask_area.x1 = blend_area.x1 - (glyph_draw_dsc->letter_coords->x1 - layer->buf_area.x1); - mask_area.y1 = blend_area.y1 - (glyph_draw_dsc->letter_coords->y1 - layer->buf_area.y1); - mask_area.x2 = mask_width - 1; - mask_area.y2 = mask_height - 1; - - /* Set src_buf structure. */ - vglite_set_src_buf(mask_buf, mask_width, mask_height, mask_stride, LV_COLOR_FORMAT_A8); - - /* Set matrix. */ - vglite_set_translation_matrix(&blend_area); - - if(!_use_static_bitmap) - lv_draw_buf_invalidate_cache(draw_buf, &mask_area); - - _vglite_draw_letter(&mask_area, glyph_draw_dsc->color, glyph_draw_dsc->opa); - } - break; - case LV_FONT_GLYPH_FORMAT_IMAGE: { -#if LV_USE_IMGFONT - glyph_draw_dsc->glyph_data = lv_font_get_glyph_bitmap(glyph_draw_dsc->g, glyph_draw_dsc->_draw_buf); - vglite_draw_task_t * vglite_task = lv_malloc_zeroed(sizeof(vglite_draw_task_t)); - LV_ASSERT_MALLOC(vglite_task); - - lv_draw_image_dsc_t img_dsc; - lv_draw_image_dsc_init(&img_dsc); - img_dsc.opa = glyph_draw_dsc->opa; - img_dsc.src = glyph_draw_dsc->glyph_data; - - void * old_dsc = t->draw_dsc; - lv_area_t old_area = t->area; - - t->draw_dsc = &img_dsc; - t->area = *glyph_draw_dsc->letter_coords; - vglite_task->t = t; - - lv_draw_vglite_img(vglite_task); - - /** Cleanup for vglite_task */ - vg_lite_finish(); - if(vglite_task->path) { - VGLITE_CHECK_ERROR(vg_lite_clear_path(vglite_task->path)); - lv_free(vglite_task->path_data); - lv_free(vglite_task->path); - } - lv_free(vglite_task); - - t->draw_dsc = old_dsc; - t->area = old_area; -#endif - } - break; - default: - break; - } - } - - if(fill_draw_dsc && fill_area) { - vglite_draw_task_t * vglite_task = lv_malloc_zeroed(sizeof(vglite_draw_task_t)); - LV_ASSERT_MALLOC(vglite_task); - - t->draw_dsc = fill_draw_dsc; - t->area = *fill_area; - vglite_task->t = t; - - lv_draw_vglite_fill(vglite_task); - - /** Cleanup for vglite_task */ - vg_lite_finish(); - if(vglite_task->path) { - VGLITE_CHECK_ERROR(vg_lite_clear_path(vglite_task->path)); - lv_free(vglite_task->path_data); - lv_free(vglite_task->path); - } - if(vglite_task->gradient) { - VGLITE_CHECK_ERROR(vg_lite_clear_grad(vglite_task->gradient)); - lv_free(vglite_task->gradient); - } - lv_free(vglite_task); - } -} - -static void _vglite_draw_letter(const lv_area_t * mask_area, lv_color_t color, lv_opa_t opa) -{ - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - vg_lite_buffer_t * mask_buf = vglite_get_src_buf(); - - mask_buf->image_mode = VG_LITE_MULTIPLY_IMAGE_MODE; - mask_buf->transparency_mode = VG_LITE_IMAGE_TRANSPARENT; - - vg_lite_rectangle_t rect = { - .x = (vg_lite_int32_t)mask_area->x1, - .y = (vg_lite_int32_t)mask_area->y1, - .width = (vg_lite_int32_t)lv_area_get_width(mask_area), - .height = (vg_lite_int32_t)lv_area_get_height(mask_area) - }; - - lv_color32_t col32 = lv_color_to_32(color, opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - vg_lite_matrix_t * matrix = vglite_get_matrix(); - - /*Blit with font color as paint color*/ - VGLITE_CHECK_ERROR(vg_lite_blit_rect(dest_buf, mask_buf, &rect, matrix, VG_LITE_BLEND_SRC_OVER, vgcol, - VG_LITE_FILTER_POINT)); - - vglite_run(); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_layer.c b/src/draw/nxp/vglite/lv_draw_vglite_layer.c deleted file mode 100644 index 559b1107c4..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_layer.c +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file lv_draw_vglite_layer.c - * - */ - -/** - * Copyright 2023-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE - -#include "../../../stdlib/lv_string.h" -#include "../../../core/lv_global.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -#define _draw_info LV_GLOBAL_DEFAULT()->draw_info - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_layer(vglite_draw_task_t * vglite_task) -{ - lv_draw_image_dsc_t * draw_dsc = vglite_task->t->draw_dsc; - - lv_layer_t * layer_to_draw = (lv_layer_t *)draw_dsc->src; - const lv_draw_buf_t * draw_buf = layer_to_draw->draw_buf; - - /* It can happen that nothing was draw on a layer and therefore its buffer is not allocated. - * In this case just return. - */ - if(draw_buf == NULL) - return; - - if(_draw_info.unit_cnt > 1) { - const lv_area_t area_to_draw = { - .x1 = 0, - .y1 = 0, - .x2 = draw_buf->header.w - 1, - .y2 = draw_buf->header.h - 1 - }; - lv_draw_buf_invalidate_cache(draw_buf, &area_to_draw); - } - - lv_draw_image_dsc_t new_draw_dsc = *draw_dsc; - new_draw_dsc.src = draw_buf; - vglite_task->t->draw_dsc = &new_draw_dsc; - lv_draw_vglite_img(vglite_task); - vglite_task->t->draw_dsc = draw_dsc; - -#if LV_USE_LAYER_DEBUG || LV_USE_PARALLEL_DRAW_DEBUG - const lv_area_t * coords = &vglite_task->t->area; - lv_area_t area_rot; - lv_area_copy(&area_rot, coords); - bool has_transform = (draw_dsc->rotation != 0 || draw_dsc->scale_x != LV_SCALE_NONE || - draw_dsc->scale_y != LV_SCALE_NONE); - - if(has_transform) { - int32_t w = lv_area_get_width(coords); - int32_t h = lv_area_get_height(coords); - - lv_image_buf_get_transformed_area(&area_rot, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y, - &draw_dsc->pivot); - - area_rot.x1 += coords->x1; - area_rot.y1 += coords->y1; - area_rot.x2 += coords->x1; - area_rot.y2 += coords->y1; - } - lv_area_t draw_area; - if(!lv_area_intersect(&draw_area, &area_rot, &vglite_task->t->clip_area)) return; -#endif - -#if LV_USE_LAYER_DEBUG - lv_draw_fill_dsc_t fill_dsc; - lv_draw_fill_dsc_init(&fill_dsc); - fill_dsc.color = lv_color_hex(layer_to_draw->color_format == LV_COLOR_FORMAT_ARGB8888 ? 0xff0000 : 0x00ff00); - fill_dsc.opa = LV_OPA_20; - lv_draw_sw_fill(vglite_task->t, &fill_dsc, &area_rot); - - lv_draw_border_dsc_t border_dsc; - lv_draw_border_dsc_init(&border_dsc); - border_dsc.color = fill_dsc.color; - border_dsc.opa = LV_OPA_60; - border_dsc.width = 2; - lv_draw_sw_border(vglite_task->t, &border_dsc, &area_rot); - -#endif - -#if LV_USE_PARALLEL_DRAW_DEBUG - int32_t idx = vglite_task->t->draw_unit->idx; - - lv_draw_fill_dsc_t fill_dsc; - lv_draw_rect_dsc_init(&fill_dsc); - fill_dsc.color = lv_palette_main(idx % LV_PALETTE_LAST); - fill_dsc.opa = LV_OPA_10; - lv_draw_sw_fill(vglite_task->t, &fill_dsc, &area_rot); - - lv_draw_border_dsc_t border_dsc; - lv_draw_border_dsc_init(&border_dsc); - border_dsc.color = lv_palette_main(idx % LV_PALETTE_LAST); - border_dsc.opa = LV_OPA_100; - border_dsc.width = 2; - lv_draw_sw_border(vglite_task->t, &border_dsc, &area_rot); - - lv_point_t txt_size; - lv_text_get_size(&txt_size, "W", LV_FONT_DEFAULT, 0, 0, 100, LV_TEXT_FLAG_NONE); - - lv_area_t txt_area; - txt_area.x1 = draw_area.x1; - txt_area.x2 = draw_area.x1 + txt_size.x - 1; - txt_area.y2 = draw_area.y2; - txt_area.y1 = draw_area.y2 - txt_size.y + 1; - - lv_draw_fill_dsc_init(&fill_dsc); - fill_dsc.color = lv_color_black(); - lv_draw_sw_fill(vglite_task->t, &fill_dsc, &txt_area); - - char buf[8]; - lv_snprintf(buf, sizeof(buf), "%d", idx); - lv_draw_label_dsc_t label_dsc; - lv_draw_label_dsc_init(&label_dsc); - label_dsc.color = lv_color_white(); - label_dsc.text = buf; - lv_draw_sw_label(vglite_task->t, &label_dsc, &txt_area); -#endif -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_line.c b/src/draw/nxp/vglite/lv_draw_vglite_line.c deleted file mode 100644 index 105b7add8a..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_line.c +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @file lv_draw_vglite_line.c - * - */ - -/** - * Copyright 2022-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_utils.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/** - * Set line path data - * - * @param[in/out] line_path Coordinates of the line - * @param[in/out] path_data_size Size of path_data (bytes) - * @param[in] p1 First point of the line - * @patam[in] p2 Second point of the line - * - */ -static void _vglite_set_line(int32_t * line_path, uint32_t * path_data_size, - const lv_point_t * point1, const lv_point_t * point2); - -/** - * Draw line shape with effects - * - * @param[in] point1 Starting point with relative coordinates - * @param[in] point2 Ending point with relative coordinates - * @param[in] clip_area Clip area with relative coordinates to dest buff - * @param[in] dsc Line description structure (width, rounded ending, opacity, ...) - * - */ -static void _vglite_draw_line(vglite_draw_task_t * vglite_task, const lv_point_t * point1, const lv_point_t * point2, - const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_line(vglite_draw_task_t * vglite_task) -{ - const lv_draw_line_dsc_t * dsc = vglite_task->t->draw_dsc; - - if(dsc->width == 0) - return; - if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) - return; - if(dsc->p1.x == dsc->p2.x && dsc->p1.y == dsc->p2.y) - return; - - lv_layer_t * layer = vglite_task->t->target_layer; - lv_area_t clip_area; - clip_area.x1 = LV_MIN(dsc->p1.x, dsc->p2.x) - dsc->width / 2; - clip_area.x2 = LV_MAX(dsc->p1.x, dsc->p2.x) + dsc->width / 2; - clip_area.y1 = LV_MIN(dsc->p1.y, dsc->p2.y) - dsc->width / 2; - clip_area.y2 = LV_MAX(dsc->p1.y, dsc->p2.y) + dsc->width / 2; - - if(!lv_area_intersect(&clip_area, &clip_area, &vglite_task->t->clip_area)) - return; /*Fully clipped, nothing to do*/ - - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_point_t point1 = {dsc->p1.x - layer->buf_area.x1, dsc->p1.y - layer->buf_area.y1}; - lv_point_t point2 = {dsc->p2.x - layer->buf_area.x1, dsc->p2.y - layer->buf_area.y1}; - - _vglite_draw_line(vglite_task, &point1, &point2, &clip_area, dsc); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _vglite_set_line(int32_t * line_path, uint32_t * path_data_size, const lv_point_t * point1, - const lv_point_t * point2) -{ - uint32_t pidx = 0; - line_path[pidx++] = VLC_OP_MOVE; - line_path[pidx++] = point1->x; - line_path[pidx++] = point1->y; - line_path[pidx++] = VLC_OP_LINE; - line_path[pidx++] = point2->x; - line_path[pidx++] = point2->y; - line_path[pidx++] = VLC_OP_END; - - *path_data_size = pidx * sizeof(int32_t); -} - -static void _vglite_draw_line(vglite_draw_task_t * vglite_task, const lv_point_t * point1, const lv_point_t * point2, - const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc) -{ - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - vg_lite_cap_style_t cap_style = (dsc->round_start || dsc->round_end) ? VG_LITE_CAP_ROUND : VG_LITE_CAP_BUTT; - vg_lite_join_style_t join_style = (dsc->round_start || dsc->round_end) ? VG_LITE_JOIN_ROUND : VG_LITE_JOIN_MITER; - - bool is_dashed = (dsc->dash_width && dsc->dash_gap); - - vg_lite_float_t stroke_dash_pattern[2] = {0, 0}; - uint32_t stroke_dash_count = 0; - vg_lite_float_t stroke_dash_phase = 0; - if(is_dashed) { - stroke_dash_pattern[0] = (vg_lite_float_t)dsc->dash_width; - stroke_dash_pattern[1] = (vg_lite_float_t)dsc->dash_gap; - stroke_dash_count = sizeof(stroke_dash_pattern) / sizeof(vg_lite_float_t); - stroke_dash_phase = (vg_lite_float_t)dsc->dash_width / 2; - } - - /*** Init path ***/ - int32_t width = dsc->width; - - uint32_t path_data_size = 0; - int32_t * line_path = lv_malloc_zeroed(7 * sizeof(int32_t)); - LV_ASSERT_MALLOC(line_path); - vglite_task->path_data = line_path; - _vglite_set_line(line_path, &path_data_size, point1, point2); - - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, VG_LITE_HIGH, path_data_size, line_path, - (vg_lite_float_t)clip_area->x1, (vg_lite_float_t)clip_area->y1, - ((vg_lite_float_t)clip_area->x2) + 1.0f, ((vg_lite_float_t)clip_area->y2) + 1.0f)); - - lv_color32_t col32 = lv_color_to_32(dsc->color, dsc->opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - /*** Draw line ***/ - VGLITE_CHECK_ERROR(vg_lite_set_draw_path_type(path, VG_LITE_DRAW_STROKE_PATH)); - - VGLITE_CHECK_ERROR(vg_lite_set_stroke(path, cap_style, join_style, width, 8, stroke_dash_pattern, stroke_dash_count, - stroke_dash_phase, vgcol)); - - VGLITE_CHECK_ERROR(vg_lite_update_stroke(path)); - - VGLITE_CHECK_ERROR(vg_lite_draw(dest_buf, path, VG_LITE_FILL_NON_ZERO, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - - vglite_run(); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_draw_vglite_triangle.c b/src/draw/nxp/vglite/lv_draw_vglite_triangle.c deleted file mode 100644 index 95da987909..0000000000 --- a/src/draw/nxp/vglite/lv_draw_vglite_triangle.c +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @file lv_draw_vglite_triangle.c - * - */ - -/** - * Copyright 2023-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_draw_vglite.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" -#include "lv_vglite_path.h" -#include "lv_vglite_utils.h" - -#include "../../../stdlib/lv_string.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/** - * Set triangle path data - * - * @param[in/out] path_data Coordinates of the triangle - * @param[in/out] path_data_size Size of path_data (bytes) - * @param[in] p Points of the triangle - * - */ -static void _vglite_set_triangle(int32_t * path_data, uint32_t * path_data_size, - const lv_point_precise_t * p); - -/** - * Draw triangle shape with effects (opacity, gradient) - * - * @param[in] vglite_task The current vglite task - * @param[in] coords Coordinates of the triangle (relative to dest buff) - * @param[in] clip_area Clipping area with relative coordinates to dest buff - * @param[in] dsc Description of the triangle - * - */ -static void _vglite_draw_triangle(vglite_draw_task_t * vglite_task, const lv_area_t * coords, - const lv_area_t * clip_area, - const lv_draw_triangle_dsc_t * dsc); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_draw_vglite_triangle(vglite_draw_task_t * vglite_task) -{ - const lv_draw_triangle_dsc_t * dsc = vglite_task->t->draw_dsc; - - if(dsc->opa <= (lv_opa_t)LV_OPA_MIN) - return; - - lv_layer_t * layer = vglite_task->t->target_layer; - lv_area_t clip_area; - lv_area_copy(&clip_area, &vglite_task->t->clip_area); - lv_area_move(&clip_area, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t coords; - coords.x1 = (int32_t)LV_MIN3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x); - coords.y1 = (int32_t)LV_MIN3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y); - coords.x2 = (int32_t)LV_MAX3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x); - coords.y2 = (int32_t)LV_MAX3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y); - - lv_area_move(&coords, -layer->buf_area.x1, -layer->buf_area.y1); - - lv_area_t clipped_coords; - if(!lv_area_intersect(&clipped_coords, &coords, &clip_area)) - return; /* Fully clipped, nothing to do */ - - _vglite_draw_triangle(vglite_task, &coords, &clip_area, dsc); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static void _vglite_set_triangle(int32_t * path_data, uint32_t * path_data_size, const lv_point_precise_t * p) -{ - uint32_t pidx = 0; - path_data[pidx++] = VLC_OP_MOVE; - path_data[pidx++] = p[0].x; - path_data[pidx++] = p[0].y; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = p[1].x; - path_data[pidx++] = p[1].y; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = p[2].x; - path_data[pidx++] = p[2].y; - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = p[0].x; - path_data[pidx++] = p[0].y; - path_data[pidx++] = VLC_OP_END; - - *path_data_size = pidx * sizeof(int32_t); -} - -static void _vglite_draw_triangle(vglite_draw_task_t * vglite_task, const lv_area_t * coords, - const lv_area_t * clip_area, - const lv_draw_triangle_dsc_t * dsc) -{ - vg_lite_buffer_t * dest_buf = vglite_get_dest_buf(); - - lv_area_t tri_area; - tri_area.x1 = (int32_t)LV_MIN3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x); - tri_area.y1 = (int32_t)LV_MIN3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y); - tri_area.x2 = (int32_t)LV_MAX3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x); - tri_area.y2 = (int32_t)LV_MAX3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y); - - uint32_t width = lv_area_get_width(&tri_area); - uint32_t height = lv_area_get_height(&tri_area); - - /* Init path */ - uint32_t path_data_size; - int32_t * triangle_path = lv_malloc_zeroed(13 * sizeof(int32_t)); - LV_ASSERT_MALLOC(triangle_path); - vglite_task->path_data = triangle_path; - _vglite_set_triangle(triangle_path, &path_data_size, dsc->p); - - - vg_lite_path_t * path = lv_malloc_zeroed(sizeof(vg_lite_path_t)); - LV_ASSERT_MALLOC(path); - vglite_task->path = path; - VGLITE_CHECK_ERROR(vg_lite_init_path(path, VG_LITE_S32, VG_LITE_HIGH, path_data_size, triangle_path, - (vg_lite_float_t)clip_area->x1, (vg_lite_float_t)clip_area->y1, - ((vg_lite_float_t)clip_area->x2) + 1.0f, ((vg_lite_float_t)clip_area->y2) + 1.0f)); - - /* Init Color */ - lv_color32_t col32 = lv_color_to_32(dsc->color, dsc->opa); - vg_lite_color_t vgcol = vglite_get_color(col32, false); - - vg_lite_linear_gradient_t * gradient; - - bool has_gradient = (dsc->grad.dir != (lv_grad_dir_t)LV_GRAD_DIR_NONE); - - /* Init Gradient*/ - if(has_gradient) { - gradient = lv_malloc_zeroed(sizeof(vg_lite_linear_gradient_t)); - LV_ASSERT_MALLOC(gradient); - vglite_task->gradient = gradient; - - vg_lite_matrix_t * grad_matrix; - - vg_lite_uint32_t colors[LV_GRADIENT_MAX_STOPS]; - vg_lite_uint32_t stops[LV_GRADIENT_MAX_STOPS]; - lv_color32_t col32[LV_GRADIENT_MAX_STOPS]; - - /* Gradient Setup */ - vg_lite_uint32_t cnt = LV_MIN(dsc->grad.stops_count, LV_GRADIENT_MAX_STOPS); - lv_opa_t opa; - - for(uint8_t i = 0; i < cnt; i++) { - stops[i] = dsc->grad.stops[i].frac; - opa = LV_OPA_MIX2(dsc->grad.stops[i].opa, dsc->opa); - - col32[i] = lv_color_to_32(dsc->grad.stops[i].color, opa); - colors[i] = vglite_get_color(col32[i], true); - } - - VGLITE_CHECK_ERROR(vg_lite_init_grad(gradient)); - - VGLITE_CHECK_ERROR(vg_lite_set_grad(gradient, cnt, colors, stops)); - - VGLITE_CHECK_ERROR(vg_lite_update_grad(gradient)); - - grad_matrix = vg_lite_get_grad_matrix(gradient); - VGLITE_CHECK_ERROR(vg_lite_identity(grad_matrix)); - VGLITE_CHECK_ERROR(vg_lite_translate((float)coords->x1, (float)coords->y1, grad_matrix)); - - if(dsc->grad.dir == (lv_grad_dir_t)LV_GRAD_DIR_VER) { - VGLITE_CHECK_ERROR(vg_lite_scale(1.0f, (float)height / 256.0f, grad_matrix)); - VGLITE_CHECK_ERROR(vg_lite_rotate(90.0f, grad_matrix)); - } - else { /*LV_GRAD_DIR_HOR*/ - VGLITE_CHECK_ERROR(vg_lite_scale((float)width / 256.0f, 1.0f, grad_matrix)); - } - - VGLITE_CHECK_ERROR(vg_lite_draw_gradient(dest_buf, path, VG_LITE_FILL_EVEN_ODD, NULL, gradient, - VG_LITE_BLEND_SRC_OVER)); - } - else { - VGLITE_CHECK_ERROR(vg_lite_draw(dest_buf, path, VG_LITE_FILL_EVEN_ODD, NULL, VG_LITE_BLEND_SRC_OVER, vgcol)); - } - - vglite_run(); -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_vglite_buf.c b/src/draw/nxp/vglite/lv_vglite_buf.c deleted file mode 100644 index 76f9dc13ee..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_buf.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file lv_vglite_buf.c - * - */ - -/** - * Copyright 2023 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_vglite_buf.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_utils.h" - -#include "../../../stdlib/lv_string.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -static inline void _set_vgbuf_ptr(vg_lite_buffer_t * vgbuf, void * buf); - -/********************** - * STATIC VARIABLES - **********************/ - -static vg_lite_buffer_t _dest_buf; -static vg_lite_buffer_t _src_buf; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -vg_lite_buffer_t * vglite_get_dest_buf(void) -{ - return &_dest_buf; -} - -vg_lite_buffer_t * vglite_get_src_buf(void) -{ - return &_src_buf; -} - -void vglite_set_dest_buf_ptr(void * buf) -{ - _set_vgbuf_ptr(&_dest_buf, buf); -} - -void vglite_set_src_buf_ptr(const void * buf) -{ - _set_vgbuf_ptr(&_src_buf, (void *)buf); -} - -void vglite_set_dest_buf(const void * buf, uint32_t width, uint32_t height, uint32_t stride, - lv_color_format_t cf) -{ - vglite_set_buf(&_dest_buf, (void *)buf, width, height, stride, cf); -} - -void vglite_set_src_buf(const void * buf, uint32_t width, uint32_t height, uint32_t stride, - lv_color_format_t cf) -{ - vglite_set_buf(&_src_buf, (void *)buf, width, height, stride, cf); -} - -void vglite_set_buf(vg_lite_buffer_t * vgbuf, void * buf, - uint32_t width, uint32_t height, uint32_t stride, - lv_color_format_t cf) -{ - vg_lite_buffer_format_t vgformat = vglite_get_buf_format(cf); - - vgbuf->format = vgformat; - vgbuf->tiled = VG_LITE_LINEAR; - vgbuf->image_mode = VG_LITE_NORMAL_IMAGE_MODE; - vgbuf->transparency_mode = VG_LITE_IMAGE_OPAQUE; - - vgbuf->width = (int32_t)width; - vgbuf->height = (int32_t)height; - vgbuf->stride = (int32_t)stride; - - lv_memzero(&vgbuf->yuv, sizeof(vgbuf->yuv)); - - vgbuf->memory = buf; - vgbuf->address = (uint32_t)vgbuf->memory; - vgbuf->handle = NULL; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -static inline void _set_vgbuf_ptr(vg_lite_buffer_t * vgbuf, void * buf) -{ - vgbuf->memory = buf; - vgbuf->address = (uint32_t)vgbuf->memory; -} - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_vglite_buf.h b/src/draw/nxp/vglite/lv_vglite_buf.h deleted file mode 100644 index c15d918d00..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_buf.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file lv_vglite_buf.h - * - */ - -/** - * Copyright 2023 NXP - * - * SPDX-License-Identifier: MIT - */ - -#ifndef LV_VGLITE_BUF_H -#define LV_VGLITE_BUF_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "../../../lv_conf_internal.h" - -#if LV_USE_DRAW_VGLITE -#include "../../lv_draw.h" - -#include "vg_lite.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Get vglite destination buffer pointer. - * - * @retval The vglite destination buffer - * - */ -vg_lite_buffer_t * vglite_get_dest_buf(void); - -/** - * Get vglite source buffer pointer. - * - * @retval The vglite source buffer - * - */ -vg_lite_buffer_t * vglite_get_src_buf(void); - -/** - * Set vglite destination buffer address only. - * - * @param[in] buf Destination buffer address (does not require alignment for VG_LITE_LINEAR mode) - * - */ -void vglite_set_dest_buf_ptr(void * buf); - -/** - * Set vglite source buffer address only. - * - * @param[in] buf Source buffer address - * - */ -void vglite_set_src_buf_ptr(const void * buf); - -/** - * Set vglite destination buffer. - * - * @param[in] buf Destination buffer address - * @param[in] width Destination buffer width - * @param[in] height Destination buffer height - * @param[in] stride Destination buffer stride in bytes - * @param[in] cf Destination buffer color format - * - */ -void vglite_set_dest_buf(const void * buf, uint32_t width, uint32_t height, uint32_t stride, - lv_color_format_t cf); - -/** - * Set vglite source buffer. - * - * @param[in] buf Source buffer address - * @param[in] width Source buffer width - * @param[in] height Source buffer height - * @param[in] stride Source buffer stride in bytes - * @param[in] cf Source buffer color format - * - */ -void vglite_set_src_buf(const void * buf, uint32_t width, uint32_t height, uint32_t stride, - lv_color_format_t cf); - -/** - * Set vglite buffer. - * - * @param[in] vgbuf Address of the VGLite buffer object - * @param[in] buf Address of the memory for the VGLite buffer - * @param[in] width Buffer width - * @param[in] height Buffer height - * @param[in] stride Buffer stride in bytes - * @param[in] cf Buffer color format - * - */ -void vglite_set_buf(vg_lite_buffer_t * vgbuf, void * buf, - uint32_t width, uint32_t height, uint32_t stride, - lv_color_format_t cf); - -/********************** - * MACROS - **********************/ - -#endif /*LV_USE_DRAW_VGLITE*/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_VGLITE_BUF_H*/ diff --git a/src/draw/nxp/vglite/lv_vglite_matrix.c b/src/draw/nxp/vglite/lv_vglite_matrix.c deleted file mode 100644 index f41ed37460..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_matrix.c +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file lv_vglite_matrix.c - * - */ - -/** - * Copyright 2023 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_vglite_matrix.h" - -#if LV_USE_DRAW_VGLITE - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -static vg_lite_matrix_t _matrix; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -vg_lite_matrix_t * vglite_get_matrix(void) -{ - return &_matrix; -} - -void vglite_set_translation_matrix(const lv_area_t * dest_area) -{ - vg_lite_identity(&_matrix); - vg_lite_translate((vg_lite_float_t)dest_area->x1, (vg_lite_float_t)dest_area->y1, &_matrix); -} - -void vglite_set_transformation_matrix(const lv_area_t * dest_area, const lv_draw_image_dsc_t * dsc) -{ - vglite_set_translation_matrix(dest_area); - - bool has_scale = (dsc->scale_x != LV_SCALE_NONE || dsc->scale_y != LV_SCALE_NONE); - bool has_rotation = (dsc->rotation != 0); - - if(has_scale || has_rotation) { - vg_lite_translate(dsc->pivot.x, dsc->pivot.y, &_matrix); - if(has_rotation) - vg_lite_rotate(dsc->rotation / 10.0f, &_matrix); /* angle is 1/10 degree */ - if(has_scale) { - vg_lite_float_t scale_x = 1.0f * dsc->scale_x / LV_SCALE_NONE; - vg_lite_float_t scale_y = 1.0f * dsc->scale_y / LV_SCALE_NONE; - vg_lite_scale(scale_x, scale_y, &_matrix); - } - vg_lite_translate(0.0f - dsc->pivot.x, 0.0f - dsc->pivot.y, &_matrix); - } -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_vglite_matrix.h b/src/draw/nxp/vglite/lv_vglite_matrix.h deleted file mode 100644 index 0f735d69e2..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_matrix.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file lv_vglite_matrix.h - * - */ - -/** - * Copyright 2023 NXP - * - * SPDX-License-Identifier: MIT - */ - -#ifndef LV_VGLITE_MATRIX_H -#define LV_VGLITE_MATRIX_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "../../../lv_conf_internal.h" - -#if LV_USE_DRAW_VGLITE - -#include "../../lv_draw_image.h" -#include "../../lv_draw.h" - -#include "vg_lite.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -vg_lite_matrix_t * vglite_get_matrix(void); - -/** - * Creates matrix that translates to origin of given destination area. - * - * @param[in] dest_area Area with relative coordinates of destination buffer - * - */ -void vglite_set_translation_matrix(const lv_area_t * dest_area); - -/** - * Creates matrix that translates to origin of given destination area with transformation (scale or rotate). - * - * @param[in] dest_area Area with relative coordinates of destination buffer - * @param[in] dsc Image descriptor - * - */ -void vglite_set_transformation_matrix(const lv_area_t * dest_area, const lv_draw_image_dsc_t * dsc); - -/********************** - * MACROS - **********************/ - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_DRAW_VGLITE*/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_VGLITE_MATRIX_H*/ diff --git a/src/draw/nxp/vglite/lv_vglite_path.c b/src/draw/nxp/vglite/lv_vglite_path.c deleted file mode 100644 index 6f8b759c82..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_path.c +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @file lv_vglite_path.c - * - */ - -/** - * Copyright 2023 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_vglite_path.h" - -#if LV_USE_DRAW_VGLITE -#include "vg_lite.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void vglite_create_rect_path_data(int32_t * path_data, uint32_t * path_data_size, - int32_t radius, - const lv_area_t * coords) -{ - int32_t rect_width = lv_area_get_width(coords); - int32_t rect_height = lv_area_get_height(coords); - - /* Get the final radius. Can't be larger than the half of the shortest side */ - int32_t shortest_side = LV_MIN(rect_width, rect_height); - int32_t final_radius = LV_MIN(radius, shortest_side / 2); - - /* Path data element index */ - uint8_t pidx = 0; - - if((radius == (int32_t)LV_RADIUS_CIRCLE) && (rect_width == rect_height)) { - - /* Get the control point offset for rounded cases */ - int32_t cpoff = (int32_t)((float)final_radius * BEZIER_OPTIM_CIRCLE); - - /* Circle case */ - /* Starting point */ - path_data[pidx++] = VLC_OP_MOVE; - path_data[pidx++] = coords->x1 + final_radius; - path_data[pidx++] = coords->y1; - - /* Top-right arc */ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = cpoff; - path_data[pidx++] = 0; - path_data[pidx++] = final_radius; - path_data[pidx++] = final_radius - cpoff; - path_data[pidx++] = final_radius; - path_data[pidx++] = final_radius; - - /* Bottom-right arc*/ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = 0; - path_data[pidx++] = cpoff; - path_data[pidx++] = cpoff - final_radius; - path_data[pidx++] = final_radius; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = final_radius; - - /* Bottom-left arc */ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = 0 - cpoff; - path_data[pidx++] = 0; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = cpoff - final_radius; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = 0 - final_radius; - - /* Top-left arc*/ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = 0; - path_data[pidx++] = 0 - cpoff; - path_data[pidx++] = final_radius - cpoff; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = final_radius; - path_data[pidx++] = 0 - final_radius; - - /* Ending point */ - path_data[pidx++] = VLC_OP_END; - } - else if(radius > 0) { - /* Get the control point offset for rounded cases */ - int32_t cpoff = (int32_t)((float)final_radius * BEZIER_OPTIM_CIRCLE); - - /* Rounded rectangle case */ - /* Starting point */ - path_data[pidx++] = VLC_OP_MOVE; - path_data[pidx++] = coords->x1 + final_radius; - path_data[pidx++] = coords->y1; - - /* Top side */ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x2 - final_radius + 1; /*Extended for VGLite*/ - path_data[pidx++] = coords->y1; - - /* Top-right corner */ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = cpoff; - path_data[pidx++] = 0; - path_data[pidx++] = final_radius; - path_data[pidx++] = final_radius - cpoff; - path_data[pidx++] = final_radius; - path_data[pidx++] = final_radius; - - /* Right side */ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x2 + 1; /*Extended for VGLite*/ - path_data[pidx++] = coords->y2 - final_radius + 1; /*Extended for VGLite*/ - - /* Bottom-right corner*/ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = 0; - path_data[pidx++] = cpoff; - path_data[pidx++] = cpoff - final_radius; - path_data[pidx++] = final_radius; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = final_radius; - - /* Bottom side */ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x1 + final_radius; - path_data[pidx++] = coords->y2 + 1; /*Extended for VGLite*/ - - /* Bottom-left corner */ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = 0 - cpoff; - path_data[pidx++] = 0; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = cpoff - final_radius; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = 0 - final_radius; - - /* Left side*/ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x1; - path_data[pidx++] = coords->y1 + final_radius; - - /* Top-left corner */ - path_data[pidx++] = VLC_OP_CUBIC_REL; - path_data[pidx++] = 0; - path_data[pidx++] = 0 - cpoff; - path_data[pidx++] = final_radius - cpoff; - path_data[pidx++] = 0 - final_radius; - path_data[pidx++] = final_radius; - path_data[pidx++] = 0 - final_radius; - - /* Ending point */ - path_data[pidx++] = VLC_OP_END; - } - else { - /* Non-rounded rectangle case */ - /* Starting point */ - path_data[pidx++] = VLC_OP_MOVE; - path_data[pidx++] = coords->x1; - path_data[pidx++] = coords->y1; - - /* Top side */ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x2 + 1; /*Extended for VGLite*/ - path_data[pidx++] = coords->y1; - - /* Right side */ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x2 + 1; /*Extended for VGLite*/ - path_data[pidx++] = coords->y2 + 1; /*Extended for VGLite*/ - - /* Bottom side */ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x1; - path_data[pidx++] = coords->y2 + 1; /*Extended for VGLite*/ - - /* Left side*/ - path_data[pidx++] = VLC_OP_LINE; - path_data[pidx++] = coords->x1; - path_data[pidx++] = coords->y1; - - /* Ending point */ - path_data[pidx++] = VLC_OP_END; - } - - /* Resulting path size */ - *path_data_size = pidx * sizeof(int32_t); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_vglite_path.h b/src/draw/nxp/vglite/lv_vglite_path.h deleted file mode 100644 index a4cd21e586..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_path.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file lv_vglite_path.h - * - */ - -/** - * Copyright 2023 NXP - * - * SPDX-License-Identifier: MIT - */ - -#ifndef LV_VGLITE_PATH_H -#define LV_VGLITE_PATH_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "../../../lv_conf_internal.h" - -#if LV_USE_DRAW_VGLITE -#include "../../lv_draw.h" -#include "../../lv_draw_triangle.h" - -/********************* - * DEFINES - *********************/ - -/* The optimal Bezier control point offset for radial unit - * see: https://spencermortensen.com/articles/bezier-circle/ - **/ -#define BEZIER_OPTIM_CIRCLE 0.551915024494f - -/* Draw lines for control points of Bezier curves */ -#define BEZIER_DBG_CONTROL_POINTS 0 - -/* Path data sizes for different elements */ -#define CUBIC_PATH_DATA_SIZE 7 /* 1 opcode, 6 arguments */ -#define LINE_PATH_DATA_SIZE 3 /* 1 opcode, 2 arguments */ -#define MOVE_PATH_DATA_SIZE 3 /* 1 opcode, 2 arguments */ -#define END_PATH_DATA_SIZE 1 /* 1 opcode, 0 arguments */ -/* Maximum possible rectangle path size - * is in the rounded rectangle case: - * - 1 move for the path start - * - 4 cubics for the corners - * - 4 lines for the sides - * - 1 end for the path end */ -#define RECT_PATH_DATA_MAX_SIZE (1 * MOVE_PATH_DATA_SIZE + 4 * CUBIC_PATH_DATA_SIZE + 4 * LINE_PATH_DATA_SIZE + 1 * END_PATH_DATA_SIZE) - -/* Maximum possible arc path size - * is in the rounded arc case: - * - 1 move for the path start - * - 16 cubics for the arc (5 inner, 5 outer) and corners (3 per corner) - * - 1 end for the path end */ -#define ARC_PATH_DATA_MAX_SIZE (1 * MOVE_PATH_DATA_SIZE + 16 * CUBIC_PATH_DATA_SIZE + 1 * END_PATH_DATA_SIZE) -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/** - * Generates path data for rectangle drawing. - * - * @param[in/out] path The path data to initialize - * @param[in/out] path_size The resulting size of the created path data - * @param[in] dsc The style descriptor for the rectangle to be drawn - * @param[in] coords The coordinates of the rectangle to be drawn - * - */ -void vglite_create_rect_path_data(int32_t * path_data, uint32_t * path_data_size, - int32_t radius, - const lv_area_t * coords); - -/********************** - * MACROS - **********************/ - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_DRAW_VGLITE*/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_VGLITE_PATH_H*/ diff --git a/src/draw/nxp/vglite/lv_vglite_utils.c b/src/draw/nxp/vglite/lv_vglite_utils.c deleted file mode 100644 index af821fff12..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_utils.c +++ /dev/null @@ -1,286 +0,0 @@ -/** - * @file lv_vglite_utils.c - * - */ - -/** - * Copyright 2022-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -/********************* - * INCLUDES - *********************/ - -#include "lv_vglite_utils.h" - -#if LV_USE_DRAW_VGLITE -#include "lv_vglite_buf.h" - -#include "../../../core/lv_refr.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -#if LV_USE_VGLITE_DRAW_ASYNC - static volatile bool _cmd_buf_flushed = false; -#endif - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -const char * vglite_error_to_string(vg_lite_error_t error) -{ - switch(error) { - ENUM_TO_STRING(VG_LITE_SUCCESS); - ENUM_TO_STRING(VG_LITE_INVALID_ARGUMENT); - ENUM_TO_STRING(VG_LITE_OUT_OF_MEMORY); - ENUM_TO_STRING(VG_LITE_NO_CONTEXT); - ENUM_TO_STRING(VG_LITE_TIMEOUT); - ENUM_TO_STRING(VG_LITE_OUT_OF_RESOURCES); - ENUM_TO_STRING(VG_LITE_GENERIC_IO); - ENUM_TO_STRING(VG_LITE_NOT_SUPPORT); - ENUM_TO_STRING(VG_LITE_ALREADY_EXISTS); - ENUM_TO_STRING(VG_LITE_NOT_ALIGNED); - ENUM_TO_STRING(VG_LITE_FLEXA_TIME_OUT); - ENUM_TO_STRING(VG_LITE_FLEXA_HANDSHAKE_FAIL); - default: - break; - } - - return "VG_LITE_UNKNOWN_ERROR"; -} - -#if LV_USE_VGLITE_DRAW_ASYNC -bool vglite_cmd_buf_is_flushed(void) -{ - return _cmd_buf_flushed; -} -#endif - -void vglite_run(void) -{ -#if LV_USE_VGLITE_DRAW_ASYNC - vg_lite_uint32_t gpu_idle = 0; - - VGLITE_CHECK_ERROR(vg_lite_get_parameter(VG_LITE_GPU_IDLE_STATE, 1, (vg_lite_pointer)&gpu_idle)); - - if(!gpu_idle) { - _cmd_buf_flushed = false; - - return; - } -#endif - - /* - * If LV_USE_VGLITE_DRAW_ASYNC is enabled, simply flush the command buffer and the - * vglite draw thread will signal asynchronous the dispatcher for completed tasks. - * Without draw async, process the tasks and signal them as complete one by one. - */ -#if LV_USE_VGLITE_DRAW_ASYNC - VGLITE_CHECK_ERROR(vg_lite_flush()); - _cmd_buf_flushed = true; -#else - VGLITE_CHECK_ERROR(vg_lite_finish()); -#endif -} - -#if LV_USE_VGLITE_DRAW_ASYNC -void vglite_wait_for_finish(void) -{ - VGLITE_CHECK_ERROR(vg_lite_finish()); -} -#endif - -vg_lite_color_t vglite_get_color(lv_color32_t lv_col32, bool gradient) -{ - vg_lite_color_t vg_col32; - - /* Pre-multiply alpha */ - lv_col32.red = LV_UDIV255(lv_col32.red * lv_col32.alpha); - lv_col32.green = LV_UDIV255(lv_col32.green * lv_col32.alpha); - lv_col32.blue = LV_UDIV255(lv_col32.blue * lv_col32.alpha); - - if(!gradient) - /* The color is in ABGR8888 format with red channel in the lower 8 bits. */ - vg_col32 = ((vg_lite_color_t)lv_col32.alpha << 24) | ((vg_lite_color_t)lv_col32.blue << 16) | - ((vg_lite_color_t)lv_col32.green << 8) | (vg_lite_color_t)lv_col32.red; - else - /* The gradient color is in ARGB8888 format with blue channel in the lower 8 bits. */ - vg_col32 = ((vg_lite_color_t)lv_col32.alpha << 24) | ((vg_lite_color_t)lv_col32.red << 16) | - ((vg_lite_color_t)lv_col32.green << 8) | (vg_lite_color_t)lv_col32.blue; - - return vg_col32; -} - -vg_lite_blend_t vglite_get_blend_mode(lv_blend_mode_t lv_blend_mode) -{ - vg_lite_blend_t vg_blend_mode = VG_LITE_BLEND_NONE; - - if(vg_lite_query_feature(gcFEATURE_BIT_VG_LVGL_SUPPORT)) { - switch(lv_blend_mode) { - case LV_BLEND_MODE_NORMAL: - vg_blend_mode = VG_LITE_BLEND_NORMAL_LVGL; - break; - case LV_BLEND_MODE_ADDITIVE: - vg_blend_mode = VG_LITE_BLEND_ADDITIVE_LVGL; - break; - case LV_BLEND_MODE_SUBTRACTIVE: - vg_blend_mode = VG_LITE_BLEND_SUBTRACT_LVGL; - break; - case LV_BLEND_MODE_MULTIPLY: - vg_blend_mode = VG_LITE_BLEND_MULTIPLY_LVGL; - break; - default: - VGLITE_ASSERT_MSG(false, "Unsupported blend mode."); - break; - } - } - else { - switch(lv_blend_mode) { - case LV_BLEND_MODE_NORMAL: - vg_blend_mode = VG_LITE_BLEND_SRC_OVER; - break; - case LV_BLEND_MODE_ADDITIVE: - vg_blend_mode = VG_LITE_BLEND_ADDITIVE; - break; - case LV_BLEND_MODE_SUBTRACTIVE: - vg_blend_mode = VG_LITE_BLEND_SUBTRACT; - break; - case LV_BLEND_MODE_MULTIPLY: - vg_blend_mode = VG_LITE_BLEND_MULTIPLY; - break; - default: - VGLITE_ASSERT_MSG(false, "Unsupported blend mode."); - break; - } - } - - return vg_blend_mode; -} - -vg_lite_buffer_format_t vglite_get_buf_format(lv_color_format_t cf) -{ - vg_lite_buffer_format_t vg_buffer_format = VG_LITE_BGR565; - - switch(cf) { - case LV_COLOR_FORMAT_L8: - vg_buffer_format = VG_LITE_L8; - break; - case LV_COLOR_FORMAT_A4: - vg_buffer_format = VG_LITE_A4; - break; - case LV_COLOR_FORMAT_A8: - vg_buffer_format = VG_LITE_A8; - break; - case LV_COLOR_FORMAT_I1: - vg_buffer_format = VG_LITE_INDEX_1; - break; - case LV_COLOR_FORMAT_I2: - vg_buffer_format = VG_LITE_INDEX_2; - break; - case LV_COLOR_FORMAT_I4: - vg_buffer_format = VG_LITE_INDEX_4; - break; - case LV_COLOR_FORMAT_I8: - vg_buffer_format = VG_LITE_INDEX_8; - break; - case LV_COLOR_FORMAT_RGB565: - vg_buffer_format = VG_LITE_BGR565; - break; - case LV_COLOR_FORMAT_ARGB8565: - vg_buffer_format = VG_LITE_BGRA5658; - break; - case LV_COLOR_FORMAT_RGB888: - vg_buffer_format = VG_LITE_BGR888; - break; - case LV_COLOR_FORMAT_ARGB8888: - vg_buffer_format = VG_LITE_BGRA8888; - break; - case LV_COLOR_FORMAT_XRGB8888: - vg_buffer_format = VG_LITE_BGRX8888; - break; - - default: - VGLITE_ASSERT_MSG(false, "Unsupported color format."); - break; - } - - return vg_buffer_format; -} - -uint8_t vglite_get_stride_alignment(lv_color_format_t cf) -{ - uint8_t align_bytes = LV_COLOR_DEPTH / 8 * 16; /*16 pixels*/ - - switch(cf) { - case LV_COLOR_FORMAT_I1: - case LV_COLOR_FORMAT_I2: - case LV_COLOR_FORMAT_I4: - case LV_COLOR_FORMAT_A4: - align_bytes = 8; - break; - case LV_COLOR_FORMAT_I8: - case LV_COLOR_FORMAT_A8: - case LV_COLOR_FORMAT_L8: - align_bytes = 16; - break; - case LV_COLOR_FORMAT_RGB565: - align_bytes = 32; - break; - case LV_COLOR_FORMAT_ARGB8565: - case LV_COLOR_FORMAT_RGB888: - align_bytes = 48; - break; - case LV_COLOR_FORMAT_ARGB8888: - case LV_COLOR_FORMAT_XRGB8888: - align_bytes = 64; - break; - - default: - VGLITE_ASSERT_MSG(false, "Unsupported buffer format."); - break; - } - - return align_bytes; -} - -bool vglite_src_buf_aligned(const void * buf, uint32_t stride, lv_color_format_t cf) -{ - /* No alignment requirement for destination buffer when using mode VG_LITE_LINEAR */ - - /* Test for pointer alignment */ - if((uintptr_t)buf % LV_ATTRIBUTE_MEM_ALIGN_SIZE) - return false; - - /* Test for stride alignment */ - if(stride == 0 || stride % vglite_get_stride_alignment(cf)) - return false; - - return true; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_DRAW_VGLITE*/ diff --git a/src/draw/nxp/vglite/lv_vglite_utils.h b/src/draw/nxp/vglite/lv_vglite_utils.h deleted file mode 100644 index c61e04ecdf..0000000000 --- a/src/draw/nxp/vglite/lv_vglite_utils.h +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @file lv_vglite_utils.h - * - */ - -/** - * Copyright 2022-2024 NXP - * - * SPDX-License-Identifier: MIT - */ - -#ifndef LV_VGLITE_UTILS_H -#define LV_VGLITE_UTILS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "../../../lv_conf_internal.h" - -#if LV_USE_DRAW_VGLITE -#include "../../lv_draw.h" - -#include "vg_lite.h" -#include "vg_lite_options.h" - -/********************* - * DEFINES - *********************/ - -#define ENUM_TO_STRING(e) \ - case (e): \ - return #e - -#if LV_USE_VGLITE_ASSERT -#define VGLITE_ASSERT(expr) LV_ASSERT(expr) -#else -#define VGLITE_ASSERT(expr) -#endif - -#define VGLITE_ASSERT_MSG(expr, msg) \ - do { \ - if(!(expr)) { \ - LV_LOG_ERROR(msg); \ - VGLITE_ASSERT(false); \ - } \ - } while(0) - -#if LV_USE_VGLITE_CHECK_ERROR -#define VGLITE_CHECK_ERROR(function) \ - do { \ - vg_lite_error_t error = function; \ - if(error != VG_LITE_SUCCESS) { \ - LV_LOG_ERROR("Execute '" #function "' error(%d): %s", \ - (int)error, vglite_error_to_string(error)); \ - VGLITE_ASSERT(false); \ - } \ - } while (0) -#else -#define VGLITE_CHECK_ERROR(function) function -#endif - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/** - * Set the clipping box. - * - * @param[in] clip_area Clip area with relative coordinates of destination buffer - * - */ -static inline void vglite_set_scissor(const lv_area_t * clip_area); - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -const char * vglite_error_to_string(vg_lite_error_t error); - -#if LV_USE_VGLITE_DRAW_ASYNC -/** - * Get VG-Lite command buffer flushed status. - * - */ -bool vglite_cmd_buf_is_flushed(void); -#endif - -/** - * Flush command to VG-Lite. - * - */ -void vglite_run(void); - -/** - * Wait for VG-Lite finish. - * - */ -#if LV_USE_VGLITE_DRAW_ASYNC -void vglite_wait_for_finish(void); -#endif - -/** - * Get vglite color. Premultiplies (if not hw already) and swizzles the given - * LVGL 32bit color to obtain vglite color. - * - * @param[in] lv_col32 The initial LVGL 32bit color - * @param[in] gradient True for gradient color - * - * @retval The vglite 32-bit color value: - * - */ -vg_lite_color_t vglite_get_color(lv_color32_t lv_col32, bool gradient); - -/** - * Get vglite blend mode. - * - * @param[in] lv_blend_mode The LVGL blend mode - * - * @retval The vglite blend mode - * - */ -vg_lite_blend_t vglite_get_blend_mode(lv_blend_mode_t lv_blend_mode); - -/** - * Get vglite buffer format. - * - * @param[in] cf Color format - * - * @retval The vglite buffer format - * - */ -vg_lite_buffer_format_t vglite_get_buf_format(lv_color_format_t cf); - -/** - * Get vglite stride alignment. - * - * @param[in] cf Color format - * - * @retval Alignment requirement in bytes - * - */ -uint8_t vglite_get_stride_alignment(lv_color_format_t cf); - -/** - * Check source start address and stride alignment. - * - * @param[in] buf Buffer address - * @param[in] stride Stride of buffer in bytes - * @param[in] cf Color format - to calculate the expected alignment - * - * @retval true Alignment OK - * - */ -bool vglite_src_buf_aligned(const void * buf, uint32_t stride, lv_color_format_t cf); - -/********************** - * MACROS - **********************/ - -/********************** - * STATIC FUNCTIONS - **********************/ - -static inline void vglite_set_scissor(const lv_area_t * clip_area) -{ - vg_lite_set_scissor(clip_area->x1, clip_area->y1, clip_area->x2 + 1, clip_area->y2 + 1); -} - -#endif /*LV_USE_DRAW_VGLITE*/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_VGLITE_UTILS_H*/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 588f9f8678..96c7d2274c 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -701,74 +701,6 @@ #endif #endif -/** Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ -#ifndef LV_USE_DRAW_VGLITE - #ifdef CONFIG_LV_USE_DRAW_VGLITE - #define LV_USE_DRAW_VGLITE CONFIG_LV_USE_DRAW_VGLITE - #else - #define LV_USE_DRAW_VGLITE 0 - #endif -#endif - -#if LV_USE_DRAW_VGLITE - /** Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ - #ifndef LV_USE_VGLITE_BLIT_SPLIT - #ifdef CONFIG_LV_USE_VGLITE_BLIT_SPLIT - #define LV_USE_VGLITE_BLIT_SPLIT CONFIG_LV_USE_VGLITE_BLIT_SPLIT - #else - #define LV_USE_VGLITE_BLIT_SPLIT 0 - #endif - #endif - - #if LV_USE_OS - /** Use additional draw thread for VG-Lite processing. */ - #ifndef LV_USE_VGLITE_DRAW_THREAD - #ifdef LV_KCONFIG_PRESENT - #ifdef CONFIG_LV_USE_VGLITE_DRAW_THREAD - #define LV_USE_VGLITE_DRAW_THREAD CONFIG_LV_USE_VGLITE_DRAW_THREAD - #else - #define LV_USE_VGLITE_DRAW_THREAD 0 - #endif - #else - #define LV_USE_VGLITE_DRAW_THREAD 1 - #endif - #endif - - #if LV_USE_VGLITE_DRAW_THREAD - /** Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ - #ifndef LV_USE_VGLITE_DRAW_ASYNC - #ifdef LV_KCONFIG_PRESENT - #ifdef CONFIG_LV_USE_VGLITE_DRAW_ASYNC - #define LV_USE_VGLITE_DRAW_ASYNC CONFIG_LV_USE_VGLITE_DRAW_ASYNC - #else - #define LV_USE_VGLITE_DRAW_ASYNC 0 - #endif - #else - #define LV_USE_VGLITE_DRAW_ASYNC 1 - #endif - #endif - #endif - #endif - - /** Enable VGLite asserts. */ - #ifndef LV_USE_VGLITE_ASSERT - #ifdef CONFIG_LV_USE_VGLITE_ASSERT - #define LV_USE_VGLITE_ASSERT CONFIG_LV_USE_VGLITE_ASSERT - #else - #define LV_USE_VGLITE_ASSERT 0 - #endif - #endif - - /** Enable VGLite error checks. */ - #ifndef LV_USE_VGLITE_CHECK_ERROR - #ifdef CONFIG_LV_USE_VGLITE_CHECK_ERROR - #define LV_USE_VGLITE_CHECK_ERROR CONFIG_LV_USE_VGLITE_CHECK_ERROR - #else - #define LV_USE_VGLITE_CHECK_ERROR 0 - #endif - #endif -#endif - /** Use NXP's PXP on iMX RTxxx platforms. */ #ifndef LV_USE_PXP #ifdef CONFIG_LV_USE_PXP @@ -897,7 +829,6 @@ #define LV_USE_DRAW_VG_LITE 0 #endif #endif - #if LV_USE_DRAW_VG_LITE /** Enable VG-Lite custom external 'gpu_init()' function */ #ifndef LV_VG_LITE_USE_GPU_INIT @@ -977,6 +908,113 @@ #define LV_VG_LITE_DISABLE_LINEAR_GRADIENT_EXT 0 #endif #endif + + /** Enable usage of the LVGL's built-in vg_lite driver */ + #ifndef LV_USE_VG_LITE_DRIVER + #ifdef CONFIG_LV_USE_VG_LITE_DRIVER + #define LV_USE_VG_LITE_DRIVER CONFIG_LV_USE_VG_LITE_DRIVER + #else + #define LV_USE_VG_LITE_DRIVER 0 + #endif + #endif + #if LV_USE_VG_LITE_DRIVER + /** Used to pick the correct GPU series folder valid options are gc255, gc355 and gc555*/ + #ifndef LV_VG_LITE_HAL_GPU_SERIES + #ifdef CONFIG_LV_VG_LITE_HAL_GPU_SERIES + #define LV_VG_LITE_HAL_GPU_SERIES CONFIG_LV_VG_LITE_HAL_GPU_SERIES + #else + #define LV_VG_LITE_HAL_GPU_SERIES gc255 + #endif + #endif + + /** Used to pick the correct GPU revision header it depends on the vendor */ + #ifndef LV_VG_LITE_HAL_GPU_REVISION + #ifdef CONFIG_LV_VG_LITE_HAL_GPU_REVISION + #define LV_VG_LITE_HAL_GPU_REVISION CONFIG_LV_VG_LITE_HAL_GPU_REVISION + #else + #define LV_VG_LITE_HAL_GPU_REVISION 0x40 + #endif + #endif + + /** Base memory address of the GPU IP it depends on SoC, + * default value is for NXP based devices */ + #ifndef LV_VG_LITE_HAL_GPU_BASE_ADDRESS + #ifdef CONFIG_LV_VG_LITE_HAL_GPU_BASE_ADDRESS + #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS CONFIG_LV_VG_LITE_HAL_GPU_BASE_ADDRESS + #else + #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS 0x40240000 + #endif + #endif + #endif /*LV_USE_VG_LITE_DRIVER*/ + + /** Use ThorVG (a software vector library) as VG-Lite driver to allow testing VGLite on PC + * Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ + #ifndef LV_USE_VG_LITE_THORVG + #ifdef CONFIG_LV_USE_VG_LITE_THORVG + #define LV_USE_VG_LITE_THORVG CONFIG_LV_USE_VG_LITE_THORVG + #else + #define LV_USE_VG_LITE_THORVG 0 + #endif + #endif + #if LV_USE_VG_LITE_THORVG + /** Enable LVGL's blend mode support */ + #ifndef LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT + #ifdef CONFIG_LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT + #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT CONFIG_LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT + #else + #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 + #endif + #endif + + /** Enable YUV color format support */ + #ifndef LV_VG_LITE_THORVG_YUV_SUPPORT + #ifdef CONFIG_LV_VG_LITE_THORVG_YUV_SUPPORT + #define LV_VG_LITE_THORVG_YUV_SUPPORT CONFIG_LV_VG_LITE_THORVG_YUV_SUPPORT + #else + #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 + #endif + #endif + + /** Enable Linear gradient extension support */ + #ifndef LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT + #ifdef CONFIG_LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT + #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT CONFIG_LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT + #else + #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 + #endif + #endif + + /** Enable alignment on 16 pixels */ + #ifndef LV_VG_LITE_THORVG_16PIXELS_ALIGN + #ifdef LV_KCONFIG_PRESENT + #ifdef CONFIG_LV_VG_LITE_THORVG_16PIXELS_ALIGN + #define LV_VG_LITE_THORVG_16PIXELS_ALIGN CONFIG_LV_VG_LITE_THORVG_16PIXELS_ALIGN + #else + #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 0 + #endif + #else + #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 + #endif + #endif + + /** Buffer address alignment */ + #ifndef LV_VG_LITE_THORVG_BUF_ADDR_ALIGN + #ifdef CONFIG_LV_VG_LITE_THORVG_BUF_ADDR_ALIGN + #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN CONFIG_LV_VG_LITE_THORVG_BUF_ADDR_ALIGN + #else + #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 + #endif + #endif + + /** Enable multi-thread render */ + #ifndef LV_VG_LITE_THORVG_THREAD_RENDER + #ifdef CONFIG_LV_VG_LITE_THORVG_THREAD_RENDER + #define LV_VG_LITE_THORVG_THREAD_RENDER CONFIG_LV_VG_LITE_THORVG_THREAD_RENDER + #else + #define LV_VG_LITE_THORVG_THREAD_RENDER 0 + #endif + #endif + #endif /*LV_USE_VG_LITE_THORVG*/ #endif /** Accelerate blends, fills, etc. with STM32 DMA2D */ @@ -987,7 +1025,6 @@ #define LV_USE_DRAW_DMA2D 0 #endif #endif - #if LV_USE_DRAW_DMA2D #ifndef LV_DRAW_DMA2D_HAL_INCLUDE #ifdef CONFIG_LV_DRAW_DMA2D_HAL_INCLUDE @@ -1017,7 +1054,6 @@ #define LV_USE_DRAW_OPENGLES 0 #endif #endif - #if LV_USE_DRAW_OPENGLES #ifndef LV_DRAW_OPENGLES_TEXTURE_CACHE_COUNT #ifdef CONFIG_LV_DRAW_OPENGLES_TEXTURE_CACHE_COUNT @@ -1054,7 +1090,6 @@ #define LV_USE_DRAW_EVE 0 #endif #endif - #if LV_USE_DRAW_EVE /* EVE_GEN value: 2, 3, or 4 */ #ifndef LV_DRAW_EVE_EVE_GENERATION @@ -1488,116 +1523,6 @@ #endif #endif -/* Use VG-Lite Simulator. - * - Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ -#ifndef LV_USE_VG_LITE_THORVG - #ifdef CONFIG_LV_USE_VG_LITE_THORVG - #define LV_USE_VG_LITE_THORVG CONFIG_LV_USE_VG_LITE_THORVG - #else - #define LV_USE_VG_LITE_THORVG 0 - #endif -#endif - -#if LV_USE_VG_LITE_THORVG - /** Enable LVGL's blend mode support */ - #ifndef LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT - #ifdef CONFIG_LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT - #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT CONFIG_LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT - #else - #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 - #endif - #endif - - /** Enable YUV color format support */ - #ifndef LV_VG_LITE_THORVG_YUV_SUPPORT - #ifdef CONFIG_LV_VG_LITE_THORVG_YUV_SUPPORT - #define LV_VG_LITE_THORVG_YUV_SUPPORT CONFIG_LV_VG_LITE_THORVG_YUV_SUPPORT - #else - #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 - #endif - #endif - - /** Enable Linear gradient extension support */ - #ifndef LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT - #ifdef CONFIG_LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT - #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT CONFIG_LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT - #else - #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 - #endif - #endif - - /** Enable alignment on 16 pixels */ - #ifndef LV_VG_LITE_THORVG_16PIXELS_ALIGN - #ifdef LV_KCONFIG_PRESENT - #ifdef CONFIG_LV_VG_LITE_THORVG_16PIXELS_ALIGN - #define LV_VG_LITE_THORVG_16PIXELS_ALIGN CONFIG_LV_VG_LITE_THORVG_16PIXELS_ALIGN - #else - #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 0 - #endif - #else - #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 - #endif - #endif - - /** Buffer address alignment */ - #ifndef LV_VG_LITE_THORVG_BUF_ADDR_ALIGN - #ifdef CONFIG_LV_VG_LITE_THORVG_BUF_ADDR_ALIGN - #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN CONFIG_LV_VG_LITE_THORVG_BUF_ADDR_ALIGN - #else - #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 - #endif - #endif - - /** Enable multi-thread render */ - #ifndef LV_VG_LITE_THORVG_THREAD_RENDER - #ifdef CONFIG_LV_VG_LITE_THORVG_THREAD_RENDER - #define LV_VG_LITE_THORVG_THREAD_RENDER CONFIG_LV_VG_LITE_THORVG_THREAD_RENDER - #else - #define LV_VG_LITE_THORVG_THREAD_RENDER 0 - #endif - #endif -#endif - -/* Enable usage of the LVGL's vg_lite spec driver */ -#ifndef LV_USE_VG_LITE_DRIVER - #ifdef CONFIG_LV_USE_VG_LITE_DRIVER - #define LV_USE_VG_LITE_DRIVER CONFIG_LV_USE_VG_LITE_DRIVER - #else - #define LV_USE_VG_LITE_DRIVER 0 - #endif -#endif - -#if LV_USE_VG_LITE_DRIVER - - /* Used to pick the correct GPU series folder valid options are gc255, gc355 and gc555*/ - #ifndef LV_VG_LITE_HAL_GPU_SERIES - #ifdef CONFIG_LV_VG_LITE_HAL_GPU_SERIES - #define LV_VG_LITE_HAL_GPU_SERIES CONFIG_LV_VG_LITE_HAL_GPU_SERIES - #else - #define LV_VG_LITE_HAL_GPU_SERIES gc255 - #endif - #endif - - /* Used to pick the correct GPU revision header it depends on the vendor */ - #ifndef LV_VG_LITE_HAL_GPU_REVISION - #ifdef CONFIG_LV_VG_LITE_HAL_GPU_REVISION - #define LV_VG_LITE_HAL_GPU_REVISION CONFIG_LV_VG_LITE_HAL_GPU_REVISION - #else - #define LV_VG_LITE_HAL_GPU_REVISION 0x40 - #endif - #endif - - /* Base memory address of the GPU IP it depends on SoC, default value is for NXP based devices */ - #ifndef LV_VG_LITE_HAL_GPU_BASE_ADDRESS - #ifdef CONFIG_LV_VG_LITE_HAL_GPU_BASE_ADDRESS - #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS CONFIG_LV_VG_LITE_HAL_GPU_BASE_ADDRESS - #else - #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS 0x40240000 - #endif - #endif - -#endif - /* Enable the multi-touch gesture recognition feature */ /* Gesture recognition requires the use of floats */ #ifndef LV_USE_GESTURE_RECOGNITION @@ -3205,7 +3130,7 @@ #endif /** Enable Vector Graphic APIs - * - Requires `LV_USE_MATRIX = 1` */ + * Requires `LV_USE_MATRIX = 1` */ #ifndef LV_USE_VECTOR_GRAPHIC #ifdef CONFIG_LV_USE_VECTOR_GRAPHIC #define LV_USE_VECTOR_GRAPHIC CONFIG_LV_USE_VECTOR_GRAPHIC @@ -3214,7 +3139,8 @@ #endif #endif -/** Enable ThorVG (vector graphics library) from the src/libs folder */ +/** Enable ThorVG (vector graphics library) from the src/libs folder. + * Requires LV_USE_VECTOR_GRAPHIC */ #ifndef LV_USE_THORVG_INTERNAL #ifdef CONFIG_LV_USE_THORVG_INTERNAL #define LV_USE_THORVG_INTERNAL CONFIG_LV_USE_THORVG_INTERNAL @@ -3223,6 +3149,16 @@ #endif #endif +/** Enable ThorVG by assuming that its installed and linked to the project + * Requires LV_USE_VECTOR_GRAPHIC */ +#ifndef LV_USE_THORVG_EXTERNAL + #ifdef CONFIG_LV_USE_THORVG_EXTERNAL + #define LV_USE_THORVG_EXTERNAL CONFIG_LV_USE_THORVG_EXTERNAL + #else + #define LV_USE_THORVG_EXTERNAL 0 + #endif +#endif + /** Enable ThorVG by assuming that its installed and linked to the project */ #ifndef LV_USE_THORVG_EXTERNAL #ifdef CONFIG_LV_USE_THORVG_EXTERNAL @@ -4746,6 +4682,15 @@ LV_EXPORT_CONST_INT(LV_DRAW_BUF_ALIGN); #undef LV_KCONFIG_PRESENT +/* Disable VGLite drivers if VGLite drawing is disabled */ +#ifndef LV_USE_VG_LITE_DRIVER + #define LV_USE_VG_LITE_DRIVER 0 +#endif + +#ifndef LV_USE_VG_LITE_THORVG + #define LV_USE_VG_LITE_THORVG 0 +#endif + /* Set some defines if a dependency is disabled. */ #if LV_USE_LOG == 0 #define LV_LOG_LEVEL LV_LOG_LEVEL_NONE diff --git a/src/lv_init.c b/src/lv_init.c index 2afbacb098..d0ca348e5b 100644 --- a/src/lv_init.c +++ b/src/lv_init.c @@ -49,9 +49,6 @@ #if LV_USE_NEMA_GFX #include "draw/nema_gfx/lv_draw_nema_gfx.h" #endif -#if LV_USE_DRAW_VGLITE - #include "draw/nxp/vglite/lv_draw_vglite.h" -#endif #if LV_USE_PXP #if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP #include "draw/nxp/pxp/lv_draw_pxp.h" @@ -241,10 +238,6 @@ void lv_init(void) lv_draw_nema_gfx_init(); #endif -#if LV_USE_DRAW_VGLITE - lv_draw_vglite_init(); -#endif - #if LV_USE_PXP #if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP lv_draw_pxp_init(); @@ -478,10 +471,6 @@ void lv_deinit(void) #endif #endif -#if LV_USE_DRAW_VGLITE - lv_draw_vglite_deinit(); -#endif - #if LV_USE_DRAW_G2D lv_draw_g2d_deinit(); #endif diff --git a/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c b/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c index 188f361470..b64c1858ca 100644 --- a/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c +++ b/tests/src/test_cases/draw/test_render_to_argb8888_premultiplied.c @@ -31,7 +31,7 @@ void test_render_to_argb8888_premultiplied(void) * also skip normal_3 and recolor_3 on VGLite * because RGB565A8 and I8 are not supported */ - if((LV_BIN_DECODER_RAM_LOAD == 0 || LV_USE_DRAW_VGLITE == 0) && + if((LV_BIN_DECODER_RAM_LOAD == 0 || LV_USE_DRAW_VG_LITE) && (i == LV_DEMO_RENDER_SCENE_IMAGE_NORMAL_3 || i == LV_DEMO_RENDER_SCENE_IMAGE_RECOLOR_3)) continue;