feat(vglite): refactor driver config and remove NXP VGLite draw unit (#8911)

This commit is contained in:
Gabor Kiss-Vamosi
2025-09-26 11:41:57 +02:00
committed by GitHub
parent f178e7b1ed
commit 48a1ea968a
26 changed files with 183 additions and 4832 deletions
-31
View File
@@ -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
-21
View File
@@ -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
+44 -70
View File
@@ -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
+9
View File
@@ -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
-131
View File
@@ -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*/
File diff suppressed because it is too large Load Diff
-101
View File
@@ -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*/
File diff suppressed because it is too large Load Diff
-248
View File
@@ -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 <math.h>
/*********************
* 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*/
-269
View File
@@ -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*/
-449
View File
@@ -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*/
-270
View File
@@ -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*/
-156
View File
@@ -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*/
-169
View File
@@ -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*/
@@ -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*/
-116
View File
@@ -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*/
-124
View File
@@ -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*/
-81
View File
@@ -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*/
-80
View File
@@ -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*/
-217
View File
@@ -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*/
-98
View File
@@ -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*/
-286
View File
@@ -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*/
-183
View File
@@ -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*/
+129 -184
View File
@@ -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
-11
View File
@@ -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
@@ -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;