initial commit

This commit is contained in:
Carter Essen committed 2026-11-09 17:35:03 -05:00
commit cff2a21efc
550 files changed
+154887

No files matched your search

@@ -0,0 +1,49 @@
/**
* @file lv_draw_dma2d.h
*
*/
#ifndef LV_DRAW_DMA2D_H
#define LV_DRAW_DMA2D_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_DRAW_DMA2D
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_dma2d_init(void);
void lv_draw_dma2d_deinit(void);
#if LV_USE_DRAW_DMA2D_INTERRUPT
void lv_draw_dma2d_transfer_complete_interrupt_handler(void);
#endif
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_DMA2D*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_DMA2D_H*/
@@ -0,0 +1,155 @@
/**
* @file lv_draw_dma2d_private.h
*
*/
#ifndef LV_DRAW_DMA2D_PRIVATE_H
#define LV_DRAW_DMA2D_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_dma2d.h"
#if LV_USE_DRAW_DMA2D
#include "../lv_draw_private.h"
#include LV_DRAW_DMA2D_HAL_INCLUDE
/*********************
* DEFINES
*********************/
#if LV_USE_DRAW_DMA2D_INTERRUPT && LV_USE_OS
#define LV_DRAW_DMA2D_ASYNC 1
#else
#define LV_DRAW_DMA2D_ASYNC 0
#endif
#if defined(__CORTEX_M) && (__CORTEX_M == 7)
#define LV_DRAW_DMA2D_CACHE 1
#else
#define LV_DRAW_DMA2D_CACHE 0
#endif
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_DRAW_DMA2D_OUTPUT_CF_ARGB8888 = 0,
LV_DRAW_DMA2D_OUTPUT_CF_RGB888,
LV_DRAW_DMA2D_OUTPUT_CF_RGB565,
LV_DRAW_DMA2D_OUTPUT_CF_ARGB1555,
LV_DRAW_DMA2D_OUTPUT_CF_ARGB4444
} lv_draw_dma2d_output_cf_t;
typedef enum {
LV_DRAW_DMA2D_FGBG_CF_ARGB8888 = 0,
LV_DRAW_DMA2D_FGBG_CF_RGB888,
LV_DRAW_DMA2D_FGBG_CF_RGB565,
LV_DRAW_DMA2D_FGBG_CF_ARGB1555,
LV_DRAW_DMA2D_FGBG_CF_ARGB4444,
LV_DRAW_DMA2D_FGBG_CF_L8,
LV_DRAW_DMA2D_FGBG_CF_AL44,
LV_DRAW_DMA2D_FGBG_CF_AL88,
LV_DRAW_DMA2D_FGBG_CF_L4,
LV_DRAW_DMA2D_FGBG_CF_A8,
LV_DRAW_DMA2D_FGBG_CF_A4,
LV_DRAW_DMA2D_FGBG_CF_YCBCR
} lv_draw_dma2d_fgbg_cf_t;
typedef enum {
LV_DRAW_DMA2D_MODE_MEMORY_TO_MEMORY = 0,
LV_DRAW_DMA2D_MODE_MEMORY_TO_MEMORY_WITH_PFC,
LV_DRAW_DMA2D_MODE_MEMORY_TO_MEMORY_WITH_BLENDING,
LV_DRAW_DMA2D_MODE_REGISTER_TO_MEMORY,
LV_DRAW_DMA2D_MODE_MEMORY_TO_MEMORY_WITH_BLENDING_AND_FIXED_COLOR_FG,
LV_DRAW_DMA2D_MODE_MEMORY_TO_MEMORY_WITH_BLENDING_AND_FIXED_COLOR_BG
} lv_draw_dma2d_mode_t;
typedef enum {
LV_DRAW_DMA2D_ALPHA_MODE_NO_MODIFY_IMAGE_ALPHA_CHANNEL = 0,
LV_DRAW_DMA2D_ALPHA_MODE_REPLACE_ALPHA_CHANNEL,
LV_DRAW_DMA2D_ALPHA_MODE_MULTIPLY_IMAGE_ALPHA_CHANNEL
} lv_draw_dma2d_alpha_mode_t;
typedef struct {
lv_draw_dma2d_mode_t mode;
uint32_t w;
uint32_t h;
void * output_address;
uint32_t output_offset;
lv_draw_dma2d_output_cf_t output_cf;
uint32_t reg_to_mem_mode_color;
const void * fg_address;
uint32_t fg_offset;
lv_draw_dma2d_fgbg_cf_t fg_cf;
uint32_t fg_color;
uint32_t fg_alpha_mode;
uint32_t fg_alpha;
const void * bg_address;
uint32_t bg_offset;
lv_draw_dma2d_fgbg_cf_t bg_cf;
uint32_t bg_color;
uint32_t bg_alpha_mode;
uint32_t bg_alpha;
} lv_draw_dma2d_configuration_t;
typedef struct {
const void * first_byte;
uint32_t width_bytes;
uint32_t height;
uint32_t stride;
} lv_draw_dma2d_cache_area_t;
typedef struct {
lv_draw_unit_t base_unit;
lv_draw_task_t * volatile task_act;
#if LV_DRAW_DMA2D_CACHE
lv_draw_dma2d_cache_area_t writing_area;
#endif
#if LV_DRAW_DMA2D_ASYNC
lv_thread_t thread;
lv_thread_sync_t interrupt_signal;
#endif
} lv_draw_dma2d_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_dma2d_opaque_fill(lv_draw_dma2d_unit_t * u, void * first_pixel, int32_t w, int32_t h, int32_t stride);
void lv_draw_dma2d_fill(lv_draw_dma2d_unit_t * u, void * first_pixel, int32_t w, int32_t h, int32_t stride);
void lv_draw_dma2d_opaque_image(lv_draw_dma2d_unit_t * u, void * dest_first_pixel, lv_area_t * clipped_coords,
int32_t dest_stride);
void lv_draw_dma2d_image(lv_draw_dma2d_unit_t * u, void * dest_first_pixel, lv_area_t * clipped_coords,
int32_t dest_stride);
lv_draw_dma2d_output_cf_t lv_draw_dma2d_cf_to_dma2d_output_cf(lv_color_format_t cf);
uint32_t lv_draw_dma2d_color_to_dma2d_ocolr(lv_draw_dma2d_output_cf_t cf, lv_color_t color);
void lv_draw_dma2d_configure_and_start_transfer(const lv_draw_dma2d_configuration_t * conf);
#if LV_DRAW_DMA2D_CACHE
void lv_draw_dma2d_invalidate_cache(const lv_draw_dma2d_cache_area_t * mem_area);
void lv_draw_dma2d_clean_cache(const lv_draw_dma2d_cache_area_t * mem_area);
#endif
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_DMA2D*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_DMA2D_PRIVATE_H*/
+283
View File
@@ -0,0 +1,283 @@
/**
* @file lv_draw.h
*
*/
/**
* Modified by NXP in 2024
*/
#ifndef LV_DRAW_H
#define LV_DRAW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include "../misc/lv_types.h"
#include "../misc/lv_style.h"
#include "../misc/lv_text.h"
#include "../misc/lv_profiler.h"
#include "../misc/lv_matrix.h"
#include "lv_image_decoder.h"
#include "../osal/lv_os.h"
#include "lv_draw_buf.h"
/*********************
* DEFINES
*********************/
#define LV_DRAW_UNIT_NONE 0
#define LV_DRAW_UNIT_IDLE -1 /**< The draw unit is idle, new dispatching might be requested to try again */
#if LV_DRAW_TRANSFORM_USE_MATRIX
#if !LV_USE_MATRIX
#error "LV_DRAW_TRANSFORM_USE_MATRIX requires LV_USE_MATRIX = 1"
#endif
#endif
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_DRAW_TASK_TYPE_NONE = 0,
LV_DRAW_TASK_TYPE_FILL,
LV_DRAW_TASK_TYPE_BORDER,
LV_DRAW_TASK_TYPE_BOX_SHADOW,
LV_DRAW_TASK_TYPE_LABEL,
LV_DRAW_TASK_TYPE_IMAGE,
LV_DRAW_TASK_TYPE_LAYER,
LV_DRAW_TASK_TYPE_LINE,
LV_DRAW_TASK_TYPE_ARC,
LV_DRAW_TASK_TYPE_TRIANGLE,
LV_DRAW_TASK_TYPE_MASK_RECTANGLE,
LV_DRAW_TASK_TYPE_MASK_BITMAP,
LV_DRAW_TASK_TYPE_VECTOR,
} lv_draw_task_type_t;
typedef enum {
LV_DRAW_TASK_STATE_WAITING, /*Waiting for something to be finished. E.g. rendering a layer*/
LV_DRAW_TASK_STATE_QUEUED,
LV_DRAW_TASK_STATE_IN_PROGRESS,
LV_DRAW_TASK_STATE_READY,
} lv_draw_task_state_t;
struct _lv_layer_t {
/** Target draw buffer of the layer*/
lv_draw_buf_t * draw_buf;
/** The absolute coordinates of the buffer */
lv_area_t buf_area;
/** The color format of the layer. LV_COLOR_FORMAT_... */
lv_color_format_t color_format;
/**
* NEVER USE IT DRAW UNITS. USED INTERNALLY DURING DRAW TASK CREATION.
* The current clip area with absolute coordinates, always the same or smaller than `buf_area`
* Can be set before new draw tasks are added to indicate the clip area of the draw tasks.
* Therefore `lv_draw_add_task()` always saves it in the new draw task to know the clip area when the draw task was added.
* During drawing the draw units also sees the saved clip_area and should use it during drawing.
* During drawing the layer's clip area shouldn't be used as it might be already changed for other draw tasks.
*/
lv_area_t _clip_area;
/**
* The physical clipping area relative to the display.
*/
lv_area_t phy_clip_area;
#if LV_DRAW_TRANSFORM_USE_MATRIX
/** Transform matrix to be applied when rendering the layer */
lv_matrix_t matrix;
#endif
/** Linked list of draw tasks */
lv_draw_task_t * draw_task_head;
lv_layer_t * parent;
lv_layer_t * next;
bool all_tasks_added;
void * user_data;
};
typedef struct {
lv_obj_t * obj;
lv_part_t part;
uint32_t id1;
uint32_t id2;
lv_layer_t * layer;
size_t dsc_size;
void * user_data;
} lv_draw_dsc_base_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Used internally to initialize the drawing module
*/
void lv_draw_init(void);
/**
* Deinitialize the drawing module
*/
void lv_draw_deinit(void);
/**
* Allocate a new draw unit with the given size and appends it to the list of draw units
* @param size the size to allocate. E.g. `sizeof(my_draw_unit_t)`,
* where the first element of `my_draw_unit_t` is `lv_draw_unit_t`.
*/
void * lv_draw_create_unit(size_t size);
/**
* Add an empty draw task to the draw task list of a layer.
* @param layer pointer to a layer
* @param coords the coordinates of the draw task
* @return the created draw task which needs to be
* further configured e.g. by added a draw descriptor
*/
lv_draw_task_t * lv_draw_add_task(lv_layer_t * layer, const lv_area_t * coords);
/**
* Needs to be called when a draw task is created and configured.
* It will send an event about the new draw task to the widget
* and assign it to a draw unit.
* @param layer pointer to a layer
* @param t pointer to a draw task
*/
void lv_draw_finalize_task_creation(lv_layer_t * layer, lv_draw_task_t * t);
/**
* Try dispatching draw tasks to draw units
*/
void lv_draw_dispatch(void);
/**
* Used internally to try dispatching draw tasks of a specific layer
* @param disp pointer to a display on which the dispatching was requested
* @param layer pointer to a layer
* @return at least one draw task is being rendered (maybe it was taken earlier)
*/
bool lv_draw_dispatch_layer(lv_display_t * disp, lv_layer_t * layer);
/**
* Wait for a new dispatch request.
* It's blocking if `LV_USE_OS == 0` else it yields
*/
void lv_draw_dispatch_wait_for_request(void);
/**
* Wait for draw finish in case of asynchronous task execution.
* If `LV_USE_OS == 0` it just return.
*/
void lv_draw_wait_for_finish(void);
/**
* When a draw unit finished a draw task it needs to request dispatching
* to let LVGL assign a new draw task to it
*/
void lv_draw_dispatch_request(void);
/**
* Get the total number of draw units.
*/
uint32_t lv_draw_get_unit_count(void);
/**
* Find and available draw task
* @param layer the draw ctx to search in
* @param t_prev continue searching from this task
* @param draw_unit_id check the task where `preferred_draw_unit_id` equals this value or `LV_DRAW_UNIT_NONE`
* @return tan available draw task or NULL if there is no any
*/
lv_draw_task_t * lv_draw_get_next_available_task(lv_layer_t * layer, lv_draw_task_t * t_prev, uint8_t draw_unit_id);
/**
* Tell how many draw task are waiting to be drawn on the area of `t_check`.
* It can be used to determine if a GPU shall combine many draw tasks into one or not.
* If a lot of tasks are waiting for the current ones it makes sense to draw them one-by-one
* to not block the dependent tasks' rendering
* @param t_check the task whose dependent tasks shall be counted
* @return number of tasks depending on `t_check`
*/
uint32_t lv_draw_get_dependent_count(lv_draw_task_t * t_check);
/**
* Create (allocate) a new layer on a parent layer
* @param parent_layer the parent layer to which the layer will be merged when it's rendered
* @param color_format the color format of the layer
* @param area the areas of the layer (absolute coordinates)
* @return the new target_layer or NULL on error
*/
lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t color_format, const lv_area_t * area);
/**
* Initialize a layer which is allocated by the user
* @param layer pointer the layer to initialize (its lifetime needs to be managed by the user)
* @param parent_layer the parent layer to which the layer will be merged when it's rendered
* @param color_format the color format of the layer
* @param area the areas of the layer (absolute coordinates)
* @return the new target_layer or NULL on error
*/
void lv_draw_layer_init(lv_layer_t * layer, lv_layer_t * parent_layer, lv_color_format_t color_format,
const lv_area_t * area);
/**
* Try to allocate a buffer for the layer.
* @param layer pointer to a layer
* @return pointer to the allocated aligned buffer or NULL on failure
*/
void * lv_draw_layer_alloc_buf(lv_layer_t * layer);
/**
* Got to a pixel at X and Y coordinate on a layer
* @param layer pointer to a layer
* @param x the target X coordinate
* @param y the target X coordinate
* @return `buf` offset to point to the given X and Y coordinate
*/
void * lv_draw_layer_go_to_xy(lv_layer_t * layer, int32_t x, int32_t y);
/**
* Get the type of a draw task
* @param t the draw task to get the type of
* @return the draw task type
*/
lv_draw_task_type_t lv_draw_task_get_type(const lv_draw_task_t * t);
/**
* Get the draw descriptor of a draw task
* @param t the draw task to get the draw descriptor of
* @return a void pointer to the draw descriptor
*/
void * lv_draw_task_get_draw_dsc(const lv_draw_task_t * t);
/**
* Get the draw area of a draw task
* @param t the draw task to get the draw area of
* @param area the destination where the draw area will be stored
*/
void lv_draw_task_get_area(const lv_draw_task_t * t, lv_area_t * area);
/**********************
* GLOBAL VARIABLES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_H*/
+90
View File
@@ -0,0 +1,90 @@
/**
* @file lv_draw_arc.h
*
*/
#ifndef LV_DRAW_ARC_H
#define LV_DRAW_ARC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include "../misc/lv_color.h"
#include "../misc/lv_area.h"
#include "../misc/lv_style.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_dsc_base_t base;
lv_color_t color;
int32_t width;
lv_value_precise_t start_angle;
lv_value_precise_t end_angle;
lv_point_t center;
uint16_t radius;
const void * img_src;
lv_opa_t opa;
uint8_t rounded : 1;
} lv_draw_arc_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize an arc draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc);
/**
* Try to get an arc draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_ARC
*/
lv_draw_arc_dsc_t * lv_draw_task_get_arc_dsc(lv_draw_task_t * task);
/**
* Create an arc draw task.
* @param layer pointer to a layer
* @param dsc pointer to an initialized draw descriptor variable
*/
void lv_draw_arc(lv_layer_t * layer, const lv_draw_arc_dsc_t * dsc);
/**
* Get an area the should be invalidated when the arcs angle changed between start_angle and end_ange
* @param x the x coordinate of the center of the arc
* @param y the y coordinate of the center of the arc
* @param radius the radius of the arc
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
* @param end_angle the end angle of the arc
* @param w width of the arc
* @param rounded true: the arc is rounded
* @param area store the area to invalidate here
*/
void lv_draw_arc_get_area(int32_t x, int32_t y, uint16_t radius, lv_value_precise_t start_angle,
lv_value_precise_t end_angle,
int32_t w, bool rounded, lv_area_t * area);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_ARC_H*/
+356
View File
@@ -0,0 +1,356 @@
/**
* @file lv_draw_buf.h
*
*/
#ifndef LV_DRAW_BUF_H
#define LV_DRAW_BUF_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../misc/lv_types.h"
#include "../misc/lv_area.h"
#include "../misc/lv_color.h"
#include "../stdlib/lv_string.h"
#include "lv_image_dsc.h"
/*********************
* DEFINES
*********************/
/** Use this value to let LVGL calculate stride automatically */
#define LV_STRIDE_AUTO 0
LV_EXPORT_CONST_INT(LV_STRIDE_AUTO);
/**
* Stride alignment for draw buffers.
* It may vary between different color formats and hardware.
* Refine it to suit your needs.
*/
#define LV_DRAW_BUF_STRIDE(w, cf) \
LV_ROUND_UP(((w) * LV_COLOR_FORMAT_GET_BPP(cf) + 7) / 8, LV_DRAW_BUF_STRIDE_ALIGN)
/** Allocate a slightly larger buffer, so we can adjust the start address to meet alignment */
#define LV_DRAW_BUF_SIZE(w, h, cf) \
(LV_DRAW_BUF_STRIDE(w, cf) * (h) + LV_DRAW_BUF_ALIGN + \
LV_COLOR_INDEXED_PALETTE_SIZE(cf) * sizeof(lv_color32_t))
/**
* Define a static draw buffer with the given width, height, and color format.
* Stride alignment is set to LV_DRAW_BUF_STRIDE_ALIGN.
*
* For platform that needs special buffer alignment, call LV_DRAW_BUF_INIT_STATIC.
*/
#define LV_DRAW_BUF_DEFINE_STATIC(name, _w, _h, _cf) \
static uint8_t buf_##name[LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
static lv_draw_buf_t name = { \
.header = { \
.magic = LV_IMAGE_HEADER_MAGIC, \
.cf = (_cf), \
.flags = LV_IMAGE_FLAGS_MODIFIABLE, \
.w = (_w), \
.h = (_h), \
.stride = LV_DRAW_BUF_STRIDE(_w, _cf), \
.reserved_2 = 0, \
}, \
.data_size = sizeof(buf_##name), \
.data = buf_##name, \
.unaligned_data = buf_##name, \
}
#define LV_DRAW_BUF_INIT_STATIC(name) \
do { \
lv_image_header_t * header = &name.header; \
lv_draw_buf_init(&name, header->w, header->h, (lv_color_format_t)header->cf, header->stride, buf_##name, sizeof(buf_##name)); \
lv_draw_buf_set_flag(&name, LV_IMAGE_FLAGS_MODIFIABLE); \
} while(0)
/**********************
* TYPEDEFS
**********************/
typedef void * (*lv_draw_buf_malloc_cb)(size_t size, lv_color_format_t color_format);
typedef void (*lv_draw_buf_free_cb)(void * draw_buf);
typedef void * (*lv_draw_buf_align_cb)(void * buf, lv_color_format_t color_format);
typedef void (*lv_draw_buf_cache_operation_cb)(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
typedef uint32_t (*lv_draw_buf_width_to_stride_cb)(uint32_t w, lv_color_format_t color_format);
struct _lv_draw_buf_t {
lv_image_header_t header;
uint32_t data_size; /**< Total buf size in bytes */
uint8_t * data;
void * unaligned_data; /**< Unaligned address of `data`, used internally by lvgl */
const lv_draw_buf_handlers_t * handlers; /**< draw buffer alloc/free ops. */
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the draw buffer with the default handlers.
*
* @param handlers the draw buffer handlers to set
*/
void lv_draw_buf_init_with_default_handlers(lv_draw_buf_handlers_t * handlers);
/**
* Initialize the draw buffer with given handlers.
*
* @param handlers the draw buffer handlers to set
* @param buf_malloc_cb the callback to allocate memory for the buffer
* @param buf_free_cb the callback to free memory of the buffer
* @param align_pointer_cb the callback to align the buffer
* @param invalidate_cache_cb the callback to invalidate the cache of the buffer
* @param flush_cache_cb the callback to flush buffer
* @param width_to_stride_cb the callback to calculate the stride based on the width and color format
*/
void lv_draw_buf_handlers_init(lv_draw_buf_handlers_t * handlers,
lv_draw_buf_malloc_cb buf_malloc_cb,
lv_draw_buf_free_cb buf_free_cb,
lv_draw_buf_align_cb align_pointer_cb,
lv_draw_buf_cache_operation_cb invalidate_cache_cb,
lv_draw_buf_cache_operation_cb flush_cache_cb,
lv_draw_buf_width_to_stride_cb width_to_stride_cb);
/**
* Get the struct which holds the callbacks for draw buf management.
* Custom callback can be set on the returned value
* @return pointer to the struct of handlers
*/
lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void);
lv_draw_buf_handlers_t * lv_draw_buf_get_font_handlers(void);
lv_draw_buf_handlers_t * lv_draw_buf_get_image_handlers(void);
/**
* Align the address of a buffer. The buffer needs to be large enough for the real data after alignment
* @param buf the data to align
* @param color_format the color format of the buffer
* @return the aligned buffer
*/
void * lv_draw_buf_align(void * buf, lv_color_format_t color_format);
/**
* Align the address of a buffer with custom draw buffer handlers.
* The buffer needs to be large enough for the real data after alignment
* @param handlers the draw buffer handlers
* @param buf the data to align
* @param color_format the color format of the buffer
* @return the aligned buffer
*/
void * lv_draw_buf_align_ex(const lv_draw_buf_handlers_t * handlers, void * buf, lv_color_format_t color_format);
/**
* Invalidate the cache of the buffer
* @param draw_buf the draw buffer needs to be invalidated
* @param area the area to invalidate in the buffer,
* use NULL to invalidate the whole draw buffer address range
*/
void lv_draw_buf_invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
/**
* Flush the cache of the buffer
* @param draw_buf the draw buffer needs to be flushed
* @param area the area to flush in the buffer,
* use NULL to flush the whole draw buffer address range
*/
void lv_draw_buf_flush_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
/**
* Calculate the stride in bytes based on a width and color format
* @param w the width in pixels
* @param color_format the color format
* @return the stride in bytes
*/
uint32_t lv_draw_buf_width_to_stride(uint32_t w, lv_color_format_t color_format);
/**
* Calculate the stride in bytes based on a width and color format
* @param handlers the draw buffer handlers
* @param w the width in pixels
* @param color_format the color format
* @return the stride in bytes
*/
uint32_t lv_draw_buf_width_to_stride_ex(const lv_draw_buf_handlers_t * handlers, uint32_t w,
lv_color_format_t color_format);
/**
* Clear an area on the buffer
* @param draw_buf pointer to draw buffer
* @param a the area to clear, or NULL to clear the whole buffer
*/
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a);
/**
* Copy an area from a buffer to another
* @param dest pointer to the destination draw buffer
* @param dest_area the area to copy from the destination buffer, if NULL, use the whole buffer
* @param src pointer to the source draw buffer
* @param src_area the area to copy from the destination buffer, if NULL, use the whole buffer
* @note `dest_area` and `src_area` should have the same width and height
* @note `dest` and `src` should have same color format. Color converting is not supported fow now.
*/
void lv_draw_buf_copy(lv_draw_buf_t * dest, const lv_area_t * dest_area,
const lv_draw_buf_t * src, const lv_area_t * src_area);
/**
* Note: Eventually, lv_draw_buf_malloc/free will be kept as private.
* For now, we use `create` to distinguish with malloc.
*
* Create an draw buf by allocating struct for `lv_draw_buf_t` and allocating a buffer for it
* that meets specified requirements.
*
* @param w the buffer width in pixels
* @param h the buffer height in pixels
* @param cf the color format for image
* @param stride the stride in bytes for image. Use 0 for automatic calculation based on
* w, cf, and global stride alignment configuration.
*/
lv_draw_buf_t * lv_draw_buf_create(uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride);
/**
* Note: Eventually, lv_draw_buf_malloc/free will be kept as private.
* For now, we use `create` to distinguish with malloc.
*
* Create an draw buf by allocating struct for `lv_draw_buf_t` and allocating a buffer for it
* that meets specified requirements.
*
* @param handlers the draw buffer handlers
* @param w the buffer width in pixels
* @param h the buffer height in pixels
* @param cf the color format for image
* @param stride the stride in bytes for image. Use 0 for automatic calculation based on
* w, cf, and global stride alignment configuration.
*/
lv_draw_buf_t * lv_draw_buf_create_ex(const lv_draw_buf_handlers_t * handlers, uint32_t w, uint32_t h,
lv_color_format_t cf, uint32_t stride);
/**
* Duplicate a draw buf with same image size, stride and color format. Copy the image data too.
* @param draw_buf the draw buf to duplicate
* @return the duplicated draw buf on success, NULL if failed
*/
lv_draw_buf_t * lv_draw_buf_dup(const lv_draw_buf_t * draw_buf);
/**
* Duplicate a draw buf with same image size, stride and color format. Copy the image data too.
* @param handlers the draw buffer handlers
* @param draw_buf the draw buf to duplicate
* @return the duplicated draw buf on success, NULL if failed
*/
lv_draw_buf_t * lv_draw_buf_dup_ex(const lv_draw_buf_handlers_t * handlers, const lv_draw_buf_t * draw_buf);
/**
* Initialize a draw buf with the given buffer and parameters. Clear draw buffer flag to zero.
* @param draw_buf the draw buf to initialize
* @param w the buffer width in pixels
* @param h the buffer height in pixels
* @param cf the color format
* @param stride the stride in bytes. Use 0 for automatic calculation
* @param data the buffer used for drawing. Unaligned `data` will be aligned internally
* @param data_size the size of the buffer in bytes
* @return return LV_RESULT_OK on success, LV_RESULT_INVALID otherwise
*/
lv_result_t lv_draw_buf_init(lv_draw_buf_t * draw_buf, uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride,
void * data, uint32_t data_size);
/**
* Keep using the existing memory, reshape the draw buffer to the given width and height.
* Return NULL if data_size is smaller than the required size.
* @param draw_buf pointer to a draw buffer
* @param cf the new color format, use 0 or LV_COLOR_FORMAT_UNKNOWN to keep using the original color format.
* @param w the new width in pixels
* @param h the new height in pixels
* @param stride the stride in bytes for image. Use 0 for automatic calculation.
*/
lv_draw_buf_t * lv_draw_buf_reshape(lv_draw_buf_t * draw_buf, lv_color_format_t cf, uint32_t w, uint32_t h,
uint32_t stride);
/**
* Destroy a draw buf by freeing the actual buffer if it's marked as LV_IMAGE_FLAGS_ALLOCATED in header.
* Then free the lv_draw_buf_t struct.
*
* @param draw_buf the draw buffer to destroy
*/
void lv_draw_buf_destroy(lv_draw_buf_t * draw_buf);
/**
* Return pointer to the buffer at the given coordinates
*/
void * lv_draw_buf_goto_xy(const lv_draw_buf_t * buf, uint32_t x, uint32_t y);
/**
* Adjust the stride of a draw buf in place.
* @param src pointer to a draw buffer
* @param stride the new stride in bytes for image. Use LV_STRIDE_AUTO for automatic calculation.
* @return LV_RESULT_OK: success or LV_RESULT_INVALID: failed
*/
lv_result_t lv_draw_buf_adjust_stride(lv_draw_buf_t * src, uint32_t stride);
/**
* Premultiply draw buffer color with alpha channel.
* If it's already premultiplied, return directly.
* Only color formats with alpha channel will be processed.
*
* @return LV_RESULT_OK: premultiply success
*/
lv_result_t lv_draw_buf_premultiply(lv_draw_buf_t * draw_buf);
bool lv_draw_buf_has_flag(const lv_draw_buf_t * draw_buf, lv_image_flags_t flag);
void lv_draw_buf_set_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag);
void lv_draw_buf_clear_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag);
/**
* As of now, draw buf share same definition as `lv_image_dsc_t`.
* And is interchangeable with `lv_image_dsc_t`.
*/
void lv_draw_buf_from_image(lv_draw_buf_t * buf, const lv_image_dsc_t * img);
void lv_draw_buf_to_image(const lv_draw_buf_t * buf, lv_image_dsc_t * img);
/**
* Set the palette color of an indexed image. Valid only for `LV_COLOR_FORMAT_I1/2/4/8`
* @param draw_buf pointer to an image descriptor
* @param index the palette color to set:
* - for `LV_COLOR_FORMAT_I1`: 0..1
* - for `LV_COLOR_FORMAT_I2`: 0..3
* - for `LV_COLOR_FORMAT_I4`: 0..15
* - for `LV_COLOR_FORMAT_I8`: 0..255
* @param color the color to set in lv_color32_t format
*/
void lv_draw_buf_set_palette(lv_draw_buf_t * draw_buf, uint8_t index, lv_color32_t color);
/**
* @deprecated Use lv_draw_buf_set_palette instead.
*/
void lv_image_buf_set_palette(lv_image_dsc_t * dsc, uint8_t id, lv_color32_t c);
/**
* @deprecated Use lv_draw_buffer_create/destroy instead.
* Free the data pointer and dsc struct of an image.
*/
void lv_image_buf_free(lv_image_dsc_t * dsc);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_BUF_H*/
@@ -0,0 +1,53 @@
/**
* @file lv_draw_buf_private.h
*
*/
#ifndef LV_DRAW_BUF_PRIVATE_H
#define LV_DRAW_BUF_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_buf.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_buf_handlers_t {
lv_draw_buf_malloc_cb buf_malloc_cb;
lv_draw_buf_free_cb buf_free_cb;
lv_draw_buf_align_cb align_pointer_cb;
lv_draw_buf_cache_operation_cb invalidate_cache_cb;
lv_draw_buf_cache_operation_cb flush_cache_cb;
lv_draw_buf_width_to_stride_cb width_to_stride_cb;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Called internally to initialize the draw_buf_handlers in lv_global
*/
void lv_draw_buf_init_handlers(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_BUF_PRIVATE_H*/
+129
View File
@@ -0,0 +1,129 @@
/**
* @file lv_draw_image.h
*
*/
#ifndef LV_DRAW_IMAGE_H
#define LV_DRAW_IMAGE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
#include "lv_image_decoder.h"
#include "lv_draw_buf.h"
#include "../misc/lv_style.h"
/*********************
* DEFINES
*********************/
/**********************
* MACROS
**********************/
typedef struct _lv_draw_image_dsc_t {
lv_draw_dsc_base_t base;
const void * src;
lv_image_header_t header;
int32_t rotation;
int32_t scale_x;
int32_t scale_y;
int32_t skew_x;
int32_t skew_y;
lv_point_t pivot;
lv_color_t recolor;
lv_opa_t recolor_opa;
lv_opa_t opa;
lv_blend_mode_t blend_mode : 4;
uint16_t antialias : 1;
uint16_t tile : 1;
lv_draw_image_sup_t * sup;
/** Used to indicate the entire original, non-clipped area where the image is to be drawn.
* This is important for:
* 1. Layer rendering, where it might happen that only a smaller area of the layer is rendered.
* 2. Tiled images, where the target draw area is larger than the image to be tiled.
*/
lv_area_t image_area;
int32_t clip_radius;
const lv_image_dsc_t * bitmap_mask_src;
} lv_draw_image_dsc_t;
/**
* PErform the actual rendering of a decoded image
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param decoder_dsc pointer to the decoded image's descriptor
* @param sup supplementary data
* @param img_coords the absolute coordinates of the image
* @param clipped_img_area the absolute clip coordinates
*/
typedef void (*lv_draw_image_core_cb)(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_image_decoder_dsc_t * decoder_dsc, lv_draw_image_sup_t * sup,
const lv_area_t * img_coords, const lv_area_t * clipped_img_area);
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize an image draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc);
/**
* Try to get an image draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_IMAGE
*/
lv_draw_image_dsc_t * lv_draw_task_get_image_dsc(lv_draw_task_t * task);
/**
* Create an image draw task
* @param layer pointer to a layer
* @param dsc pointer to an initialized draw descriptor
* @param coords the coordinates of the image
* @note `coords` can be small than the real image area
* (if only a part of the image is rendered)
* or can be larger (in case of tiled images). .
*/
void lv_draw_image(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords);
/**
* Create a draw task to blend a layer to another layer
* @param layer pointer to a layer
* @param dsc pointer to an initialized draw descriptor
* @param coords the coordinates of the layer.
* @note `coords` can be small than the total widget area from which the layer is created
* (if only a part of the widget was rendered to a layer)
*/
void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords);
/**
* Get the type of an image source
* @param src pointer to an image source:
* - pointer to an 'lv_image_t' variable (image stored internally and compiled into the code)
* - a path to a file (e.g. "S:/folder/image.bin")
* - or a symbol (e.g. LV_SYMBOL_CLOSE)
* @return type of the image source LV_IMAGE_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN
*/
lv_image_src_t lv_image_src_get_type(const void * src);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_IMAGE_H*/
@@ -0,0 +1,85 @@
/**
* @file lv_draw_image_private.h
*
*/
#ifndef LV_DRAW_IMAGE_PRIVATE_H
#define LV_DRAW_IMAGE_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_image.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_image_sup_t {
lv_color_t alpha_color;
const lv_color32_t * palette;
uint32_t palette_size : 9;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Can be used by draw units to handle the decoding and
* prepare everything for the actual image rendering
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param coords the absolute coordinates of the image
* @param draw_core_cb a callback to perform the actual rendering
*/
void lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
/**
* Can be used by draw units for TILED images to handle the decoding and
* prepare everything for the actual image rendering
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor of the image
* @param coords the absolute coordinates of the image
* @param draw_core_cb a callback to perform the actual rendering
*/
void lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
/**
* Get the area of a rectangle if its rotated and scaled
* @param res store the coordinates here
* @param w width of the rectangle to transform
* @param h height of the rectangle to transform
* @param angle angle of rotation
* @param scale_x zoom in x direction, (256 no zoom)
* @param scale_y zoom in y direction, (256 no zoom)
* @param pivot x,y pivot coordinates of rotation
*/
void lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_IMAGE_PRIVATE_H*/
+145
View File
@@ -0,0 +1,145 @@
/**
* @file lv_draw_label.h
*
*/
#ifndef LV_DRAW_LABEL_H
#define LV_DRAW_LABEL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
#include "lv_draw_rect.h"
#include "../misc/lv_bidi.h"
#include "../misc/lv_text.h"
#include "../misc/lv_color.h"
#include "../misc/lv_style.h"
/*********************
* DEFINES
*********************/
#define LV_DRAW_LABEL_NO_TXT_SEL (0xFFFF)
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_dsc_base_t base;
const char * text;
const lv_font_t * font;
uint32_t sel_start;
uint32_t sel_end;
lv_color_t color;
lv_color_t sel_color;
lv_color_t sel_bg_color;
int32_t line_space;
int32_t letter_space;
int32_t ofs_x;
int32_t ofs_y;
lv_opa_t opa;
lv_base_dir_t bidi_dir;
lv_text_align_t align;
lv_text_flag_t flag;
lv_text_decor_t decor : 3;
lv_blend_mode_t blend_mode : 3;
/**
* < 1: malloc buffer and copy `text` there.
* 0: `text` is const and it's pointer will be valid during rendering.*/
uint8_t text_local : 1;
/**
* Indicate that the text is constant and its pointer can be safely saved e.g. in a cache.
*/
uint8_t text_static : 1;
lv_draw_label_hint_t * hint;
} lv_draw_label_dsc_t;
/**
* Passed as a parameter to `lv_draw_label_iterate_characters` to
* draw the characters one by one
* @param draw_unit pointer to a draw unit
* @param dsc pointer to `lv_draw_glyph_dsc_t` to describe the character to draw
* if NULL don't draw character
* @param fill_dsc pointer to a fill descriptor to draw a background for the character or
* underline or strike through
* if NULL do not fill anything
* @param fill_area the area to fill
* if NULL do not fill anything
*/
typedef void(*lv_draw_glyph_cb_t)(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc, lv_draw_fill_dsc_t * fill_dsc,
const lv_area_t * fill_area);
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize a label draw descriptor
* @param dsc pointer to a draw descriptor
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
/**
* Try to get a label draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_LABEL
*/
lv_draw_label_dsc_t * lv_draw_task_get_label_dsc(lv_draw_task_t * task);
/**
* Initialize a glyph draw descriptor.
* Used internally.
* @param dsc pointer to a draw descriptor
*/
void lv_draw_glyph_dsc_init(lv_draw_glyph_dsc_t * dsc);
/**
* Crate a draw task to render a text
* @param layer pointer to a layer
* @param dsc pointer to draw descriptor
* @param coords coordinates of the character
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_label(lv_layer_t * layer, const lv_draw_label_dsc_t * dsc,
const lv_area_t * coords);
/**
* Crate a draw task to render a single character
* @param layer pointer to a layer
* @param dsc pointer to draw descriptor
* @param point position of the label
* @param unicode_letter the letter to draw
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_character(lv_layer_t * layer, lv_draw_label_dsc_t * dsc,
const lv_point_t * point, uint32_t unicode_letter);
/**
* Should be used during rendering the characters to get the position and other
* parameters of the characters
* @param draw_unit pointer to a draw unit
* @param dsc pointer to draw descriptor
* @param coords coordinates of the label
* @param cb a callback to call to draw each glyphs one by one
*/
void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc,
const lv_area_t * coords, lv_draw_glyph_cb_t cb);
/***********************
* GLOBAL VARIABLES
***********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_LABEL_H*/
@@ -0,0 +1,68 @@
/**
* @file lv_draw_label_private.h
*
*/
#ifndef LV_DRAW_LABEL_PRIVATE_H
#define LV_DRAW_LABEL_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_label.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/** Store some info to speed up drawing of very large texts
* It takes a lot of time to get the first visible character because
* all the previous characters needs to be checked to calculate the positions.
* This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line.
* Therefore the calculations can start from here.*/
struct _lv_draw_label_hint_t {
/** Index of the line at `y` coordinate*/
int32_t line_start;
/** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/
int32_t y;
/** The 'y1' coordinate of the label when the hint was saved.
* Used to invalidate the hint if the label has moved too much.*/
int32_t coord_y;
};
struct _lv_draw_glyph_dsc_t {
void * glyph_data; /**< Depends on `format` field, it could be image source or draw buf of bitmap or vector data. */
lv_font_glyph_format_t format;
const lv_area_t * letter_coords;
const lv_area_t * bg_coords;
const lv_font_glyph_dsc_t * g;
lv_color_t color;
lv_opa_t opa;
lv_draw_buf_t * _draw_buf; /**< a shared draw buf for get_bitmap, do not use it directly, use glyph_data instead */
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_LABEL_PRIVATE_H*/
+76
View File
@@ -0,0 +1,76 @@
/**
* @file lv_draw_line.h
*
*/
#ifndef LV_DRAW_LINE_H
#define LV_DRAW_LINE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include "../misc/lv_color.h"
#include "../misc/lv_area.h"
#include "../misc/lv_style.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_dsc_base_t base;
lv_point_precise_t p1;
lv_point_precise_t p2;
lv_color_t color;
int32_t width;
int32_t dash_width;
int32_t dash_gap;
lv_opa_t opa;
lv_blend_mode_t blend_mode : 2;
uint8_t round_start : 1;
uint8_t round_end : 1;
uint8_t raw_end : 1; /**< Do not bother with perpendicular line ending if it's not visible for any reason */
} lv_draw_line_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize a line draw descriptor
* @param dsc pointer to a draw descriptor
*/
void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
/**
* Try to get a line draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_LINE
*/
lv_draw_line_dsc_t * lv_draw_task_get_line_dsc(lv_draw_task_t * task);
/**
* Create a line draw task
* @param layer pointer to a layer
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_draw_line(lv_layer_t * layer, const lv_draw_line_dsc_t * dsc);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_LINE_H*/
+56
View File
@@ -0,0 +1,56 @@
/**
* @file lv_draw_mask.h
*
*/
#ifndef LV_DRAW_MASK_H
#define LV_DRAW_MASK_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../misc/lv_color.h"
#include "../misc/lv_area.h"
#include "../misc/lv_style.h"
/*********************
* DEFINES
*********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize a rectangle mask draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_mask_rect_dsc_init(lv_draw_mask_rect_dsc_t * dsc);
/**
* Try to get a rectangle mask draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_MASK_RECTANGLE
*/
lv_draw_mask_rect_dsc_t * lv_draw_task_get_mask_rect_dsc(lv_draw_task_t * task);
/**
* Create a draw task to mask a rectangle from the buffer
* @param layer pointer to a layer
* @param dsc pointer to a draw descriptor
*/
void lv_draw_mask_rect(lv_layer_t * layer, const lv_draw_mask_rect_dsc_t * dsc);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_MASK_H*/
@@ -0,0 +1,51 @@
/**
* @file lv_draw_mask_private.h
*
*/
#ifndef LV_DRAW_MASK_PRIVATE_H
#define LV_DRAW_MASK_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_mask.h"
#include "lv_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_mask_rect_dsc_t {
lv_draw_dsc_base_t base;
lv_area_t area;
int32_t radius;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_MASK_PRIVATE_H*/
+196
View File
@@ -0,0 +1,196 @@
/**
* @file lv_draw_private.h
*
*/
/**
* Modified by NXP in 2024
*/
#ifndef LV_DRAW_PRIVATE_H
#define LV_DRAW_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_task_t {
lv_draw_task_t * next;
lv_draw_task_type_t type;
/**
* The area where to draw
*/
lv_area_t area;
/**
* The real draw area. E.g. for shadow, outline, or transformed images it's different from `area`
*/
lv_area_t _real_area;
/** The original area which is updated*/
lv_area_t clip_area_original;
/**
* The clip area of the layer is saved here when the draw task is created.
* As the clip area of the layer can be changed as new draw tasks are added its current value needs to be saved.
* Therefore during drawing the layer's clip area shouldn't be used as it might be already changed for other draw tasks.
*/
lv_area_t clip_area;
#if LV_DRAW_TRANSFORM_USE_MATRIX
/** Transform matrix to be applied when rendering the layer */
lv_matrix_t matrix;
#endif
volatile int state; /** int instead of lv_draw_task_state_t to be sure its atomic */
void * draw_dsc;
/**
* The ID of the draw_unit which should take this task
*/
uint8_t preferred_draw_unit_id;
/**
* Set to which extent `preferred_draw_unit_id` is good at this task.
* 80: means 20% better (faster) than software rendering
* 100: the default value
* 110: means 10% worse (slower) than software rendering
*/
uint8_t preference_score;
};
struct _lv_draw_mask_t {
void * user_data;
};
struct _lv_draw_unit_t {
lv_draw_unit_t * next;
/**
* The target_layer on which drawing should happen
*/
lv_layer_t * target_layer;
const lv_area_t * clip_area;
/**
* Called to try to assign a draw task to itself.
* `lv_draw_get_next_available_task` can be used to get an independent draw task.
* A draw task should be assign only if the draw unit can draw it too
* @param draw_unit pointer to the draw unit
* @param layer pointer to a layer on which the draw task should be drawn
* @return >=0: The number of taken draw task:
* 0 means the task has not yet been completed.
* 1 means a new task has been accepted.
* -1: The draw unit wanted to work on a task but couldn't do that
* due to some errors (e.g. out of memory).
* It signals that LVGL should call the dispatcher later again
* to let draw unit try to start the rendering again.
*/
int32_t (*dispatch_cb)(lv_draw_unit_t * draw_unit, lv_layer_t * layer);
/**
*
* @param draw_unit
* @param task
* @return
*/
int32_t (*evaluate_cb)(lv_draw_unit_t * draw_unit, lv_draw_task_t * task);
/**
* Called to signal the unit to complete all tasks in order to return their ready status.
* This callback can be implemented in case of asynchronous task processing.
* Below is an example to show the difference between synchronous and asynchronous:
*
* Synchronous:
* LVGL thread DRAW thread HW
*
* task1 --> submit --> Receive task1
* wait_for_finish()
* <-- task1->state = READY <-- Complete task1
* task2 --> submit --> Receive task2
* wait_for_finish()
* task2->state = READY <-- Complete task2
* task3 --> submit --> Receive task3
* wait_for_finish()
* <-- task3->state = READY <-- Complete task3
* task4 --> submit --> Receive task4
* wait_for_finish()
* <-- task4->state = READY <-- Complete task4
* NO MORE TASKS
*
*
* Asynchronous:
* LVGL thread DRAW thread HW
* is IDLE
* task1 --> queue task1
* submit --> Receive task1
* task2 --> queue task2 is BUSY (with task1)
* task3 --> queue task3 still BUSY (with task1)
* task4 --> queue task4 becomes IDLE
* <-- task1->state = READY <-- Complete task1
* submit --> Receive task2, task3, task4
* NO MORE TASKS
* wait_for_finish_cb() wait_for_finish()
* <-- Complete task2, task3, task4
* <-- task2->state = READY <--
* <-- task3->state = READY <--
* <-- task4->state = READY <--
*
* @param draw_unit
* @return
*/
int32_t (*wait_for_finish_cb)(lv_draw_unit_t * draw_unit);
/**
* Called to delete draw unit.
* @param draw_unit
* @return
*/
int32_t (*delete_cb)(lv_draw_unit_t * draw_unit);
};
typedef struct {
lv_draw_unit_t * unit_head;
uint32_t unit_cnt;
uint32_t used_memory_for_layers_kb;
#if LV_USE_OS
lv_thread_sync_t sync;
#else
volatile int dispatch_req;
#endif
lv_mutex_t circle_cache_mutex;
bool task_running;
} lv_draw_global_info_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_PRIVATE_H*/
+174
View File
@@ -0,0 +1,174 @@
/**
* @file lv_draw_rect.h
*
*/
#ifndef LV_DRAW_RECT_H
#define LV_DRAW_RECT_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
#include "../misc/lv_color.h"
#include "../misc/lv_area.h"
#include "../misc/lv_style.h"
#include "sw/lv_draw_sw_gradient.h"
/*********************
* DEFINES
*********************/
#define LV_RADIUS_CIRCLE 0x7FFF /**< A very big radius to always draw as circle*/
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_dsc_base_t base;
int32_t radius;
/*Background*/
lv_opa_t bg_opa;
lv_color_t bg_color; /**< First element of a gradient is a color, so it maps well here*/
lv_grad_dsc_t bg_grad;
/*Background img*/
const void * bg_image_src;
const void * bg_image_symbol_font;
lv_color_t bg_image_recolor;
lv_opa_t bg_image_opa;
lv_opa_t bg_image_recolor_opa;
uint8_t bg_image_tiled;
/*Border*/
lv_color_t border_color;
int32_t border_width;
lv_opa_t border_opa;
lv_border_side_t border_side : 5;
uint8_t border_post : 1; /*The border will be drawn later*/
/*Outline*/
lv_color_t outline_color;
int32_t outline_width;
int32_t outline_pad;
lv_opa_t outline_opa;
/*Shadow*/
lv_color_t shadow_color;
int32_t shadow_width;
int32_t shadow_offset_x;
int32_t shadow_offset_y;
int32_t shadow_spread;
lv_opa_t shadow_opa;
} lv_draw_rect_dsc_t;
typedef struct {
lv_draw_dsc_base_t base;
int32_t radius;
lv_opa_t opa;
lv_color_t color;
lv_grad_dsc_t grad;
} lv_draw_fill_dsc_t;
typedef struct {
lv_draw_dsc_base_t base;
int32_t radius;
lv_color_t color;
int32_t width;
lv_opa_t opa;
lv_border_side_t side : 5;
} lv_draw_border_dsc_t;
typedef struct {
lv_draw_dsc_base_t base;
int32_t radius;
lv_color_t color;
int32_t width;
int32_t spread;
int32_t ofs_x;
int32_t ofs_y;
lv_opa_t opa;
uint8_t bg_cover : 1;
} lv_draw_box_shadow_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize a rectangle draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
/**
* Initialize a fill draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void lv_draw_fill_dsc_init(lv_draw_fill_dsc_t * dsc);
/**
* Try to get a fill draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_FILL
*/
lv_draw_fill_dsc_t * lv_draw_task_get_fill_dsc(lv_draw_task_t * task);
/**
* Initialize a border draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc);
/**
* Try to get a border draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BORDER
*/
lv_draw_border_dsc_t * lv_draw_task_get_border_dsc(lv_draw_task_t * task);
/**
* Initialize a box shadow draw descriptor.
* @param dsc pointer to a draw descriptor
*/
void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc);
/**
* Try to get a box shadow draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BOX_SHADOW
*/
lv_draw_box_shadow_dsc_t * lv_draw_task_get_box_shadow_dsc(lv_draw_task_t * task);
/**
* The rectangle is a wrapper for fill, border, bg. image and box shadow.
* Internally fill, border, image and box shadow draw tasks will be created.
* @param layer pointer to a layer
* @param dsc pointer to an initialized draw descriptor variable
* @param coords the coordinates of the rectangle
*/
void lv_draw_rect(lv_layer_t * layer, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_RECT_H*/
@@ -0,0 +1,39 @@
/**
* @file lv_draw_rect_private.h
*
*/
#ifndef LV_DRAW_RECT_PRIVATE_H
#define LV_DRAW_RECT_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_rect.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_RECT_PRIVATE_H*/
+67
View File
@@ -0,0 +1,67 @@
/**
* @file lv_draw_triangle.h
*
*/
#ifndef LV_DRAW_TRIANGLE_H
#define LV_DRAW_TRIANGLE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_rect.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_dsc_base_t base;
lv_opa_t bg_opa;
lv_color_t bg_color;
lv_grad_dsc_t bg_grad;
lv_point_precise_t p[3];
} lv_draw_triangle_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize a triangle draw descriptor
* @param draw_dsc pointer to a draw descriptor
*/
void lv_draw_triangle_dsc_init(lv_draw_triangle_dsc_t * draw_dsc);
/**
* Try to get a triangle draw descriptor from a draw task.
* @param task draw task
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_TRIANGLE
*/
lv_draw_triangle_dsc_t * lv_draw_task_get_triangle_dsc(lv_draw_task_t * task);
/**
* Create a triangle draw task
* @param layer pointer to a layer
* @param draw_dsc pointer to an initialized `lv_draw_triangle_dsc_t` object
*/
void lv_draw_triangle(lv_layer_t * layer, const lv_draw_triangle_dsc_t * draw_dsc);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_TRIANGLE_H*/
@@ -0,0 +1,43 @@
/**
* @file lv_draw_triangle_private.h
*
*/
#ifndef LV_DRAW_TRIANGLE_PRIVATE_H
#define LV_DRAW_TRIANGLE_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_triangle.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_TRIANGLE_PRIVATE_H*/
+489
View File
@@ -0,0 +1,489 @@
/**
* @file lv_draw_vector.h
*
*/
#ifndef LV_DRAW_VECTOR_H
#define LV_DRAW_VECTOR_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../misc/lv_array.h"
#include "../misc/lv_matrix.h"
#include "lv_draw_image.h"
#if LV_USE_VECTOR_GRAPHIC
#if !LV_USE_MATRIX
#error "lv_draw_vector needs LV_USE_MATRIX = 1"
#endif
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_VECTOR_FILL_NONZERO = 0,
LV_VECTOR_FILL_EVENODD,
} lv_vector_fill_t;
typedef enum {
LV_VECTOR_STROKE_CAP_BUTT = 0,
LV_VECTOR_STROKE_CAP_SQUARE,
LV_VECTOR_STROKE_CAP_ROUND,
} lv_vector_stroke_cap_t;
typedef enum {
LV_VECTOR_STROKE_JOIN_MITER = 0,
LV_VECTOR_STROKE_JOIN_BEVEL,
LV_VECTOR_STROKE_JOIN_ROUND,
} lv_vector_stroke_join_t;
typedef enum {
LV_VECTOR_PATH_QUALITY_MEDIUM = 0, /* default*/
LV_VECTOR_PATH_QUALITY_HIGH,
LV_VECTOR_PATH_QUALITY_LOW,
} lv_vector_path_quality_t;
typedef enum {
LV_VECTOR_BLEND_SRC_OVER = 0,
LV_VECTOR_BLEND_SRC_IN,
LV_VECTOR_BLEND_DST_OVER,
LV_VECTOR_BLEND_DST_IN,
LV_VECTOR_BLEND_SCREEN,
LV_VECTOR_BLEND_MULTIPLY,
LV_VECTOR_BLEND_NONE,
LV_VECTOR_BLEND_ADDITIVE,
LV_VECTOR_BLEND_SUBTRACTIVE,
} lv_vector_blend_t;
typedef enum {
LV_VECTOR_PATH_OP_MOVE_TO = 0,
LV_VECTOR_PATH_OP_LINE_TO,
LV_VECTOR_PATH_OP_QUAD_TO,
LV_VECTOR_PATH_OP_CUBIC_TO,
LV_VECTOR_PATH_OP_CLOSE,
} lv_vector_path_op_t;
typedef enum {
LV_VECTOR_DRAW_STYLE_SOLID = 0,
LV_VECTOR_DRAW_STYLE_PATTERN,
LV_VECTOR_DRAW_STYLE_GRADIENT,
} lv_vector_draw_style_t;
typedef enum {
LV_VECTOR_GRADIENT_SPREAD_PAD = 0,
LV_VECTOR_GRADIENT_SPREAD_REPEAT,
LV_VECTOR_GRADIENT_SPREAD_REFLECT,
} lv_vector_gradient_spread_t;
typedef enum {
LV_VECTOR_GRADIENT_STYLE_LINEAR = 0,
LV_VECTOR_GRADIENT_STYLE_RADIAL,
} lv_vector_gradient_style_t;
struct _lv_fpoint_t {
float x;
float y;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Transform the coordinates of a point using given matrix
* @param matrix pointer to a matrix
* @param point pointer to a point
*/
void lv_matrix_transform_point(const lv_matrix_t * matrix, lv_fpoint_t * point);
/**
* Transform all the coordinates of a path using given matrix
* @param matrix pointer to a matrix
* @param path pointer to a path
*/
void lv_matrix_transform_path(const lv_matrix_t * matrix, lv_vector_path_t * path);
/**
* Create a vector graphic path object
* @param quality the quality hint of path
* @return pointer to the created path object
*/
lv_vector_path_t * lv_vector_path_create(lv_vector_path_quality_t quality);
/**
* Copy a path data to another
* @param target_path pointer to a path
* @param path pointer to source path
*/
void lv_vector_path_copy(lv_vector_path_t * target_path, const lv_vector_path_t * path);
/**
* Clear path data
* @param path pointer to a path
*/
void lv_vector_path_clear(lv_vector_path_t * path);
/**
* Delete the graphic path object
* @param path pointer to a path
*/
void lv_vector_path_delete(lv_vector_path_t * path);
/**
* Begin a new sub path and set a point to path
* @param path pointer to a path
* @param p pointer to a `lv_fpoint_t` variable
*/
void lv_vector_path_move_to(lv_vector_path_t * path, const lv_fpoint_t * p);
/**
* Add a line to the path from last point to the point
* @param path pointer to a path
* @param p pointer to a `lv_fpoint_t` variable
*/
void lv_vector_path_line_to(lv_vector_path_t * path, const lv_fpoint_t * p);
/**
* Add a quadratic bezier line to the path from last point to the point
* @param path pointer to a path
* @param p1 pointer to a `lv_fpoint_t` variable for control point
* @param p2 pointer to a `lv_fpoint_t` variable for end point
*/
void lv_vector_path_quad_to(lv_vector_path_t * path, const lv_fpoint_t * p1, const lv_fpoint_t * p2);
/**
* Add a cubic bezier line to the path from last point to the point
* @param path pointer to a path
* @param p1 pointer to a `lv_fpoint_t` variable for first control point
* @param p2 pointer to a `lv_fpoint_t` variable for second control point
* @param p3 pointer to a `lv_fpoint_t` variable for end point
*/
void lv_vector_path_cubic_to(lv_vector_path_t * path, const lv_fpoint_t * p1, const lv_fpoint_t * p2,
const lv_fpoint_t * p3);
/**
* Close the sub path
* @param path pointer to a path
*/
void lv_vector_path_close(lv_vector_path_t * path);
/**
* Get the bounding box of a path
* @param path pointer to a path
* @param area pointer to a `lv_area_t` variable for bounding box
*/
void lv_vector_path_get_bounding(const lv_vector_path_t * path, lv_area_t * area);
/**
* Add a rectangle to the path
* @param path pointer to a path
* @param rect pointer to a `lv_area_t` variable
* @param rx the horizontal radius for rounded rectangle
* @param ry the vertical radius for rounded rectangle
*/
void lv_vector_path_append_rect(lv_vector_path_t * path, const lv_area_t * rect, float rx, float ry);
/**
* Add a circle to the path
* @param path pointer to a path
* @param c pointer to a `lv_fpoint_t` variable for center of the circle
* @param rx the horizontal radius for circle
* @param ry the vertical radius for circle
*/
void lv_vector_path_append_circle(lv_vector_path_t * path, const lv_fpoint_t * c, float rx, float ry);
/**
* Add a arc to the path
* @param path pointer to a path
* @param c pointer to a `lv_fpoint_t` variable for center of the circle
* @param radius the radius for arc
* @param start_angle the start angle for arc
* @param sweep the sweep angle for arc, could be negative
* @param pie true: draw a pie, false: draw a arc
*/
void lv_vector_path_append_arc(lv_vector_path_t * path, const lv_fpoint_t * c, float radius, float start_angle,
float sweep, bool pie);
/**
* Add an sub path to the path
* @param path pointer to a path
* @param subpath pointer to another path which will be added
*/
void lv_vector_path_append_path(lv_vector_path_t * path, const lv_vector_path_t * subpath);
/**
* Create a vector graphic descriptor
* @param layer pointer to a layer
* @return pointer to the created descriptor
*/
lv_vector_dsc_t * lv_vector_dsc_create(lv_layer_t * layer);
/**
* Delete the vector graphic descriptor
* @param dsc pointer to a vector graphic descriptor
*/
void lv_vector_dsc_delete(lv_vector_dsc_t * dsc);
/**
* Set a matrix to current transformation matrix
* @param dsc pointer to a vector graphic descriptor
* @param matrix pointer to a matrix
*/
void lv_vector_dsc_set_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix);
/**
* Set blend mode for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param blend the blend mode to be set in `lv_vector_blend_t`
*/
void lv_vector_dsc_set_blend_mode(lv_vector_dsc_t * dsc, lv_vector_blend_t blend);
/**
* Set fill color for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param color the color to be set in lv_color32_t format
*/
void lv_vector_dsc_set_fill_color32(lv_vector_dsc_t * dsc, lv_color32_t color);
/**
* Set fill color for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param color the color to be set in lv_color_t format
*/
void lv_vector_dsc_set_fill_color(lv_vector_dsc_t * dsc, lv_color_t color);
/**
* Set fill opacity for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param opa the opacity to be set in lv_opa_t format
*/
void lv_vector_dsc_set_fill_opa(lv_vector_dsc_t * dsc, lv_opa_t opa);
/**
* Set fill rule for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param rule the fill rule to be set in lv_vector_fill_t format
*/
void lv_vector_dsc_set_fill_rule(lv_vector_dsc_t * dsc, lv_vector_fill_t rule);
/**
* Set fill image for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param img_dsc pointer to a `lv_draw_image_dsc_t` variable
*/
void lv_vector_dsc_set_fill_image(lv_vector_dsc_t * dsc, const lv_draw_image_dsc_t * img_dsc);
/**
* Set fill linear gradient for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param x1 the x for start point
* @param y1 the y for start point
* @param x2 the x for end point
* @param y2 the y for end point
*/
void lv_vector_dsc_set_fill_linear_gradient(lv_vector_dsc_t * dsc, float x1, float y1, float x2, float y2);
/**
* Set fill radial gradient radius for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param cx the x for center of the circle
* @param cy the y for center of the circle
* @param radius the radius for circle
*/
void lv_vector_dsc_set_fill_radial_gradient(lv_vector_dsc_t * dsc, float cx, float cy, float radius);
/**
* Set fill radial gradient spread for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param spread the gradient spread to be set in lv_vector_gradient_spread_t format
*/
void lv_vector_dsc_set_fill_gradient_spread(lv_vector_dsc_t * dsc, lv_vector_gradient_spread_t spread);
/**
* Set fill gradient color stops for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param stops an array of `lv_gradient_stop_t` variables
* @param count the number of stops in the array, range: 0..LV_GRADIENT_MAX_STOPS
*/
void lv_vector_dsc_set_fill_gradient_color_stops(lv_vector_dsc_t * dsc, const lv_gradient_stop_t * stops,
uint16_t count);
/**
* Set a matrix to current fill transformation matrix
* @param dsc pointer to a vector graphic descriptor
* @param matrix pointer to a matrix
*/
void lv_vector_dsc_set_fill_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix);
/**
* Set stroke color for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param color the color to be set in lv_color32_t format
*/
void lv_vector_dsc_set_stroke_color32(lv_vector_dsc_t * dsc, lv_color32_t color);
/**
* Set stroke color for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param color the color to be set in lv_color_t format
*/
void lv_vector_dsc_set_stroke_color(lv_vector_dsc_t * dsc, lv_color_t color);
/**
* Set stroke opacity for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param opa the opacity to be set in lv_opa_t format
*/
void lv_vector_dsc_set_stroke_opa(lv_vector_dsc_t * dsc, lv_opa_t opa);
/**
* Set stroke line width for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param width the stroke line width
*/
void lv_vector_dsc_set_stroke_width(lv_vector_dsc_t * dsc, float width);
/**
* Set stroke line dash pattern for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param dash_pattern an array of values that specify the segments of dash line
* @param dash_count the length of dash pattern array
*/
void lv_vector_dsc_set_stroke_dash(lv_vector_dsc_t * dsc, float * dash_pattern, uint16_t dash_count);
/**
* Set stroke line cap style for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param cap the line cap to be set in lv_vector_stroke_cap_t format
*/
void lv_vector_dsc_set_stroke_cap(lv_vector_dsc_t * dsc, lv_vector_stroke_cap_t cap);
/**
* Set stroke line join style for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param join the line join to be set in lv_vector_stroke_join_t format
*/
void lv_vector_dsc_set_stroke_join(lv_vector_dsc_t * dsc, lv_vector_stroke_join_t join);
/**
* Set stroke miter limit for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param miter_limit the stroke miter_limit
*/
void lv_vector_dsc_set_stroke_miter_limit(lv_vector_dsc_t * dsc, uint16_t miter_limit);
/**
* Set stroke linear gradient for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param x1 the x for start point
* @param y1 the y for start point
* @param x2 the x for end point
* @param y2 the y for end point
*/
void lv_vector_dsc_set_stroke_linear_gradient(lv_vector_dsc_t * dsc, float x1, float y1, float x2, float y2);
/**
* Set stroke radial gradient for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param cx the x for center of the circle
* @param cy the y for center of the circle
* @param radius the radius for circle
*/
void lv_vector_dsc_set_stroke_radial_gradient(lv_vector_dsc_t * dsc, float cx, float cy, float radius);
/**
* Set stroke color stops for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param spread the gradient spread to be set in lv_vector_gradient_spread_t format
*/
void lv_vector_dsc_set_stroke_gradient_spread(lv_vector_dsc_t * dsc, lv_vector_gradient_spread_t spread);
/**
* Set stroke color stops for descriptor
* @param dsc pointer to a vector graphic descriptor
* @param stops an array of `lv_gradient_stop_t` variables
* @param count the number of stops in the array
*/
void lv_vector_dsc_set_stroke_gradient_color_stops(lv_vector_dsc_t * dsc, const lv_gradient_stop_t * stops,
uint16_t count);
/**
* Set a matrix to current stroke transformation matrix
* @param dsc pointer to a vector graphic descriptor
* @param matrix pointer to a matrix
*/
void lv_vector_dsc_set_stroke_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix);
/**
* Set current transformation matrix to identity matrix
* @param dsc pointer to a vector graphic descriptor
*/
void lv_vector_dsc_identity(lv_vector_dsc_t * dsc);
/**
* Change the scale factor of current transformation matrix
* @param dsc pointer to a vector graphic descriptor
* @param scale_x the scale factor for the X direction
* @param scale_y the scale factor for the Y direction
*/
void lv_vector_dsc_scale(lv_vector_dsc_t * dsc, float scale_x, float scale_y);
/**
* Rotate current transformation matrix with origin
* @param dsc pointer to a vector graphic descriptor
* @param degree angle to rotate
*/
void lv_vector_dsc_rotate(lv_vector_dsc_t * dsc, float degree);
/**
* Translate current transformation matrix to new position
* @param dsc pointer to a vector graphic descriptor
* @param tx the amount of translate in x direction
* @param tx the amount of translate in y direction
*/
void lv_vector_dsc_translate(lv_vector_dsc_t * dsc, float tx, float ty);
/**
* Change the skew factor of current transformation matrix
* @param dsc pointer to a vector graphic descriptor
* @param skew_x the skew factor for x direction
* @param skew_y the skew factor for y direction
*/
void lv_vector_dsc_skew(lv_vector_dsc_t * dsc, float skew_x, float skew_y);
/**
* Add a graphic path to the draw list
* @param dsc pointer to a vector graphic descriptor
* @param path pointer to a path
*/
void lv_vector_dsc_add_path(lv_vector_dsc_t * dsc, const lv_vector_path_t * path);
/**
* Clear a rectangle area use current fill color
* @param dsc pointer to a vector graphic descriptor
* @param rect the area to clear in the buffer
*/
void lv_vector_clear_area(lv_vector_dsc_t * dsc, const lv_area_t * rect);
/**
* Draw all the vector graphic paths
* @param dsc pointer to a vector graphic descriptor
*/
void lv_draw_vector(lv_vector_dsc_t * dsc);
/* Traverser for task list */
typedef void (*vector_draw_task_cb)(void * ctx, const lv_vector_path_t * path, const lv_vector_draw_dsc_t * dsc);
#endif /* LV_USE_VECTOR_GRAPHIC */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LV_DRAW_VECTOR_H */
@@ -0,0 +1,109 @@
/**
* @file lv_draw_vector_private.h
*
*/
#ifndef LV_DRAW_VECTOR_PRIVATE_H
#define LV_DRAW_VECTOR_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_vector.h"
#if LV_USE_VECTOR_GRAPHIC
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_vector_path_t {
lv_vector_path_quality_t quality;
lv_array_t ops;
lv_array_t points;
};
struct _lv_vector_gradient_t {
lv_vector_gradient_style_t style;
lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS]; /**< A gradient stop array */
uint16_t stops_count; /**< The number of used stops in the array */
float x1;
float y1;
float x2;
float y2;
float cx;
float cy;
float cr;
lv_vector_gradient_spread_t spread;
};
struct _lv_vector_fill_dsc_t {
lv_vector_draw_style_t style;
lv_color32_t color;
lv_opa_t opa;
lv_vector_fill_t fill_rule;
lv_draw_image_dsc_t img_dsc;
lv_vector_gradient_t gradient;
lv_matrix_t matrix;
};
struct _lv_vector_stroke_dsc_t {
lv_vector_draw_style_t style;
lv_color32_t color;
lv_opa_t opa;
float width;
lv_array_t dash_pattern;
lv_vector_stroke_cap_t cap;
lv_vector_stroke_join_t join;
uint16_t miter_limit;
lv_vector_gradient_t gradient;
lv_matrix_t matrix;
};
struct _lv_vector_draw_dsc_t {
lv_vector_fill_dsc_t fill_dsc;
lv_vector_stroke_dsc_t stroke_dsc;
lv_matrix_t matrix;
lv_vector_blend_t blend_mode;
lv_area_t scissor_area;
};
struct _lv_draw_vector_task_dsc_t {
lv_draw_dsc_base_t base;
lv_ll_t * task_list; /*draw task list.*/
};
struct _lv_vector_dsc_t {
lv_layer_t * layer;
lv_vector_draw_dsc_t current_dsc;
/* private data */
lv_draw_vector_task_dsc_t tasks;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data);
/**********************
* MACROS
**********************/
#endif /* LV_USE_VECTOR_GRAPHIC */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_VECTOR_PRIVATE_H*/
+194
View File
@@ -0,0 +1,194 @@
/**
* @file lv_image_decoder.h
*
*/
#ifndef LV_IMAGE_DECODER_H
#define LV_IMAGE_DECODER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include "lv_draw_buf.h"
#include "../misc/lv_fs.h"
#include "../misc/lv_types.h"
#include "../misc/lv_area.h"
#include "../misc/cache/lv_cache.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Source of image.*/
typedef enum {
LV_IMAGE_SRC_VARIABLE, /** Binary/C variable*/
LV_IMAGE_SRC_FILE, /** File in filesystem*/
LV_IMAGE_SRC_SYMBOL, /** Symbol (@ref lv_symbol_def.h)*/
LV_IMAGE_SRC_UNKNOWN, /** Unknown source*/
} lv_image_src_t;
/**
* Get info from an image and store in the `header`
* @param decoder pointer to decoder object
* @param dsc pointer to decoder descriptor
* @param header store the info here
* @return LV_RESULT_OK: info written correctly; LV_RESULT_INVALID: failed
*/
typedef lv_result_t (*lv_image_decoder_info_f_t)(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
lv_image_header_t * header);
/**
* Open an image for decoding. Prepare it as it is required to read it later
* @param decoder pointer to the decoder the function associated with
* @param dsc pointer to decoder descriptor. `src`, `color` are already initialized in it.
*/
typedef lv_result_t (*lv_image_decoder_open_f_t)(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
/**
* Decode `full_area` pixels incrementally by calling in a loop. Set `decoded_area` values to `LV_COORD_MIN` on first call.
* Required only if the "open" function can't return with the whole decoded pixel array.
* @param decoder pointer to the decoder the function associated with
* @param dsc pointer to decoder descriptor
* @param full_area input parameter. the full area to decode after enough subsequent calls
* @param decoded_area input+output parameter. set the values to `LV_COORD_MIN` for the first call and to reset decoding.
* the decoded area is stored here after each call.
* @return LV_RESULT_OK: ok; LV_RESULT_INVALID: failed or there is nothing left to decode
*/
typedef lv_result_t (*lv_image_decoder_get_area_cb_t)(lv_image_decoder_t * decoder,
lv_image_decoder_dsc_t * dsc,
const lv_area_t * full_area, lv_area_t * decoded_area);
/**
* Close the pending decoding. Free resources etc.
* @param decoder pointer to the decoder the function associated with
* @param dsc pointer to decoder descriptor
*/
typedef void (*lv_image_decoder_close_f_t)(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Get information about an image.
* Try the created image decoder one by one. Once one is able to get info that info will be used.
* @param src the image source. Can be
* 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_drv_register()`)
* 2) Variable: Pointer to an `lv_image_dsc_t` variable
* 3) Symbol: E.g. `LV_SYMBOL_OK`
* @param header the image info will be stored here
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: wasn't able to get info about the image
*/
lv_result_t lv_image_decoder_get_info(const void * src, lv_image_header_t * header);
/**
* Open an image.
* Try the created image decoders one by one. Once one is able to open the image that decoder is saved in `dsc`
* @param dsc describes a decoding session. Simply a pointer to an `lv_image_decoder_dsc_t` variable.
* @param src the image source. Can be
* 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_drv_register())`)
* 2) Variable: Pointer to an `lv_image_dsc_t` variable
* 3) Symbol: E.g. `LV_SYMBOL_OK`
* @param args args about how the image should be opened.
* @return LV_RESULT_OK: opened the image. `dsc->decoded` and `dsc->header` are set.
* LV_RESULT_INVALID: none of the registered image decoders were able to open the image.
*/
lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src, const lv_image_decoder_args_t * args);
/**
* Decode `full_area` pixels incrementally by calling in a loop. Set `decoded_area` to `LV_COORD_MIN` on first call.
* @param dsc image decoder descriptor
* @param full_area input parameter. the full area to decode after enough subsequent calls
* @param decoded_area input+output parameter. set the values to `LV_COORD_MIN` for the first call and to reset decoding.
* the decoded area is stored here after each call.
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: an error occurred or there is nothing left to decode
*/
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
lv_area_t * decoded_area);
/**
* Close a decoding session
* @param dsc pointer to `lv_image_decoder_dsc_t` used in `lv_image_decoder_open`
*/
void lv_image_decoder_close(lv_image_decoder_dsc_t * dsc);
/**
* Create a new image decoder
* @return pointer to the new image decoder
*/
lv_image_decoder_t * lv_image_decoder_create(void);
/**
* Delete an image decoder
* @param decoder pointer to an image decoder
*/
void lv_image_decoder_delete(lv_image_decoder_t * decoder);
/**
* Get the next image decoder in the linked list of image decoders
* @param decoder pointer to an image decoder or NULL to get the first one
* @return the next image decoder or NULL if no more image decoder exists
*/
lv_image_decoder_t * lv_image_decoder_get_next(lv_image_decoder_t * decoder);
/**
* Set a callback to get information about the image
* @param decoder pointer to an image decoder
* @param info_cb a function to collect info about an image (fill an `lv_image_header_t` struct)
*/
void lv_image_decoder_set_info_cb(lv_image_decoder_t * decoder, lv_image_decoder_info_f_t info_cb);
/**
* Set a callback to open an image
* @param decoder pointer to an image decoder
* @param open_cb a function to open an image
*/
void lv_image_decoder_set_open_cb(lv_image_decoder_t * decoder, lv_image_decoder_open_f_t open_cb);
/**
* Set a callback to a decoded line of an image
* @param decoder pointer to an image decoder
* @param read_line_cb a function to read a line of an image
*/
void lv_image_decoder_set_get_area_cb(lv_image_decoder_t * decoder, lv_image_decoder_get_area_cb_t read_line_cb);
/**
* Set a callback to close a decoding session. E.g. close files and free other resources.
* @param decoder pointer to an image decoder
* @param close_cb a function to close a decoding session
*/
void lv_image_decoder_set_close_cb(lv_image_decoder_t * decoder, lv_image_decoder_close_f_t close_cb);
lv_cache_entry_t * lv_image_decoder_add_to_cache(lv_image_decoder_t * decoder,
lv_image_cache_data_t * search_key,
const lv_draw_buf_t * decoded, void * user_data);
/**
* Check the decoded image, make any modification if decoder `args` requires.
* @note A new draw buf will be allocated if provided `decoded` is not modifiable or stride mismatch etc.
* @param dsc pointer to a decoder descriptor
* @param decoded pointer to a decoded image to post process to meet dsc->args requirement.
* @return post processed draw buffer, when it differs with `decoded`, it's newly allocated.
*/
lv_draw_buf_t * lv_image_decoder_post_process(lv_image_decoder_dsc_t * dsc, lv_draw_buf_t * decoded);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_IMAGE_DECODER_H*/
@@ -0,0 +1,142 @@
/**
* @file lv_image_decoder_private.h
*
*/
#ifndef LV_IMAGE_DECODER_PRIVATE_H
#define LV_IMAGE_DECODER_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_image_decoder.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Image decoder args.
* It determines how to decoder an image, e.g. whether to premultiply the alpha or not.
* It should be passed to lv_img_decoder_open() function. If NULL is provided, default
* args are used.
*
* Default args:
* all field are zero or false.
*/
struct _lv_image_decoder_args_t {
bool stride_align; /**< Whether stride should be aligned */
bool premultiply; /**< Whether image should be premultiplied or not after decoding */
bool no_cache; /**< When set, decoded image won't be put to cache, and decoder open will also ignore cache. */
bool use_indexed; /**< Decoded indexed image as is. Convert to ARGB8888 if false. */
bool flush_cache; /**< Whether to flush the data cache after decoding */
};
struct _lv_image_decoder_t {
lv_image_decoder_info_f_t info_cb;
lv_image_decoder_open_f_t open_cb;
lv_image_decoder_get_area_cb_t get_area_cb;
lv_image_decoder_close_f_t close_cb;
const char * name;
void * user_data;
};
struct _lv_image_cache_data_t {
lv_cache_slot_size_t slot;
const void * src;
lv_image_src_t src_type;
const lv_draw_buf_t * decoded;
const lv_image_decoder_t * decoder;
void * user_data;
};
struct _lv_image_header_cache_data_t {
const void * src;
lv_image_src_t src_type;
lv_image_header_t header;
lv_image_decoder_t * decoder;
};
/**Describe an image decoding session. Stores data about the decoding*/
struct _lv_image_decoder_dsc_t {
/**The decoder which was able to open the image source*/
lv_image_decoder_t * decoder;
/**A copy of parameters of how this image is decoded*/
lv_image_decoder_args_t args;
/**The image source. A file path like "S:my_img.png" or pointer to an `lv_image_dsc_t` variable*/
const void * src;
/**Type of the source: file or variable. Can be set in `open` function if required*/
lv_image_src_t src_type;
lv_fs_file_t file;
/**Info about the opened image: color format, size, etc. MUST be set in `open` function*/
lv_image_header_t header;
/** Pointer to a draw buffer where the image's data (pixels) are stored in a decoded, plain format.
* MUST be set in `open` or `get_area_cb`function*/
const lv_draw_buf_t * decoded;
const lv_color32_t * palette;
uint32_t palette_size;
/** How much time did it take to open the image. [ms]
* If not set `lv_image_cache` will measure and set the time to open*/
uint32_t time_to_open;
/**A text to display instead of the image when the image can't be opened.
* Can be set in `open` function or set NULL.*/
const char * error_msg;
lv_cache_t * cache;
/**Point to cache entry information*/
lv_cache_entry_t * cache_entry;
/**Store any custom data here is required*/
void * user_data;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the image decoder module
* @param image_cache_size Image cache size in bytes. 0 to disable cache.
* @param image_header_count Number of header cache entries. 0 to disable header cache.
*/
void lv_image_decoder_init(uint32_t image_cache_size, uint32_t image_header_count);
/**
* Deinitialize the image decoder module
*/
void lv_image_decoder_deinit(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_IMAGE_DECODER_PRIVATE_H*/
+141
View File
@@ -0,0 +1,141 @@
/**
* @file lv_image_dsc.h
*
*/
#ifndef LV_IMAGE_DSC_H
#define LV_IMAGE_DSC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
/*********************
* DEFINES
*********************/
/** Magic number for lvgl image, 9 means lvgl version 9
* It must be neither a valid ASCII character nor larger than 0x80. See `lv_image_src_get_type`.
*/
#define LV_IMAGE_HEADER_MAGIC (0x19)
LV_EXPORT_CONST_INT(LV_IMAGE_HEADER_MAGIC);
/**********************
* TYPEDEFS
**********************/
typedef enum _lvimage_flags_t {
/**
* For RGB map of the image data, mark if it's pre-multiplied with alpha.
* For indexed image, this bit indicated palette data is pre-multiplied with alpha.
*/
LV_IMAGE_FLAGS_PREMULTIPLIED = 0x0001,
/**
* The image data is compressed, so decoder needs to decode image firstly.
* If this flag is set, the whole image will be decompressed upon decode, and
* `get_area_cb` won't be necessary.
*/
LV_IMAGE_FLAGS_COMPRESSED = 0x0008,
/*Below flags are applicable only for draw buffer header.*/
/**
* The image is allocated from heap, thus should be freed after use.
*/
LV_IMAGE_FLAGS_ALLOCATED = 0x0010,
/**
* If the image data is malloced and can be processed in place.
* In image decoder post processing, this flag means we modify it in-place.
*/
LV_IMAGE_FLAGS_MODIFIABLE = 0x0020,
/**
* Flags reserved for user, lvgl won't use these bits.
*/
LV_IMAGE_FLAGS_USER1 = 0x0100,
LV_IMAGE_FLAGS_USER2 = 0x0200,
LV_IMAGE_FLAGS_USER3 = 0x0400,
LV_IMAGE_FLAGS_USER4 = 0x0800,
LV_IMAGE_FLAGS_USER5 = 0x1000,
LV_IMAGE_FLAGS_USER6 = 0x2000,
LV_IMAGE_FLAGS_USER7 = 0x4000,
LV_IMAGE_FLAGS_USER8 = 0x8000,
} lv_image_flags_t;
typedef enum {
LV_IMAGE_COMPRESS_NONE = 0,
LV_IMAGE_COMPRESS_RLE, /**< LVGL custom RLE compression */
LV_IMAGE_COMPRESS_LZ4,
} lv_image_compress_t;
#if LV_BIG_ENDIAN_SYSTEM
typedef struct {
uint32_t reserved_2: 16; /**< Reserved to be used later*/
uint32_t stride: 16; /**< Number of bytes in a row*/
uint32_t h: 16;
uint32_t w: 16;
uint32_t flags: 16; /**< Image flags, see `lv_image_flags_t`*/
uint32_t cf : 8; /**< Color format: See `lv_color_format_t`*/
uint32_t magic: 8; /**< Magic number. Must be LV_IMAGE_HEADER_MAGIC*/
} lv_image_header_t;
#else
typedef struct {
uint32_t magic: 8; /**< Magic number. Must be LV_IMAGE_HEADER_MAGIC*/
uint32_t cf : 8; /**< Color format: See `lv_color_format_t`*/
uint32_t flags: 16; /**< Image flags, see `lv_image_flags_t`*/
uint32_t w: 16;
uint32_t h: 16;
uint32_t stride: 16; /**< Number of bytes in a row*/
uint32_t reserved_2: 16; /**< Reserved to be used later*/
} lv_image_header_t;
#endif
typedef struct {
void * buf;
uint32_t stride; /**< Number of bytes in a row*/
} lv_yuv_plane_t;
typedef union {
lv_yuv_plane_t yuv; /**< packed format*/
struct {
lv_yuv_plane_t y;
lv_yuv_plane_t u;
lv_yuv_plane_t v;
} planar; /**< planar format with 3 plane*/
struct {
lv_yuv_plane_t y;
lv_yuv_plane_t uv;
} semi_planar; /**< planar format with 2 plane*/
} lv_yuv_buf_t;
/**
* Struct to describe a constant image resource.
* It's similar to lv_draw_buf_t, but the data is constant.
*/
typedef struct {
lv_image_header_t header; /**< A header describing the basics of the image*/
uint32_t data_size; /**< Size of the image in bytes*/
const uint8_t * data; /**< Pointer to the data of the image*/
const void * reserved; /**< A reserved field to make it has same size as lv_draw_buf_t*/
} lv_image_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_IMAGE_DSC_H*/
@@ -0,0 +1,122 @@
/**
* MIT License
*
* -----------------------------------------------------------------------------
* Copyright (c) 2008-24 Think Silicon Single Member PC
* -----------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/**
* @file lv_draw_nema_gfx.h
*
*/
#ifndef LV_DRAW_NEMA_GFX_H
#define LV_DRAW_NEMA_GFX_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_NEMA_GFX
#include "lv_draw_nema_gfx_utils.h"
#include "../lv_draw_private.h"
#include "../lv_draw_buf_private.h"
#include "../lv_draw_image_private.h"
#include "../lv_image_decoder_private.h"
#include "../lv_draw_label_private.h"
#include "../lv_draw_mask_private.h"
#include "../lv_draw_rect_private.h"
#include "../lv_draw_triangle_private.h"
#include "../lv_draw_vector_private.h"
#include "../../misc/lv_area_private.h"
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_unit_t base_unit;
lv_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
uint32_t idx;
nema_cmdlist_t cl;
#if LV_USE_NEMA_VG
NEMA_VG_PAINT_HANDLE paint;
NEMA_VG_GRAD_HANDLE gradient;
NEMA_VG_PATH_HANDLE path;
#endif
} lv_draw_nema_gfx_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_nema_gfx_init(void);
void lv_draw_nema_gfx_deinit(void);
void lv_draw_nema_gfx_fill(lv_draw_unit_t * draw_unit,
const lv_draw_fill_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_nema_gfx_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle_dsc_t * dsc);
void lv_draw_nema_gfx_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_nema_gfx_label(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_nema_gfx_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
void lv_draw_nema_gfx_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc);
void lv_draw_nema_gfx_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_nema_gfx_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * dsc,
const lv_area_t * coords);
/**********************
* MACROS
**********************/
#endif /*LV_USE_NEMA_GFX*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_NEMA_GFX_H*/
@@ -0,0 +1,125 @@
/**
* MIT License
*
* -----------------------------------------------------------------------------
* Copyright (c) 2008-24 Think Silicon Single Member PC
* -----------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next paragraph)
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/**
* @file lv_draw_nema_gfx.h
*
*/
#ifndef LV_DRAW_NEMA_GFX_UTILS_H
#define LV_DRAW_NEMA_GFX_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_NEMA_GFX
#include "../sw/lv_draw_sw.h"
#include "nema_core.h"
#include "nema_utils.h"
#include "nema_error.h"
#include "nema_provisional.h"
#include "nema_vg.h"
/*********************
* DEFINES
*********************/
#ifndef NEMA_VIRT2PHYS
#define NEMA_VIRT2PHYS
#else
uintptr_t NEMA_VIRT2PHYS(void * addr);
#endif
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#if LV_COLOR_DEPTH == 8
#define LV_NEMA_GFX_COLOR_FORMAT NEMA_L8
#define LV_NEMA_GFX_FORMAT_MULTIPLIER 1
#elif LV_COLOR_DEPTH == 16
#define LV_NEMA_GFX_COLOR_FORMAT NEMA_RGB565
#define LV_NEMA_GFX_FORMAT_MULTIPLIER 2
#elif LV_COLOR_DEPTH == 24
#define LV_NEMA_GFX_COLOR_FORMAT NEMA_BGR24
#define LV_NEMA_GFX_FORMAT_MULTIPLIER 3
#elif LV_COLOR_DEPTH == 32
#define LV_NEMA_GFX_COLOR_FORMAT NEMA_BGRA8888
#define LV_NEMA_GFX_FORMAT_MULTIPLIER 4
#else
/*Can't use GPU with other formats*/
#error Selected Color Depth Not Supported
#endif
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Convert a `lv_color_format_t` to a Nema color format.
* @param cf The LVGL color format
* @return The Nema color format
*/
uint32_t lv_nemagfx_cf_to_nema(lv_color_format_t cf);
/**
* Get NemaGFX blending mode
*
* @param[in] lv_blend_mode The LVGL blend mode
*
* @return NemaGFX blending mode
*
*/
uint32_t lv_nemagfx_blending_mode(lv_blend_mode_t lv_blend_mode);
/**
* Get NemaGFX blending mode
*
* @param[in] gradient NemaGFX Gradient Buffer
*
* @param[in] lv_grad Gradient descripto
*
* @param[in] opa Descriptor's opacity
*
*/
void lv_nemagfx_grad_set(NEMA_VG_GRAD_HANDLE gradient, lv_grad_dsc_t lv_grad, lv_opa_t opa);
/**********************
* MACROS
**********************/
#endif /*LV_USE_NEMA_GFX*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_NEMA_GFX_UTILS_H*/
@@ -0,0 +1,75 @@
/**
* @file lv_draw_pxp.h
*
*/
/**
* Copyright 2022-2024 NXP
*
* SPDX-License-Identifier: MIT
*/
#ifndef LV_DRAW_PXP_H
#define LV_DRAW_PXP_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
#if LV_USE_PXP
#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP
#include "../../sw/lv_draw_sw_private.h"
#include "../../../misc/lv_area_private.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef lv_draw_sw_unit_t lv_draw_pxp_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_pxp_init(void);
void lv_draw_pxp_deinit(void);
void lv_draw_pxp_rotate(const void * src_buf, void * dest_buf, int32_t src_width, int32_t src_height,
int32_t src_stride, int32_t dest_stride, lv_display_rotation_t rotation,
lv_color_format_t cf);
#if LV_USE_DRAW_PXP
void lv_draw_buf_pxp_init_handlers(void);
void lv_draw_pxp_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_pxp_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_pxp_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_PXP*/
#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/
#endif /*LV_USE_PXP*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_PXP_H*/
+104
View File
@@ -0,0 +1,104 @@
/**
* @file lv_pxp_cfg.h
*
*/
/**
* Copyright 2020-2023 NXP
*
* SPDX-License-Identifier: MIT
*/
#ifndef LV_PXP_CFG_H
#define LV_PXP_CFG_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
#if LV_USE_PXP
#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP
#include "fsl_cache.h"
#include "fsl_pxp.h"
#include "../../../misc/lv_log.h"
/*********************
* DEFINES
*********************/
/** PXP module instance to use*/
#define PXP_ID PXP
/** PXP interrupt line ID*/
#define PXP_IRQ_ID PXP_IRQn
/**********************
* TYPEDEFS
**********************/
/**
* NXP PXP device configuration.
*/
typedef struct {
/** Callback for PXP interrupt initialization*/
void (*pxp_interrupt_init)(void);
/** Callback for PXP interrupt de-initialization*/
void (*pxp_interrupt_deinit)(void);
/** Callback for PXP start*/
void (*pxp_run)(void);
/** Callback for waiting of PXP completion*/
void (*pxp_wait)(void);
} pxp_cfg_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Reset and initialize PXP device. This function should be called as a part
* of display init sequence.
*/
void lv_pxp_init(void);
/**
* Disable PXP device. Should be called during display deinit sequence.
*/
void lv_pxp_deinit(void);
/**
* Reset PXP device.
*/
void lv_pxp_reset(void);
/**
* Clear cache and start PXP.
*/
void lv_pxp_run(void);
/**
* Wait for PXP completion.
*/
void lv_pxp_wait(void);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/
#endif /*LV_USE_PXP*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_PXP_CFG_H*/
+62
View File
@@ -0,0 +1,62 @@
/**
* @file lv_pxp_osa.h
*
*/
/**
* Copyright 2020, 2022-2023 NXP
*
* SPDX-License-Identifier: MIT
*/
#ifndef LV_PXP_OSA_H
#define LV_PXP_OSA_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
#if LV_USE_PXP
#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP
#include "lv_pxp_cfg.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* PXP device interrupt handler. Used to check PXP task completion status.
*/
void PXP_IRQHandler(void);
/**
* Get the PXP default configuration.
*/
pxp_cfg_t * pxp_get_default_cfg(void);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/
#endif /*LV_USE_PXP*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_PXP_OSA_H*/
@@ -0,0 +1,84 @@
/**
* @file lv_pxp_utils.h
*
*/
/**
* Copyright 2023-2024 NXP
*
* SPDX-License-Identifier: MIT
*/
#ifndef LV_PXP_UTILS_H
#define LV_PXP_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
#if LV_USE_PXP
#if LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP
#include "fsl_pxp.h"
#include "../../../misc/lv_color.h"
/*********************
* DEFINES
*********************/
#if LV_USE_PXP_ASSERT
#define PXP_ASSERT(expr) LV_ASSERT(expr)
#else
#define PXP_ASSERT(expr)
#endif
#define PXP_ASSERT_MSG(expr, msg) \
do { \
if(!(expr)) { \
LV_LOG_ERROR(msg); \
PXP_ASSERT(false); \
} \
} while(0)
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
pxp_output_pixel_format_t pxp_get_out_px_format(lv_color_format_t cf);
pxp_as_pixel_format_t pxp_get_as_px_format(lv_color_format_t cf);
#if LV_USE_DRAW_PXP
pxp_ps_pixel_format_t pxp_get_ps_px_format(lv_color_format_t cf);
bool pxp_buf_aligned(const void * buf, uint32_t stride);
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_DRAW_PXP*/
#endif /*LV_USE_DRAW_PXP || LV_USE_ROTATE_PXP*/
#endif /*LV_USE_PXP*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_PXP_UTILS_H*/
@@ -0,0 +1,86 @@
/**
* @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 "../../sw/lv_draw_sw_private.h"
#include "../../../misc/lv_area_private.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct lv_draw_vglite_unit {
lv_draw_sw_unit_t;
#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(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vglite_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vglite_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vglite_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vglite_label(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vglite_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
void lv_draw_vglite_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc);
void lv_draw_vglite_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VGLITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_VGLITE_H*/
@@ -0,0 +1,124 @@
/**
* @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 "../../sw/lv_draw_sw.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*/
@@ -0,0 +1,78 @@
/**
* @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 "../../sw/lv_draw_sw.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*/
@@ -0,0 +1,97 @@
/**
* @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 "../../sw/lv_draw_sw.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*/
@@ -0,0 +1,179 @@
/**
* @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 "../../sw/lv_draw_sw.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)
#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)
/**********************
* 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*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_opengles.h
*
*/
#ifndef LV_DRAW_OPENGLES_H
#define LV_DRAW_OPENGLES_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_DRAW_OPENGLES
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_opengles_init(void);
void lv_draw_opengles_deinit(void);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_OPENGLES*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_OPENGLES_H*/
@@ -0,0 +1,105 @@
/**
* @file lv_draw_dave2d.h
*
*/
#ifndef LV_DRAW_DAVE2D_H
#define LV_DRAW_DAVE2D_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
#if LV_USE_DRAW_DAVE2D
#include "../../lv_draw.h"
#include "../../lv_draw_private.h"
#include "hal_data.h"
#include "lv_draw_dave2d_utils.h"
#include "../../lv_draw_rect.h"
#include "../../lv_draw_line.h"
#include "../../lv_draw_arc.h"
#include "../../lv_draw_label.h"
#include "../../lv_draw_image.h"
#include "../../lv_draw_triangle.h"
#include "../../lv_draw_buf.h"
/*********************
* DEFINES
*********************/
#define D2_RENDER_EACH_OPERATION (1)
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_unit_t base_unit;
lv_draw_task_t * task_act;
#if LV_USE_OS
lv_thread_sync_t sync;
lv_thread_t thread;
#endif
uint32_t idx;
d2_device * d2_handle;
d2_renderbuffer * renderbuffer;
#if LV_USE_OS
lv_mutex_t * pd2Mutex;
#endif
} lv_draw_dave2d_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_dave2d_init(void);
void lv_draw_dave2d_image(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
void lv_draw_dave2d_fill(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_dave2d_border(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_border_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_dave2d_box_shadow(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_box_shadow_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_dave2d_label(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_dave2d_arc(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_arc_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_dave2d_line(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc);
void lv_draw_dave2d_layer(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
void lv_draw_dave2d_triangle(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_triangle_dsc_t * dsc);
void lv_draw_dave2d_mask_rect(lv_draw_dave2d_unit_t * draw_unit, const lv_draw_mask_rect_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_dave2d_transform(lv_draw_dave2d_unit_t * draw_unit, const lv_area_t * dest_area, const void * src_buf,
int32_t src_w, int32_t src_h, int32_t src_stride,
const lv_draw_image_dsc_t * draw_dsc, const lv_draw_image_sup_t * sup, lv_color_format_t cf, void * dest_buf);
/***********************
* GLOBAL VARIABLES
***********************/
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_DAVE2D*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_USE_DRAW_DAVE2D*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_dave2d_utils.h
*
*/
#ifndef LV_DRAW_DAVE2D_UTILS_H
#define LV_DRAW_DAVE2D_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
d2_color lv_draw_dave2d_lv_colour_to_d2_colour(lv_color_t color);
d2_s32 lv_draw_dave2d_cf_fb_get(void);
d2_u32 lv_draw_dave2d_lv_colour_fmt_to_d2_fmt(lv_color_format_t colour_format);
void d2_framebuffer_from_layer(d2_device * handle, lv_layer_t * layer);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_DAVE2D_UTILS_H*/
+87
View File
@@ -0,0 +1,87 @@
/**
* @file lv_draw_sdl.h
*
*/
#ifndef LV_DRAW_SDL_H
#define LV_DRAW_SDL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw.h"
#if LV_USE_DRAW_SDL
#include "../../misc/cache/lv_cache.h"
#include "../../misc/lv_area.h"
#include "../../misc/lv_color.h"
#include "../../display/lv_display.h"
#include "../../osal/lv_os.h"
#include "../../draw/lv_draw_label.h"
#include "../../draw/lv_draw_rect.h"
#include "../../draw/lv_draw_arc.h"
#include "../../draw/lv_draw_image.h"
#include "../../draw/lv_draw_triangle.h"
#include "../../draw/lv_draw_line.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_draw_unit_t base_unit;
lv_draw_task_t * task_act;
lv_cache_t * texture_cache;
} lv_draw_sdl_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_sdl_init(void);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sdl_image(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
void lv_draw_sdl_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_sdl_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_sdl_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_sdl_label(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc, const lv_area_t * coords);
void lv_draw_sdl_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * dsc, const lv_area_t * coords);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sdl_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc);
void lv_draw_sdl_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc, const lv_area_t * coords);
void lv_draw_sdl_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle_dsc_t * dsc);
void lv_draw_sdl_mask_rect(lv_draw_unit_t * draw_unit, const lv_draw_mask_rect_dsc_t * dsc, const lv_area_t * coords);
/***********************
* GLOBAL VARIABLES
***********************/
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SDL*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SDL_H*/
@@ -0,0 +1,589 @@
/**
* @file lv_draw_sw_arm2d.h
*
*/
#ifndef LV_DRAW_SW_ARM2D_H
#define LV_DRAW_SW_ARM2D_H
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-OFF* */
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
#include "../../../misc/lv_area_private.h"
#if LV_USE_DRAW_ARM2D_SYNC
#define __ARM_2D_IMPL__
#include "arm_2d.h"
#include "__arm_2d_impl.h"
#if defined(__IS_COMPILER_ARM_COMPILER_5__)
#pragma diag_suppress 174,177,188,68,513,144,1296
#elif defined(__IS_COMPILER_IAR__)
#pragma diag_suppress=Pa093
#elif defined(__IS_COMPILER_GCC__)
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#endif
/*********************
* DEFINES
*********************/
#ifndef LV_DRAW_SW_RGB565_SWAP
#define LV_DRAW_SW_RGB565_SWAP(__buf_ptr, __buf_size_px) \
lv_draw_sw_rgb565_swap_helium((__buf_ptr), (__buf_size_px))
#endif
#ifndef LV_DRAW_SW_IMAGE
#define LV_DRAW_SW_IMAGE(__transformed, \
__cf, \
__src_buf, \
__img_coords, \
__src_stride, \
__blend_area, \
__draw_unit, \
__draw_dsc) \
lv_draw_sw_image_helium( (__transformed), \
(__cf), \
(uint8_t *)(__src_buf), \
(__img_coords), \
(__src_stride), \
(__blend_area), \
(__draw_unit), \
(__draw_dsc))
#endif
#ifndef LV_DRAW_SW_RGB565_RECOLOR
#define LV_DRAW_SW_RGB565_RECOLOR(__src_buf, __blend_area, __color, __opa) \
lv_draw_sw_image_recolor_rgb565( (__src_buf), \
&(__blend_area), \
(__color), \
(__opa))
#endif
#ifndef LV_DRAW_SW_RGB888_RECOLOR
#define LV_DRAW_SW_RGB888_RECOLOR( __src_buf, \
__blend_area, \
__color, \
__opa, \
__cf) \
lv_draw_sw_image_recolor_rgb888( (__src_buf), \
&(__blend_area), \
(__color), \
(__opa), \
(__cf))
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
extern void arm_2d_helper_swap_rgb16(uint16_t * phwBuffer, uint32_t wCount);
/**********************
* MACROS
**********************/
#define __RECOLOUR_BEGIN() \
do { \
lv_color_t *rgb_tmp_buf = NULL; \
if(draw_dsc->recolor_opa > LV_OPA_MIN) { \
if(LV_COLOR_FORMAT_RGB565 == des_cf) { \
rgb_tmp_buf \
= lv_malloc(src_w * src_h * sizeof(uint16_t)); \
if (NULL == rgb_tmp_buf) { \
LV_LOG_WARN( \
"Failed to allocate memory for accelerating recolor, " \
"use normal route instead."); \
break; \
} \
lv_memcpy( rgb_tmp_buf, \
src_buf, \
src_w * src_h * sizeof(uint16_t)); \
arm_2d_size_t copy_size = { \
.iWidth = src_w, \
.iHeight = src_h, \
}; \
/* apply re-color */ \
__arm_2d_impl_rgb565_colour_filling_with_opacity( \
(uint16_t *)rgb_tmp_buf, \
src_w, \
&copy_size, \
lv_color_to_u16(draw_dsc->recolor), \
draw_dsc->recolor_opa); \
\
/* replace src_buf for the following operation */ \
src_buf = (const uint8_t *)rgb_tmp_buf; \
} \
else if(LV_COLOR_FORMAT_XRGB8888 == des_cf) { \
rgb_tmp_buf \
= lv_malloc(src_w * src_h * sizeof(uint32_t)); \
if (NULL == rgb_tmp_buf) { \
LV_LOG_WARN( \
"Failed to allocate memory for accelerating recolor, " \
"use normal route instead."); \
break; \
} \
lv_memcpy( rgb_tmp_buf, \
src_buf, \
src_w * src_h * sizeof(uint32_t)); \
arm_2d_size_t copy_size = { \
.iWidth = src_w, \
.iHeight = src_h, \
}; \
/* apply re-color */ \
__arm_2d_impl_cccn888_colour_filling_with_opacity( \
(uint32_t *)rgb_tmp_buf, \
src_w, \
&copy_size, \
lv_color_to_u32(draw_dsc->recolor), \
draw_dsc->recolor_opa); \
\
/* replace src_buf for the following operation */ \
src_buf = (const uint8_t *)rgb_tmp_buf; \
} \
} \
do {
#define __RECOLOUR_END() \
} while(0); \
if (NULL != rgb_tmp_buf) { \
lv_free(rgb_tmp_buf); \
} \
} while(0);
static inline lv_result_t lv_draw_sw_rgb565_swap_helium(void * buf, uint32_t buf_size_px)
{
arm_2d_helper_swap_rgb16((uint16_t *)buf, buf_size_px);
return LV_RESULT_OK;
}
static inline lv_result_t lv_draw_sw_image_helium(
bool is_transform,
lv_color_format_t src_cf,
const uint8_t *src_buf,
const lv_area_t * coords,
int32_t src_stride,
const lv_area_t * des_area,
lv_draw_unit_t * draw_unit,
const lv_draw_image_dsc_t * draw_dsc)
{
lv_result_t result = LV_RESULT_INVALID;
lv_layer_t * layer = draw_unit->target_layer;
lv_color_format_t des_cf = layer->color_format;
static bool arm_2d_initialized = false;
if (!arm_2d_initialized) {
arm_2d_initialized = true;
arm_2d_init();
}
do {
if (!is_transform) {
break;
}
if(draw_dsc->scale_x != draw_dsc->scale_y) {
break;
}
/* filter the unsupported colour format combination */
if((LV_COLOR_FORMAT_RGB565 == des_cf)
&& !( (LV_COLOR_FORMAT_RGB565 == src_cf)
|| (LV_COLOR_FORMAT_RGB565A8 == src_cf))) {
break;
}
#if 0 /* a temporary patch */
if((LV_COLOR_FORMAT_XRGB8888 == des_cf)
&& !( (LV_COLOR_FORMAT_ARGB8888 == src_cf)
|| (LV_COLOR_FORMAT_XRGB8888 == src_cf))) {
break;
}
#else
if((LV_COLOR_FORMAT_XRGB8888 == des_cf)
|| (LV_COLOR_FORMAT_RGB888 == des_cf)
|| (LV_COLOR_FORMAT_ARGB8888 == des_cf)) {
break;
}
#endif
/* ------------- prepare parameters for arm-2d APIs - BEGIN --------- */
lv_area_t blend_area;
if(!lv_area_intersect(&blend_area, des_area, draw_unit->clip_area)) {
break;
}
int32_t src_w = lv_area_get_width(coords);
int32_t src_h = lv_area_get_height(coords);
arm_2d_size_t src_size = {
.iWidth = (int16_t)src_w,
.iHeight = (int16_t)src_h,
};
// arm_2d_size_t des_size;
// do{
// int32_t des_w = lv_area_get_width(&blend_area);
// int32_t des_h = lv_area_get_height(&blend_area);
// LV_ASSERT(des_w <= INT16_MAX);
// LV_ASSERT(des_h <= INT16_MAX);
// des_size.iWidth = (int16_t)des_w;
// des_size.iHeight = (int16_t)des_h;
// } while(0);
//
// arm_2d_size_t copy_size = {
// .iWidth = MIN(des_size.iWidth, src_size.iWidth),
// .iHeight = MIN(des_size.iHeight, src_size.iHeight),
// };
//
// int32_t des_stride = lv_draw_buf_width_to_stride(
// lv_area_get_width(&layer->buf_area),
// des_cf);
// uint8_t *des_buf_moved = (uint8_t *)lv_draw_layer_go_to_xy(
// layer,
// blend_area.x1 - layer->buf_area.x1,
// blend_area.y1 - layer->buf_area.y1);
uint8_t *des_buf = (uint8_t *)lv_draw_layer_go_to_xy(layer, 0, 0);
uint8_t opa = draw_dsc->opa;
/* ------------- prepare parameters for arm-2d APIs - END ----------- */
__RECOLOUR_BEGIN()
static arm_2d_tile_t target_tile_origin;
static arm_2d_tile_t target_tile;
arm_2d_region_t clip_region;
static arm_2d_region_t target_region;
target_region = (arm_2d_region_t) {
.tLocation = {
.iX = (int16_t)(coords->x1 - draw_unit->clip_area->x1),
.iY = (int16_t)(coords->y1 - draw_unit->clip_area->y1),
},
.tSize = src_size,
};
target_tile_origin = (arm_2d_tile_t) {
.tRegion = {
.tSize = {
.iWidth = (int16_t)lv_area_get_width(&layer->buf_area),
.iHeight = (int16_t)lv_area_get_height(&layer->buf_area),
},
},
.tInfo = {
.bIsRoot = true,
},
.phwBuffer = (uint16_t *)des_buf,
};
clip_region = (arm_2d_region_t) {
.tLocation = {
.iX = (int16_t)(draw_unit->clip_area->x1 - layer->buf_area.x1),
.iY = (int16_t)(draw_unit->clip_area->y1 - layer->buf_area.y1),
},
.tSize = {
.iWidth = (int16_t)lv_area_get_width(draw_unit->clip_area),
.iHeight = (int16_t)lv_area_get_height(draw_unit->clip_area),
},
};
arm_2d_tile_generate_child(&target_tile_origin,
&clip_region,
&target_tile,
false);
static arm_2d_tile_t source_tile;
source_tile = (arm_2d_tile_t) {
.tRegion = {
.tSize = {
.iWidth = (int16_t)src_w,
.iHeight = (int16_t)src_h,
},
},
.tInfo = {
.bIsRoot = true,
},
.pchBuffer = (uint8_t *)src_buf,
};
static arm_2d_location_t source_center, target_center;
source_center.iX = draw_dsc->pivot.x;
source_center.iY = draw_dsc->pivot.y;
target_center = target_region.tLocation;
target_center.iX += draw_dsc->pivot.x;
target_center.iY += draw_dsc->pivot.y;
if(LV_COLOR_FORMAT_A8 == src_cf) {
source_tile.tInfo.bHasEnforcedColour = true;
source_tile.tInfo.tColourInfo.chScheme = ARM_2D_COLOUR_GRAY8;
if(LV_COLOR_FORMAT_RGB565 == des_cf) {
arm_2d_rgb565_fill_colour_with_mask_opacity_and_transform(
&source_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
lv_color_to_u16(draw_dsc->recolor),
opa,
&target_center
);
}
else if(LV_COLOR_FORMAT_XRGB8888 == des_cf) {
arm_2d_cccn888_fill_colour_with_mask_opacity_and_transform(
&source_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
lv_color_to_int(draw_dsc->recolor),
opa,
&target_center
);
}
else {
break;
}
}
else if(LV_COLOR_FORMAT_RGB565A8 == src_cf) {
LV_ASSERT(LV_COLOR_FORMAT_RGB565 == des_cf);
/* mask_buf = src_buf + src_stride * src_w / header->w * src_h; */
const uint8_t *mask_buf = src_buf + src_stride * src_h;
int32_t mask_stride = src_stride / 2;
static arm_2d_tile_t mask_tile;
mask_tile = source_tile;
mask_tile.tInfo.bHasEnforcedColour = true;
mask_tile.tInfo.tColourInfo.chScheme = ARM_2D_COLOUR_GRAY8;
mask_tile.pchBuffer = (uint8_t *)mask_buf;
if(opa >= LV_OPA_MAX) {
arm_2d_rgb565_tile_transform_with_src_mask(
&source_tile,
&mask_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
&target_center
);
}
else {
arm_2d_rgb565_tile_transform_with_src_mask_and_opacity(
&source_tile,
&mask_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
opa,
&target_center
);
}
}
else if(LV_COLOR_FORMAT_RGB565 == src_cf) {
LV_ASSERT(LV_COLOR_FORMAT_RGB565 == des_cf);
if(opa >= LV_OPA_MAX) {
#if ARM_2D_VERSION >= 10106
arm_2d_rgb565_tile_transform_only(
&source_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
&target_center);
#else
arm_2dp_rgb565_tile_transform_only_prepare(
NULL,
&source_tile,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
(float)(draw_dsc->scale_x / 256.0f));
arm_2dp_tile_transform(NULL,
&target_tile,
NULL,
&target_center);
#endif
}
else {
arm_2d_rgb565_tile_transform_only_with_opacity(
&source_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
opa,
&target_center
);
}
}
#if 0 /* a temporary patch */
else if(LV_COLOR_FORMAT_ARGB8888 == src_cf) {
LV_ASSERT(LV_COLOR_FORMAT_XRGB8888 == des_cf);
static arm_2d_tile_t mask_tile;
mask_tile = source_tile;
mask_tile.tInfo.bHasEnforcedColour = true;
mask_tile.tInfo.tColourInfo.chScheme = ARM_2D_CHANNEL_8in32;
mask_tile.pchBuffer = (uint8_t *)src_buf + 3;
if(opa >= LV_OPA_MAX) {
arm_2d_cccn888_tile_transform_with_src_mask(
&source_tile,
&mask_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
&target_center
);
}
else {
arm_2d_cccn888_tile_transform_with_src_mask_and_opacity(
&source_tile,
&mask_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
opa,
&target_center
);
}
}
else if(LV_COLOR_FORMAT_XRGB8888 == src_cf) {
LV_ASSERT(LV_COLOR_FORMAT_XRGB8888 == des_cf);
if(opa >= LV_OPA_MAX) {
arm_2d_cccn888_tile_transform_only(
&source_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
&target_center
);
}
else {
arm_2d_cccn888_tile_transform_only_with_opacity(
&source_tile,
&target_tile,
NULL,
source_center,
ARM_2D_ANGLE((draw_dsc->rotation / 10.0f)),
draw_dsc->scale_x / 256.0f,
opa,
&target_center
);
}
}
#endif
else {
break;
}
result = LV_RESULT_OK;
__RECOLOUR_END()
} while(0);
return result;
}
static inline lv_result_t lv_draw_sw_image_recolor_rgb565(
const uint8_t *src_buf,
const lv_area_t * blend_area,
lv_color_t color,
lv_opa_t opa)
{
int32_t src_w = lv_area_get_width(blend_area);
int32_t src_h = lv_area_get_height(blend_area);
arm_2d_size_t copy_size = {
.iWidth = (int16_t)src_w,
.iHeight = (int16_t)src_h,
};
__arm_2d_impl_rgb565_colour_filling_with_opacity(
(uint16_t *)src_buf,
src_w,
&copy_size,
lv_color_to_u16(color),
opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_draw_sw_image_recolor_rgb888(
const uint8_t *src_buf,
const lv_area_t * blend_area,
lv_color_t color,
lv_opa_t opa,
lv_color_format_t src_cf)
{
if(LV_COLOR_FORMAT_XRGB8888 != src_cf) {
return LV_RESULT_INVALID;
}
int32_t src_w = lv_area_get_width(blend_area);
int32_t src_h = lv_area_get_height(blend_area);
arm_2d_size_t copy_size = {
.iWidth = (int16_t)src_w,
.iHeight = (int16_t)src_h,
};
__arm_2d_impl_cccn888_colour_filling_with_opacity(
(uint32_t *)src_buf,
src_w,
&copy_size,
lv_color_to_u32(color),
opa);
return LV_RESULT_OK;
}
#endif /* LV_USE_DRAW_ARM2D_SYNC */
/* *INDENT-ON* */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_ARM2D_H */
@@ -0,0 +1,60 @@
/**
* @file lv_draw_sw_helium.h
*
*/
#ifndef LV_DRAW_SW_HELIUM_H
#define LV_DRAW_SW_HELIUM_H
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-OFF* */
/*********************
* INCLUDES
*********************/
#include "../../../lv_conf_internal.h"
/* detect whether helium is available based on arm compilers' standard */
#if defined(__ARM_FEATURE_MVE) && __ARM_FEATURE_MVE
#ifdef LV_DRAW_SW_HELIUM_CUSTOM_INCLUDE
#include LV_DRAW_SW_HELIUM_CUSTOM_INCLUDE
#endif
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/*********************
* POST INCLUDES
*********************/
/* use arm-2d as the default helium acceleration */
#include "lv_draw_sw_arm2d.h"
#endif /* defined(__ARM_FEATURE_MVE) && __ARM_FEATURE_MVE */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_HELIUM_H*/
@@ -0,0 +1,937 @@
/**
* @file lv_blend_arm2d.h
*
*/
#ifndef LV_BLEND_ARM2D_H
#define LV_BLEND_ARM2D_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../../lv_conf_internal.h"
#if LV_USE_DRAW_ARM2D_SYNC
#define __ARM_2D_IMPL__
#include "arm_2d.h"
#include "__arm_2d_impl.h"
#if defined(__IS_COMPILER_ARM_COMPILER_5__)
#pragma diag_suppress 174,177,188,68,513,144,1296
#elif defined(__IS_COMPILER_IAR__)
#pragma diag_suppress=Pa093
#elif defined(__IS_COMPILER_GCC__)
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#endif
#if ARM_2D_VERSION < 10106ul
#error Please upgrade to Arm-2D v1.1.6 or above
#endif
#ifndef LV_ARM2D_XRGB888_ALPHA_ALWAYS_FF
#define LV_ARM2D_XRGB888_ALPHA_ALWAYS_FF 1
#endif
/*********************
* DEFINES
*********************/
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB565
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB565(dsc) \
lv_color_blend_to_rgb565_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB565_WITH_OPA
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB565_WITH_OPA(dsc) \
lv_color_blend_to_rgb565_with_opa_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB565_WITH_MASK
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB565_WITH_MASK(dsc) \
lv_color_blend_to_rgb565_with_mask_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB565_MIX_MASK_OPA
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB565_MIX_MASK_OPA(dsc) \
lv_color_blend_to_rgb565_mix_mask_opa_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565(dsc) \
lv_rgb565_blend_normal_to_rgb565_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565_WITH_OPA
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565_WITH_OPA(dsc) \
lv_rgb565_blend_normal_to_rgb565_with_opa_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565_WITH_MASK
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565_WITH_MASK(dsc) \
lv_rgb565_blend_normal_to_rgb565_with_mask_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565_MIX_MASK_OPA
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB565_MIX_MASK_OPA(dsc) \
lv_rgb565_blend_normal_to_rgb565_mix_mask_opa_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565(dsc, src_px_size) \
lv_rgb888_blend_normal_to_rgb565_arm2d(dsc, src_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565_WITH_OPA
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565_WITH_OPA(dsc, src_px_size) \
lv_rgb888_blend_normal_to_rgb565_with_opa_arm2d(dsc, src_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565_WITH_MASK
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565_WITH_MASK(dsc, src_px_size) \
lv_rgb888_blend_normal_to_rgb565_with_mask_arm2d(dsc, src_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565_MIX_MASK_OPA
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB565_MIX_MASK_OPA(dsc, src_px_size) \
lv_rgb888_blend_normal_to_rgb565_mix_mask_opa_arm2d(dsc, src_px_size)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565(dsc) \
lv_argb8888_blend_normal_to_rgb565_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565_WITH_OPA
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565_WITH_OPA(dsc) \
lv_argb8888_blend_normal_to_rgb565_with_opa_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565_WITH_MASK
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565_WITH_MASK(dsc) \
lv_argb8888_blend_normal_to_rgb565_with_mask_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565_MIX_MASK_OPA
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB565_MIX_MASK_OPA(dsc) \
lv_argb8888_blend_normal_to_rgb565_mix_mask_opa_arm2d(dsc)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB888
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB888(dsc, dst_px_size) \
lv_color_blend_to_rgb888_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_OPA
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_OPA(dsc, dst_px_size) \
lv_color_blend_to_rgb888_with_opa_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_MASK
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB888_WITH_MASK(dsc, dst_px_size) \
lv_color_blend_to_rgb888_with_mask_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_COLOR_BLEND_TO_RGB888_MIX_MASK_OPA
#define LV_DRAW_SW_COLOR_BLEND_TO_RGB888_MIX_MASK_OPA(dsc, dst_px_size) \
lv_color_blend_to_rgb888_mix_mask_opa_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888(dsc, dst_px_size) \
lv_rgb565_blend_normal_to_rgb888_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888_WITH_OPA
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888_WITH_OPA(dsc, dst_px_size) \
lv_rgb565_blend_normal_to_rgb888_with_opa_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888_WITH_MASK
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888_WITH_MASK(dsc, dst_px_size) \
lv_rgb565_blend_normal_to_rgb888_with_mask_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA
#define LV_DRAW_SW_RGB565_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA(dsc, dst_px_size) \
lv_rgb565_blend_normal_to_rgb888_mix_mask_opa_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888(dsc, dst_px_size, src_px_size) \
lv_rgb888_blend_normal_to_rgb888_arm2d(dsc, dst_px_size, src_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888_WITH_OPA
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888_WITH_OPA(dsc, dst_px_size, src_px_size) \
lv_rgb888_blend_normal_to_rgb888_with_opa_arm2d(dsc, dst_px_size, src_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888_WITH_MASK
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888_WITH_MASK(dsc, dst_px_size, src_px_size) \
lv_rgb888_blend_normal_to_rgb888_with_mask_arm2d(dsc, dst_px_size, src_px_size)
#endif
#ifndef LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA
#define LV_DRAW_SW_RGB888_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA(dsc, dst_px_size, src_px_size) \
lv_rgb888_blend_normal_to_rgb888_mix_mask_opa_arm2d(dsc, dst_px_size, src_px_size)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888(dsc, dst_px_size) \
lv_argb8888_blend_normal_to_rgb888_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_OPA
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_OPA(dsc, dst_px_size) \
lv_argb8888_blend_normal_to_rgb888_with_opa_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_MASK
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_WITH_MASK(dsc, dst_px_size) \
lv_argb8888_blend_normal_to_rgb888_with_mask_arm2d(dsc, dst_px_size)
#endif
#ifndef LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA
#define LV_DRAW_SW_ARGB8888_BLEND_NORMAL_TO_RGB888_MIX_MASK_OPA(dsc, dst_px_size) \
lv_argb8888_blend_normal_to_rgb888_mix_mask_opa_arm2d(dsc, dst_px_size)
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
static inline lv_result_t lv_color_blend_to_rgb565_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint16_t);
__arm_2d_impl_rgb16_colour_filling((uint16_t *)dsc->dest_buf,
stride,
&draw_size,
lv_color_to_u16(dsc->color));
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb565_with_opa_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint16_t);
__arm_2d_impl_rgb565_colour_filling_with_opacity((uint16_t *)dsc->dest_buf,
stride,
&draw_size,
lv_color_to_u16(dsc->color),
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb565_with_mask_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint16_t);
__arm_2d_impl_rgb565_colour_filling_mask((uint16_t *)dsc->dest_buf,
stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
lv_color_to_u16(dsc->color));
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb565_mix_mask_opa_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint16_t);
__arm_2d_impl_rgb565_colour_filling_mask_opacity((uint16_t *)dsc->dest_buf,
stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
lv_color_to_u16(dsc->color),
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb565_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
__arm_2d_impl_rgb16_copy((uint16_t *)dsc->src_buf,
src_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb565_with_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
__arm_2d_impl_rgb565_tile_copy_opacity((uint16_t *)dsc->src_buf,
src_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb565_with_mask_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
__arm_2d_impl_rgb565_src_msk_copy((uint16_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb565_mix_mask_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
__arm_2d_impl_rgb565_tile_copy_with_src_mask_and_opacity((uint16_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb565_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t src_px_size)
{
if(src_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_cccn888_to_rgb565((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb565_with_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t src_px_size)
{
if(src_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
uint16_t * tmp_buf = (uint16_t *)lv_malloc(dsc->dest_stride * dsc->dest_h);
if(NULL == tmp_buf) {
return LV_RESULT_INVALID;
}
#if !LV_ARM2D_XRGB888_ALPHA_ALWAYS_FF
__arm_2d_impl_cccn888_to_rgb565((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)tmp_buf,
des_stride,
&draw_size);
__arm_2d_impl_rgb565_tile_copy_opacity(tmp_buf,
des_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
#else
__arm_2d_impl_ccca8888_tile_copy_to_rgb565_with_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
#endif
lv_free(tmp_buf);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb565_with_mask_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t src_px_size)
{
if(src_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
uint16_t * tmp_buf = (uint16_t *)lv_malloc(dsc->dest_stride * dsc->dest_h);
if(NULL == tmp_buf) {
return LV_RESULT_INVALID;
}
#if !LV_ARM2D_XRGB888_ALPHA_ALWAYS_FF
__arm_2d_impl_cccn888_to_rgb565((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)tmp_buf,
des_stride,
&draw_size);
__arm_2d_impl_rgb565_src_msk_copy(tmp_buf,
des_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
#else
__arm_2d_impl_ccca8888_tile_copy_to_rgb565_with_src_mask((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
#endif
lv_free(tmp_buf);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb565_mix_mask_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t src_px_size)
{
if(src_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
uint16_t * tmp_buf = (uint16_t *)lv_malloc(dsc->dest_stride * dsc->dest_h);
if(NULL == tmp_buf) {
return LV_RESULT_INVALID;
}
#if !LV_ARM2D_XRGB888_ALPHA_ALWAYS_FF
__arm_2d_impl_cccn888_to_rgb565((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)tmp_buf,
des_stride,
&draw_size);
__arm_2d_impl_rgb565_tile_copy_with_src_mask_and_opacity(tmp_buf,
des_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
#else
__arm_2d_impl_ccca8888_tile_copy_to_rgb565_with_src_mask_and_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
#endif
lv_free(tmp_buf);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb565_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_to_rgb565((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb565_with_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_tile_copy_to_rgb565_with_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb565_with_mask_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_tile_copy_to_rgb565_with_src_mask((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb565_mix_mask_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc)
{
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint16_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_tile_copy_to_rgb565_with_src_mask_and_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint16_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb888_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc, uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint32_t);
__arm_2d_impl_rgb32_colour_filling((uint32_t *)dsc->dest_buf,
stride,
&draw_size,
lv_color_to_u32(dsc->color));
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb888_with_opa_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint32_t);
__arm_2d_impl_cccn888_colour_filling_with_opacity((uint32_t *)dsc->dest_buf,
stride,
&draw_size,
lv_color_to_u32(dsc->color),
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb888_with_mask_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint32_t);
__arm_2d_impl_cccn888_colour_filling_mask((uint32_t *)dsc->dest_buf,
stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
lv_color_to_u32(dsc->color));
return LV_RESULT_OK;
}
static inline lv_result_t lv_color_blend_to_rgb888_mix_mask_opa_arm2d(lv_draw_sw_blend_fill_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t stride = (dsc->dest_stride) / sizeof(uint32_t);
__arm_2d_impl_cccn888_colour_filling_mask_opacity((uint32_t *)dsc->dest_buf,
stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
lv_color_to_u32(dsc->color),
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb888_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
__arm_2d_impl_rgb565_to_cccn888((uint16_t *)dsc->src_buf,
src_stride,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb888_with_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
uint32_t * tmp_buf = (uint32_t *)lv_malloc(dsc->dest_stride * dsc->dest_h);
if(NULL == tmp_buf) {
return LV_RESULT_INVALID;
}
/* get rgb565 */
__arm_2d_impl_rgb565_to_cccn888((uint16_t *)dsc->src_buf,
src_stride,
(uint32_t *)tmp_buf,
des_stride,
&draw_size);
__arm_2d_impl_cccn888_tile_copy_opacity(tmp_buf,
des_stride,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
lv_free(tmp_buf);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb888_with_mask_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
uint32_t * tmp_buf = (uint32_t *)lv_malloc(dsc->dest_stride * dsc->dest_h);
if(NULL == tmp_buf) {
return LV_RESULT_INVALID;
}
__arm_2d_impl_rgb565_to_cccn888((uint16_t *)dsc->src_buf,
src_stride,
(uint32_t *)tmp_buf,
des_stride,
&draw_size);
__arm_2d_impl_cccn888_src_msk_copy(tmp_buf,
des_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size);
lv_free(tmp_buf);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb565_blend_normal_to_rgb888_mix_mask_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint16_t);
uint32_t * tmp_buf = (uint32_t *)lv_malloc(dsc->dest_stride * dsc->dest_h);
if(NULL == tmp_buf) {
return LV_RESULT_INVALID;
}
__arm_2d_impl_rgb565_to_cccn888((uint16_t *)dsc->src_buf,
src_stride,
(uint32_t *)tmp_buf,
des_stride,
&draw_size);
__arm_2d_impl_cccn888_tile_copy_with_src_mask_and_opacity(tmp_buf,
des_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
lv_free(tmp_buf);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb888_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size,
uint32_t src_px_size)
{
if((dst_px_size == 3) || (src_px_size == 3)) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_rgb32_copy((uint32_t *)dsc->src_buf,
src_stride,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb888_with_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size, uint32_t src_px_size)
{
if((dst_px_size == 3) || (src_px_size == 3)) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_cccn888_tile_copy_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb888_with_mask_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size, uint32_t src_px_size)
{
if((dst_px_size == 3) || (src_px_size == 3)) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_cccn888_src_msk_copy((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_rgb888_blend_normal_to_rgb888_mix_mask_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size, uint32_t src_px_size)
{
if((dst_px_size == 3) || (src_px_size == 3)) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_cccn888_tile_copy_with_src_mask_and_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb888_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_to_cccn888((uint32_t *)dsc->src_buf,
src_stride,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb888_with_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_tile_copy_to_cccn888_with_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb888_with_mask_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_tile_copy_to_cccn888_with_src_mask((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size);
return LV_RESULT_OK;
}
static inline lv_result_t lv_argb8888_blend_normal_to_rgb888_mix_mask_opa_arm2d(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dst_px_size)
{
if(dst_px_size == 3) {
return LV_RESULT_INVALID;
}
arm_2d_size_t draw_size = {dsc->dest_w, dsc->dest_h};
int16_t des_stride = dsc->dest_stride / sizeof(uint32_t);
int16_t src_stride = dsc->src_stride / sizeof(uint32_t);
__arm_2d_impl_ccca8888_tile_copy_to_cccn888_with_src_mask_and_opacity((uint32_t *)dsc->src_buf,
src_stride,
(uint8_t *)dsc->mask_buf,
dsc->mask_stride,
&draw_size,
(uint32_t *)dsc->dest_buf,
des_stride,
&draw_size,
dsc->opa);
return LV_RESULT_OK;
}
/**********************
* MACROS
**********************/
#endif /* LV_USE_DRAW_ARM2D_SYNC */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_BLEND_ARM2D_H*/
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,52 @@
/**
* @file lv_draw_sw_blend.h
*
*/
#ifndef LV_DRAW_SW_BLEND_H
#define LV_DRAW_SW_BLEND_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw_mask.h"
#if LV_USE_DRAW_SW
#include "../../../misc/lv_color.h"
#include "../../../misc/lv_area.h"
#include "../../../misc/lv_style.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Call the blend function of the `layer`.
* @param draw_unit pointer to a draw unit
* @param dsc pointer to an initialized blend descriptor
*/
void lv_draw_sw_blend(lv_draw_unit_t * draw_unit, const lv_draw_sw_blend_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_H*/
@@ -0,0 +1,92 @@
/**
* @file lv_draw_sw_blend_private.h
*
*/
#ifndef LV_DRAW_SW_BLEND_PRIVATE_H
#define LV_DRAW_SW_BLEND_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_sw_blend.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_sw_blend_dsc_t {
const lv_area_t * blend_area; /**< The area with absolute coordinates to draw on `layer->buf`
* will be clipped to `layer->clip_area` */
const void * src_buf; /**< Pointer to an image to blend. If set `fill_color` is ignored */
uint32_t src_stride;
lv_color_format_t src_color_format;
const lv_area_t * src_area;
lv_opa_t opa; /**< The overall opacity*/
lv_color_t color; /**< Fill color*/
const lv_opa_t * mask_buf; /**< NULL if ignored, or an alpha mask to apply on `blend_area`*/
lv_draw_sw_mask_res_t mask_res; /**< The result of the previous mask operation */
const lv_area_t * mask_area; /**< The area of `mask_buf` with absolute coordinates*/
int32_t mask_stride;
lv_blend_mode_t blend_mode; /**< E.g. LV_BLEND_MODE_ADDITIVE*/
};
struct _lv_draw_sw_blend_fill_dsc_t {
void * dest_buf;
int32_t dest_w;
int32_t dest_h;
int32_t dest_stride;
const lv_opa_t * mask_buf;
int32_t mask_stride;
lv_color_t color;
lv_opa_t opa;
lv_area_t relative_area;
};
struct _lv_draw_sw_blend_image_dsc_t {
void * dest_buf;
int32_t dest_w;
int32_t dest_h;
int32_t dest_stride;
const lv_opa_t * mask_buf;
int32_t mask_stride;
const void * src_buf;
int32_t src_stride;
lv_color_format_t src_color_format;
lv_opa_t opa;
lv_blend_mode_t blend_mode;
lv_area_t relative_area; /**< The blend area relative to the layer's buffer area. */
lv_area_t src_area; /**< The original src area. */
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /* LV_USE_DRAW_SW */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_PRIVATE_H*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_sw_blend_to_al88.h
*
*/
#ifndef LV_DRAW_SW_BLEND_TO_AL88_H
#define LV_DRAW_SW_BLEND_TO_AL88_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_color_to_al88(lv_draw_sw_blend_fill_dsc_t * dsc);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_al88(lv_draw_sw_blend_image_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_AL88_H*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_sw_blend_to_argb8888.h
*
*/
#ifndef LV_DRAW_SW_BLEND_TO_ARGB8888_H
#define LV_DRAW_SW_BLEND_TO_ARGB8888_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_color_to_argb8888(lv_draw_sw_blend_fill_dsc_t * dsc);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_argb8888(lv_draw_sw_blend_image_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_ARGB8888_H*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_sw_blend_to_i1.h
*
*/
#ifndef LV_DRAW_SW_BLEND_TO_I1_H
#define LV_DRAW_SW_BLEND_TO_I1_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_color_to_i1(lv_draw_sw_blend_fill_dsc_t * dsc);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_i1(lv_draw_sw_blend_image_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_I1_H*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_sw_blend_to_l8.h
*
*/
#ifndef LV_DRAW_SW_BLEND_TO_L8_H
#define LV_DRAW_SW_BLEND_TO_L8_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_color_to_l8(lv_draw_sw_blend_fill_dsc_t * dsc);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_l8(lv_draw_sw_blend_image_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_L8_H*/
@@ -0,0 +1,45 @@
/**
* @file lv_draw_sw_blend_to_rgb565.h
*
*/
#ifndef LV_DRAW_SW_BLEND_TO_RGB565_H
#define LV_DRAW_SW_BLEND_TO_RGB565_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_color_to_rgb565(lv_draw_sw_blend_fill_dsc_t * dsc);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_rgb565(lv_draw_sw_blend_image_dsc_t * dsc);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_RGB565_H*/
@@ -0,0 +1,47 @@
/**
* @file lv_draw_sw_blend_to_rgb888.h
*
*/
#ifndef LV_DRAW_SW_BLEND_TO_RGB888_H
#define LV_DRAW_SW_BLEND_TO_RGB888_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw_sw.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_color_to_rgb888(lv_draw_sw_blend_fill_dsc_t * dsc,
uint32_t dest_px_size);
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_rgb888(lv_draw_sw_blend_image_dsc_t * dsc,
uint32_t dest_px_size);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_RGB888_H*/
File diff suppressed because it is too large. Load diff
+204
View File
@@ -0,0 +1,204 @@
/**
* @file lv_draw_sw.h
*
*/
#ifndef LV_DRAW_SW_H
#define LV_DRAW_SW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_draw.h"
#if LV_USE_DRAW_SW
#include "../../misc/lv_area.h"
#include "../../misc/lv_color.h"
#include "../../display/lv_display.h"
#include "../../osal/lv_os.h"
#include "../lv_draw_vector.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"
/*********************
* DEFINES
*********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the SW renderer. Called in internally.
* It creates as many SW renderers as defined in LV_DRAW_SW_DRAW_UNIT_CNT
*/
void lv_draw_sw_init(void);
/**
* Deinitialize the SW renderers
*/
void lv_draw_sw_deinit(void);
/**
* Fill an area using SW render. Handle gradient and radius.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
* @param coords the coordinates of the rectangle
*/
void lv_draw_sw_fill(lv_draw_unit_t * draw_unit, lv_draw_fill_dsc_t * dsc, const lv_area_t * coords);
/**
* Draw border with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
* @param coords the coordinates of the rectangle
*/
void lv_draw_sw_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc_t * dsc, const lv_area_t * coords);
/**
* Draw box shadow with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
* @param coords the coordinates of the rectangle for which the box shadow should be drawn
*/
void lv_draw_sw_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_dsc_t * dsc, const lv_area_t * coords);
/**
* Draw an image with SW render. It handles image decoding, tiling, transformations, and recoloring.
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor
* @param coords the coordinates of the image
*/
void lv_draw_sw_image(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
/**
* Draw a label with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
* @param coords the coordinates of the label
*/
void lv_draw_sw_label(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc, const lv_area_t * coords);
/**
* Draw an arc with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
* @param coords the coordinates of the arc
*/
void lv_draw_sw_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * dsc, const lv_area_t * coords);
/**
* Draw a line with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
*/
void lv_draw_sw_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc);
/**
* Blend a layer with SW render
* @param draw_unit pointer to a draw unit
* @param draw_dsc the draw descriptor
* @param coords the coordinates of the layer
*/
void lv_draw_sw_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc, const lv_area_t * coords);
/**
* Draw a triangle with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
*/
void lv_draw_sw_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle_dsc_t * dsc);
/**
* Mask out a rectangle with radius from a current layer
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
* @param coords the coordinates of the mask
*/
void lv_draw_sw_mask_rect(lv_draw_unit_t * draw_unit, const lv_draw_mask_rect_dsc_t * dsc, const lv_area_t * coords);
/**
* Used internally to get a transformed are of an image
* @param draw_unit pointer to a draw unit
* @param dest_area area to calculate, i.e. get this area from the transformed image
* @param src_buf source buffer
* @param src_w source buffer width in pixels
* @param src_h source buffer height in pixels
* @param src_stride source buffer stride in bytes
* @param draw_dsc draw descriptor
* @param sup supplementary data
* @param cf color format of the source buffer
* @param dest_buf the destination buffer
*/
void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_area, const void * src_buf,
int32_t src_w, int32_t src_h, int32_t src_stride,
const lv_draw_image_dsc_t * draw_dsc, const lv_draw_image_sup_t * sup, lv_color_format_t cf, void * dest_buf);
#if LV_USE_VECTOR_GRAPHIC && LV_USE_THORVG
/**
* Draw vector graphics with SW render.
* @param draw_unit pointer to a draw unit
* @param dsc the draw descriptor
*/
void lv_draw_sw_vector(lv_draw_unit_t * draw_unit, const lv_draw_vector_task_dsc_t * dsc);
#endif
/**
* Swap the upper and lower byte of an RGB565 buffer.
* Might be required if a 8bit parallel port or an SPI port send the bytes in the wrong order.
* The bytes will be swapped in place.
* @param buf pointer to buffer
* @param buf_size_px number of pixels in the buffer
*/
void lv_draw_sw_rgb565_swap(void * buf, uint32_t buf_size_px);
/**
* Invert a draw buffer in the I1 color format.
* Conventionally, a bit is set to 1 during blending if the luminance is greater than 127.
* Depending on the display controller used, you might want to have different behavior.
* The inversion will be performed in place.
* @param buf pointer to the buffer to be inverted
* @param buf_size size of the buffer in bytes
*/
void lv_draw_sw_i1_invert(void * buf, uint32_t buf_size);
/**
* Rotate a buffer into another buffer
* @param src the source buffer
* @param dest the destination buffer
* @param src_width source width in pixels
* @param src_height source height in pixels
* @param src_stride source stride in bytes (number of bytes in a row)
* @param dest_stride destination stride in bytes (number of bytes in a row)
* @param rotation LV_DISPLAY_ROTATION_0/90/180/270
* @param color_format LV_COLOR_FORMAT_RGB565/RGB888/XRGB8888/ARGB8888
*/
void lv_draw_sw_rotate(const void * src, void * dest, int32_t src_width, int32_t src_height, int32_t src_stride,
int32_t dest_stride, lv_display_rotation_t rotation, lv_color_format_t color_format);
/***********************
* GLOBAL VARIABLES
***********************/
/**********************
* MACROS
**********************/
#include "blend/lv_draw_sw_blend.h"
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_H*/
@@ -0,0 +1,203 @@
/**
* @file lv_draw_sw_gradient.h
*
*/
#ifndef LV_DRAW_SW_GRADIENT_H
#define LV_DRAW_SW_GRADIENT_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../misc/lv_color.h"
#include "../../misc/lv_style.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
#if LV_GRADIENT_MAX_STOPS < 2
#error LVGL needs at least 2 stops for gradients. Please increase the LV_GRADIENT_MAX_STOPS
#endif
#define LV_GRAD_LEFT LV_PCT(0)
#define LV_GRAD_RIGHT LV_PCT(100)
#define LV_GRAD_TOP LV_PCT(0)
#define LV_GRAD_BOTTOM LV_PCT(100)
#define LV_GRAD_CENTER LV_PCT(50)
/**********************
* TYPEDEFS
**********************/
typedef lv_color_t lv_grad_color_t;
/**********************
* PROTOTYPES
**********************/
/** Compute the color in the given gradient and fraction
* Gradient are specified in a virtual [0-255] range, so this function scales the virtual range to the given range
* @param dsc The gradient descriptor to use
* @param range The range to use in computation.
* @param frac The current part used in the range. frac is in [0; range]
* @param color_out Calculated gradient color
* @param opa_out Calculated opacity
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_gradient_color_calculate(const lv_grad_dsc_t * dsc, int32_t range,
int32_t frac, lv_grad_color_t * color_out, lv_opa_t * opa_out);
/** Get a gradient cache from the given parameters */
lv_grad_t * lv_gradient_get(const lv_grad_dsc_t * gradient, int32_t w, int32_t h);
/**
* Clean up the gradient item after it was get with `lv_grad_get_from_cache`.
* @param grad pointer to a gradient
*/
void lv_gradient_cleanup(lv_grad_t * grad);
/**
* Initialize gradient color map from a table
* @param grad pointer to a gradient descriptor
* @param colors color array
* @param fracs position array (0..255): if NULL, then colors are distributed evenly
* @param opa opacity array: if NULL, then LV_OPA_COVER is assumed
* @param num_stops number of gradient stops (1..LV_GRADIENT_MAX_STOPS)
*/
void lv_gradient_init_stops(lv_grad_dsc_t * grad, const lv_color_t colors[], const lv_opa_t opa[],
const uint8_t fracs[], int num_stops);
#if LV_USE_DRAW_SW_COMPLEX_GRADIENTS
/**
* Helper function to initialize linear gradient
* @param dsc gradient descriptor
* @param from_x start x position: can be a coordinate or an lv_pct() value
* predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well
* @param from_y start y position
* @param to_x end x position
* @param to_y end y position
* @param extend one of LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT or LV_GRAD_EXTEND_REFLECT
*/
void lv_grad_linear_init(lv_grad_dsc_t * dsc, int32_t from_x, int32_t from_y, int32_t to_x, int32_t to_y,
lv_grad_extend_t extend);
/**
* Helper function to initialize radial gradient
* @param dsc gradient descriptor
* @param center_x center x position: can be a coordinate or an lv_pct() value
* predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well
* @param center_y center y position
* @param to_x point on the end circle x position
* @param to_y point on the end circle y position
* @param extend one of LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT or LV_GRAD_EXTEND_REFLECT
*/
void lv_grad_radial_init(lv_grad_dsc_t * dsc, int32_t center_x, int32_t center_y, int32_t to_x, int32_t to_y,
lv_grad_extend_t extend);
/**
* Set focal (starting) circle of a radial gradient
* @param dsc gradient descriptor
* @param center_x center x position: can be a coordinate or an lv_pct() value
* predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well
* @param center_y center y position
* @param radius radius of the starting circle (NOTE: this must be a scalar number, not percentage)
*/
void lv_grad_radial_set_focal(lv_grad_dsc_t * dsc, int32_t center_x, int32_t center_y, int32_t radius);
/**
* Helper function to initialize conical gradient
* @param dsc gradient descriptor
* @param center_x center x position: can be a coordinate or an lv_pct() value
* predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well
* @param center_y center y position
* @param start_angle start angle in degrees
* @param end_angle end angle in degrees
* @param extend one of LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT or LV_GRAD_EXTEND_REFLECT
*/
void lv_grad_conical_init(lv_grad_dsc_t * dsc, int32_t center_x, int32_t center_y, int32_t start_angle,
int32_t end_angle, lv_grad_extend_t extend);
/**
* Calculate constants from the given parameters that are used during rendering
* @param dsc gradient descriptor
*/
void lv_gradient_linear_setup(lv_grad_dsc_t * dsc, const lv_area_t * coords);
/**
* Free up the allocated memory for the gradient calculation
* @param dsc gradient descriptor
*/
void lv_gradient_linear_cleanup(lv_grad_dsc_t * dsc);
/**
* Calculate a line segment of a linear gradient
* @param dsc gradient descriptor
* @param xp starting point x coordinate in gradient space
* @param yp starting point y coordinate in gradient space
* @param width width of the line segment in pixels
* @param result color buffer for the resulting line segment
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_gradient_linear_get_line(lv_grad_dsc_t * dsc, int32_t xp, int32_t yp, int32_t width,
lv_grad_t * result);
/**
* Calculate constants from the given parameters that are used during rendering
* @param dsc gradient descriptor
*/
void lv_gradient_radial_setup(lv_grad_dsc_t * dsc, const lv_area_t * coords);
/**
* Free up the allocated memory for the gradient calculation
* @param dsc gradient descriptor
*/
void lv_gradient_radial_cleanup(lv_grad_dsc_t * dsc);
/**
* Calculate a line segment of a radial gradient
* @param dsc gradient descriptor
* @param xp starting point x coordinate in gradient space
* @param yp starting point y coordinate in gradient space
* @param width width of the line segment in pixels
* @param result color buffer for the resulting line segment
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_gradient_radial_get_line(lv_grad_dsc_t * dsc, int32_t xp, int32_t yp, int32_t width,
lv_grad_t * result);
/**
* Calculate constants from the given parameters that are used during rendering
* @param dsc gradient descriptor
*/
void lv_gradient_conical_setup(lv_grad_dsc_t * dsc, const lv_area_t * coords);
/**
* Free up the allocated memory for the gradient calculation
* @param dsc gradient descriptor
*/
void lv_gradient_conical_cleanup(lv_grad_dsc_t * dsc);
/**
* Calculate a line segment of a conical gradient
* @param dsc gradient descriptor
* @param xp starting point x coordinate in gradient space
* @param yp starting point y coordinate in gradient space
* @param width width of the line segment in pixels
* @param result color buffer for the resulting line segment
*/
void /* LV_ATTRIBUTE_FAST_MEM */ lv_gradient_conical_get_line(lv_grad_dsc_t * dsc, int32_t xp, int32_t yp,
int32_t width,
lv_grad_t * result);
#endif /*LV_USE_DRAW_SW_COMPLEX_GRADIENTS*/
#endif /*LV_USE_DRAW_SW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_GRADIENT_H*/
@@ -0,0 +1,50 @@
/**
* @file lv_draw_sw_gradient_private.h
*
*/
#ifndef LV_DRAW_SW_GRADIENT_PRIVATE_H
#define LV_DRAW_SW_GRADIENT_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_sw_gradient.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_grad_t {
lv_color_t * color_map;
lv_opa_t * opa_map;
uint32_t size;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /* LV_USE_DRAW_SW */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_GRADIENT_PRIVATE_H*/
+185
View File
@@ -0,0 +1,185 @@
/**
* @file lv_draw_sw_mask.h
*
*/
#ifndef LV_DRAW_SW_MASK_H
#define LV_DRAW_SW_MASK_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../misc/lv_area.h"
#include "../../misc/lv_color.h"
#include "../../misc/lv_math.h"
#include "../../misc/lv_types.h"
/*********************
* DEFINES
*********************/
#define LV_MASK_ID_INV (-1)
#if LV_DRAW_SW_COMPLEX
# define LV_MASK_MAX_NUM 16
#else
# define LV_MASK_MAX_NUM 1
#endif
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_DRAW_SW_MASK_RES_TRANSP,
LV_DRAW_SW_MASK_RES_FULL_COVER,
LV_DRAW_SW_MASK_RES_CHANGED,
LV_DRAW_SW_MASK_RES_UNKNOWN
} lv_draw_sw_mask_res_t;
#if LV_DRAW_SW_COMPLEX
typedef enum {
LV_DRAW_SW_MASK_TYPE_LINE,
LV_DRAW_SW_MASK_TYPE_ANGLE,
LV_DRAW_SW_MASK_TYPE_RADIUS,
LV_DRAW_SW_MASK_TYPE_FADE,
LV_DRAW_SW_MASK_TYPE_MAP,
} lv_draw_sw_mask_type_t;
typedef enum {
LV_DRAW_SW_MASK_LINE_SIDE_LEFT = 0,
LV_DRAW_SW_MASK_LINE_SIDE_RIGHT,
LV_DRAW_SW_MASK_LINE_SIDE_TOP,
LV_DRAW_SW_MASK_LINE_SIDE_BOTTOM,
} lv_draw_sw_mask_line_side_t;
/**
* A common callback type for every mask type.
* Used internally by the library.
*/
typedef lv_draw_sw_mask_res_t (*lv_draw_sw_mask_xcb_t)(lv_opa_t * mask_buf, int32_t abs_x, int32_t abs_y,
int32_t len,
void * p);
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_sw_mask_init(void);
void lv_draw_sw_mask_deinit(void);
//! @cond Doxygen_Suppress
/**
* Apply the added buffers on a line. Used internally by the library's drawing routines.
* @param masks the masks list to apply, must be ended with NULL pointer in array.
* @param mask_buf store the result mask here. Has to be `len` byte long. Should be initialized with `0xFF`.
* @param abs_x absolute X coordinate where the line to calculate start
* @param abs_y absolute Y coordinate where the line to calculate start
* @param len length of the line to calculate (in pixel count)
* @return One of these values:
* - `LV_DRAW_MASK_RES_FULL_TRANSP`: the whole line is transparent. `mask_buf` is not set to zero
* - `LV_DRAW_MASK_RES_FULL_COVER`: the whole line is fully visible. `mask_buf` is unchanged
* - `LV_DRAW_MASK_RES_CHANGED`: `mask_buf` has changed, it shows the desired opacity of each pixel in the given line
*/
lv_draw_sw_mask_res_t /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_mask_apply(void * masks[], lv_opa_t * mask_buf,
int32_t abs_x,
int32_t abs_y,
int32_t len);
//! @endcond
/**
* Free the data from the parameter.
* It's called inside `lv_draw_sw_mask_remove_id` and `lv_draw_sw_mask_remove_custom`
* Needs to be called only in special cases when the mask is not added by `lv_draw_mask_add`
* and not removed by `lv_draw_mask_remove_id` or `lv_draw_mask_remove_custom`
* @param p pointer to a mask parameter
*/
void lv_draw_sw_mask_free_param(void * p);
/**
*Initialize a line mask from two points.
* @param param pointer to a `lv_draw_mask_param_t` to initialize
* @param p1x X coordinate of the first point of the line
* @param p1y Y coordinate of the first point of the line
* @param p2x X coordinate of the second point of the line
* @param p2y y coordinate of the second point of the line
* @param side and element of `lv_draw_mask_line_side_t` to describe which side to keep.
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
*/
void lv_draw_sw_mask_line_points_init(lv_draw_sw_mask_line_param_t * param, int32_t p1x, int32_t p1y,
int32_t p2x,
int32_t p2y, lv_draw_sw_mask_line_side_t side);
/**
*Initialize a line mask from a point and an angle.
* @param param pointer to a `lv_draw_mask_param_t` to initialize
* @param px X coordinate of a point of the line
* @param py X coordinate of a point of the line
* @param angle right 0 deg, bottom: 90
* @param side an element of `lv_draw_mask_line_side_t` to describe which side to keep.
* With `LV_DRAW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
* With `LV_DRAW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
*/
void lv_draw_sw_mask_line_angle_init(lv_draw_sw_mask_line_param_t * param, int32_t px, int32_t py, int16_t angle,
lv_draw_sw_mask_line_side_t side);
/**
* Initialize an angle mask.
* @param param pointer to a `lv_draw_mask_param_t` to initialize
* @param vertex_x X coordinate of the angle vertex (absolute coordinates)
* @param vertex_y Y coordinate of the angle vertex (absolute coordinates)
* @param start_angle start angle in degrees. 0 deg on the right, 90 deg, on the bottom
* @param end_angle end angle
*/
void lv_draw_sw_mask_angle_init(lv_draw_sw_mask_angle_param_t * param, int32_t vertex_x, int32_t vertex_y,
int32_t start_angle, int32_t end_angle);
/**
* Initialize a fade mask.
* @param param pointer to an `lv_draw_mask_radius_param_t` to initialize
* @param rect coordinates of the rectangle to affect (absolute coordinates)
* @param radius radius of the rectangle
* @param inv true: keep the pixels inside the rectangle; keep the pixels outside of the rectangle
*/
void lv_draw_sw_mask_radius_init(lv_draw_sw_mask_radius_param_t * param, const lv_area_t * rect, int32_t radius,
bool inv);
/**
* Initialize a fade mask.
* @param param pointer to a `lv_draw_mask_param_t` to initialize
* @param coords coordinates of the area to affect (absolute coordinates)
* @param opa_top opacity on the top
* @param y_top at which coordinate start to change to opacity to `opa_bottom`
* @param opa_bottom opacity at the bottom
* @param y_bottom at which coordinate reach `opa_bottom`.
*/
void lv_draw_sw_mask_fade_init(lv_draw_sw_mask_fade_param_t * param, const lv_area_t * coords, lv_opa_t opa_top,
int32_t y_top,
lv_opa_t opa_bottom, int32_t y_bottom);
/**
* Initialize a map mask.
* @param param pointer to a `lv_draw_mask_param_t` to initialize
* @param coords coordinates of the map (absolute coordinates)
* @param map array of bytes with the mask values
*/
void lv_draw_sw_mask_map_init(lv_draw_sw_mask_map_param_t * param, const lv_area_t * coords, const lv_opa_t * map);
#endif /*LV_DRAW_SW_COMPLEX*/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_MASK_H*/
@@ -0,0 +1,157 @@
/**
* @file lv_draw_sw_mask_private.h
*
*/
#ifndef LV_DRAW_SW_MASK_PRIVATE_H
#define LV_DRAW_SW_MASK_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_sw_mask.h"
#if LV_DRAW_SW_COMPLEX
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
uint8_t * buf;
lv_opa_t * cir_opa; /**< Opacity of values on the circumference of an 1/4 circle */
uint16_t * x_start_on_y; /**< The x coordinate of the circle for each y value */
uint16_t * opa_start_on_y; /**< The index of `cir_opa` for each y value */
int32_t life; /**< How many times the entry way used */
uint32_t used_cnt; /**< Like a semaphore to count the referencing masks */
int32_t radius; /**< The radius of the entry */
} lv_draw_sw_mask_radius_circle_dsc_t;
struct _lv_draw_sw_mask_common_dsc_t {
lv_draw_sw_mask_xcb_t cb;
lv_draw_sw_mask_type_t type;
};
struct _lv_draw_sw_mask_line_param_t {
/** The first element must be the common descriptor */
lv_draw_sw_mask_common_dsc_t dsc;
struct {
/*First point*/
lv_point_t p1;
/*Second point*/
lv_point_t p2;
/*Which side to keep?*/
lv_draw_sw_mask_line_side_t side : 2;
} cfg;
/** A point of the line */
lv_point_t origo;
/** X / (1024*Y) steepness (X is 0..1023 range). What is the change of X in 1024 Y? */
int32_t xy_steep;
/** Y / (1024*X) steepness (Y is 0..1023 range). What is the change of Y in 1024 X? */
int32_t yx_steep;
/** Helper which stores yx_steep for flat lines and xy_steep for steep (non flat) lines */
int32_t steep;
/** Steepness in 1 px in 0..255 range. Used only by flat lines. */
int32_t spx;
/** 1: It's a flat line? (Near to horizontal) */
uint8_t flat : 1;
/** Invert the mask. The default is: Keep the left part.
*It is used to select left/right/top/bottom */
uint8_t inv: 1;
};
struct _lv_draw_sw_mask_angle_param_t {
/** The first element must be the common descriptor */
lv_draw_sw_mask_common_dsc_t dsc;
struct {
lv_point_t vertex_p;
int32_t start_angle;
int32_t end_angle;
} cfg;
lv_draw_sw_mask_line_param_t start_line;
lv_draw_sw_mask_line_param_t end_line;
uint16_t delta_deg;
};
struct _lv_draw_sw_mask_radius_param_t {
/** The first element must be the common descriptor */
lv_draw_sw_mask_common_dsc_t dsc;
struct {
lv_area_t rect;
int32_t radius;
/** Invert the mask. 0: Keep the pixels inside. */
uint8_t outer: 1;
} cfg;
lv_draw_sw_mask_radius_circle_dsc_t * circle;
};
struct _lv_draw_sw_mask_fade_param_t {
/** The first element must be the common descriptor */
lv_draw_sw_mask_common_dsc_t dsc;
struct {
lv_area_t coords;
int32_t y_top;
int32_t y_bottom;
lv_opa_t opa_top;
lv_opa_t opa_bottom;
} cfg;
};
struct _lv_draw_sw_mask_map_param_t {
/** The first element must be the common descriptor */
lv_draw_sw_mask_common_dsc_t dsc;
struct {
lv_area_t coords;
const lv_opa_t * map;
} cfg;
};
typedef lv_draw_sw_mask_radius_circle_dsc_t lv_draw_sw_mask_radius_circle_dsc_arr_t[LV_DRAW_SW_CIRCLE_CACHE_SIZE];
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Called by LVGL the rendering of a screen is ready to clean up
* the temporal (cache) data of the masks
*/
void lv_draw_sw_mask_cleanup(void);
/**********************
* MACROS
**********************/
#endif /*LV_DRAW_SW_COMPLEX*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_MASK_PRIVATE_H*/
@@ -0,0 +1,68 @@
/**
* @file lv_draw_sw_private.h
*
*/
#ifndef LV_DRAW_SW_PRIVATE_H
#define LV_DRAW_SW_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw_sw.h"
#include "../lv_draw_private.h"
#if LV_USE_DRAW_SW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_sw_unit_t {
lv_draw_unit_t base_unit;
lv_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
uint32_t idx;
};
#if LV_DRAW_SW_SHADOW_CACHE_SIZE
typedef struct {
uint8_t cache[LV_DRAW_SW_SHADOW_CACHE_SIZE * LV_DRAW_SW_SHADOW_CACHE_SIZE];
int32_t cache_size;
int32_t cache_r;
} lv_draw_sw_shadow_cache_t;
#endif
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /* LV_USE_DRAW_SW */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_PRIVATE_H*/
@@ -0,0 +1,90 @@
/**
* @file lv_draw_vg_lite.h
*
*/
#ifndef LV_DRAW_VG_LITE_H
#define LV_DRAW_VG_LITE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_DRAW_VG_LITE
#include "../lv_draw.h"
#include "../../draw/lv_draw_vector.h"
#include "../../draw/lv_draw_arc.h"
#include "../../draw/lv_draw_rect.h"
#include "../../draw/lv_draw_image.h"
#include "../../draw/lv_draw_label.h"
#include "../../draw/lv_draw_line.h"
#include "../../draw/lv_draw_triangle.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_buf_vg_lite_init_handlers(void);
void lv_draw_vg_lite_init(void);
void lv_draw_vg_lite_deinit(void);
void lv_draw_vg_lite_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vg_lite_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vg_lite_border(lv_draw_unit_t * draw_unit, const lv_draw_border_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vg_lite_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vg_lite_img(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * dsc,
const lv_area_t * coords, bool no_cache);
void lv_draw_vg_lite_label(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc,
const lv_area_t * coords);
void lv_draw_vg_lite_layer(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
const lv_area_t * coords);
void lv_draw_vg_lite_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc);
void lv_draw_vg_lite_triangle(lv_draw_unit_t * draw_unit, const lv_draw_triangle_dsc_t * dsc);
void lv_draw_vg_lite_mask_rect(lv_draw_unit_t * draw_unit, const lv_draw_mask_rect_dsc_t * dsc,
const lv_area_t * coords);
#if LV_USE_VECTOR_GRAPHIC
void lv_draw_vg_lite_vector(lv_draw_unit_t * draw_unit, const lv_draw_vector_task_dsc_t * dsc);
#endif
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_VG_LITE_H*/
@@ -0,0 +1,73 @@
/**
* @file lv_draw_vg_lite_type.h
*
*/
#ifndef LV_DRAW_VG_LITE_TYPE_H
#define LV_DRAW_VG_LITE_TYPE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_DRAW_VG_LITE
#include "../lv_draw_private.h"
#include "../../misc/lv_array.h"
#if LV_USE_VG_LITE_THORVG
#include "../../others/vg_lite_tvg/vg_lite.h"
#else
#include <vg_lite.h>
#endif
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_vg_lite_pending_t;
struct _lv_draw_vg_lite_unit_t {
lv_draw_unit_t base_unit;
lv_draw_task_t * task_act;
struct _lv_vg_lite_pending_t * image_dsc_pending;
lv_cache_t * grad_cache;
struct _lv_vg_lite_pending_t * grad_pending;
lv_cache_t * stroke_cache;
uint16_t flush_count;
uint16_t letter_count;
vg_lite_buffer_t target_buffer;
vg_lite_matrix_t global_matrix;
struct _lv_vg_lite_path_t * global_path;
bool path_in_use;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DRAW_VG_LITE_TYPE_H*/
@@ -0,0 +1,47 @@
/**
* @file lv_vg_lite_decoder.h
*
*/
#ifndef LV_VG_LITE_DECODER_H
#define LV_VG_LITE_DECODER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_image_decoder.h"
#if LV_USE_DRAW_VG_LITE
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_vg_lite_decoder_init(void);
void lv_vg_lite_decoder_deinit(void);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_VG_LITE_DECODER_H*/
@@ -0,0 +1,69 @@
/**
* @file lv_vg_lite_grad.h
*
*/
#ifndef LV_VG_LITE_GRAD_H
#define LV_VG_LITE_GRAD_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lvgl.h"
#if LV_USE_DRAW_VG_LITE && LV_USE_VECTOR_GRAPHIC
#include "lv_vg_lite_utils.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_vg_lite_grad_init(struct _lv_draw_vg_lite_unit_t * u, uint32_t cache_cnt);
void lv_vg_lite_grad_deinit(struct _lv_draw_vg_lite_unit_t * u);
bool lv_vg_lite_draw_grad(
struct _lv_draw_vg_lite_unit_t * u,
vg_lite_buffer_t * buffer,
vg_lite_path_t * path,
const lv_vector_gradient_t * grad,
const vg_lite_matrix_t * grad_matrix,
const vg_lite_matrix_t * matrix,
vg_lite_fill_t fill,
vg_lite_blend_t blend);
bool lv_vg_lite_draw_grad_helper(
struct _lv_draw_vg_lite_unit_t * u,
vg_lite_buffer_t * buffer,
vg_lite_path_t * path,
const lv_area_t * area,
const lv_grad_dsc_t * grad_dsc,
const vg_lite_matrix_t * matrix,
vg_lite_fill_t fill,
vg_lite_blend_t blend);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE && LV_USE_VECTOR_GRAPHIC*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_VG_LITE_GRAD_H*/
@@ -0,0 +1,76 @@
/**
* @file lv_vg_lite_math.h
*
*/
#ifndef LV_VG_LITE_MATH_H
#define LV_VG_LITE_MATH_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_DRAW_VG_LITE
#include <math.h>
#include <stdbool.h>
#include <float.h>
/*********************
* DEFINES
*********************/
#define MATH_PI 3.14159265358979323846f
#define MATH_HALF_PI 1.57079632679489661923f
#define MATH_TWO_PI 6.28318530717958647692f
#define DEG_TO_RAD 0.017453292519943295769236907684886f
#define RAD_TO_DEG 57.295779513082320876798154814105f
#define MATH_TANF(x) tanf(x)
#define MATH_SINF(x) sinf(x)
#define MATH_COSF(x) cosf(x)
#define MATH_ASINF(x) asinf(x)
#define MATH_ACOSF(x) acosf(x)
#define MATH_FABSF(x) fabsf(x)
#define MATH_SQRTF(x) sqrtf(x)
#define MATH_RADIANS(deg) ((deg) * DEG_TO_RAD)
#define MATH_DEGREES(rad) ((rad) * RAD_TO_DEG)
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
static inline bool math_zero(float a)
{
return (MATH_FABSF(a) < FLT_EPSILON);
}
static inline bool math_equal(float a, float b)
{
return math_zero(a - b);
}
float math_fast_inv_sqrtf(float number);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_VG_LITE_MATH_H*/
@@ -0,0 +1,128 @@
/**
* @file lv_vg_lite_path.h
*
*/
#ifndef LV_VG_LITE_PATH_H
#define LV_VG_LITE_PATH_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_vg_lite_utils.h"
#if LV_USE_DRAW_VG_LITE
/*********************
* DEFINES
*********************/
typedef struct _lv_vg_lite_path_t lv_vg_lite_path_t;
typedef struct _lv_draw_vg_lite_unit_t lv_draw_vg_lite_unit_t;
typedef void (*lv_vg_lite_path_iter_cb_t)(void * user_data, uint8_t op_code, const float * data, uint32_t len);
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_vg_lite_path_init(lv_draw_vg_lite_unit_t * unit);
void lv_vg_lite_path_deinit(lv_draw_vg_lite_unit_t * unit);
lv_vg_lite_path_t * lv_vg_lite_path_create(vg_lite_format_t data_format);
void lv_vg_lite_path_destroy(lv_vg_lite_path_t * path);
lv_vg_lite_path_t * lv_vg_lite_path_get(lv_draw_vg_lite_unit_t * unit, vg_lite_format_t data_format);
void lv_vg_lite_path_drop(lv_draw_vg_lite_unit_t * unit, lv_vg_lite_path_t * path);
void lv_vg_lite_path_reset(lv_vg_lite_path_t * path, vg_lite_format_t data_format);
void lv_vg_lite_path_set_bonding_box_area(lv_vg_lite_path_t * path, const lv_area_t * area);
void lv_vg_lite_path_set_bonding_box(lv_vg_lite_path_t * path,
float min_x, float min_y,
float max_x, float max_y);
void lv_vg_lite_path_get_bonding_box(lv_vg_lite_path_t * path,
float * min_x, float * min_y,
float * max_x, float * max_y);
bool lv_vg_lite_path_update_bonding_box(lv_vg_lite_path_t * path);
void lv_vg_lite_path_set_transform(lv_vg_lite_path_t * path, const vg_lite_matrix_t * matrix);
void lv_vg_lite_path_set_quality(lv_vg_lite_path_t * path, vg_lite_quality_t quality);
vg_lite_path_t * lv_vg_lite_path_get_path(lv_vg_lite_path_t * path);
void lv_vg_lite_path_move_to(lv_vg_lite_path_t * path,
float x, float y);
void lv_vg_lite_path_line_to(lv_vg_lite_path_t * path,
float x, float y);
void lv_vg_lite_path_quad_to(lv_vg_lite_path_t * path,
float cx, float cy,
float x, float y);
void lv_vg_lite_path_cubic_to(lv_vg_lite_path_t * path,
float cx1, float cy1,
float cx2, float cy2,
float x, float y);
void lv_vg_lite_path_close(lv_vg_lite_path_t * path);
void lv_vg_lite_path_end(lv_vg_lite_path_t * path);
void lv_vg_lite_path_append_rect(lv_vg_lite_path_t * path,
float x, float y,
float w, float h,
float r);
void lv_vg_lite_path_append_circle(lv_vg_lite_path_t * path,
float cx, float cy,
float rx, float ry);
void lv_vg_lite_path_append_arc_right_angle(lv_vg_lite_path_t * path,
float start_x, float start_y,
float center_x, float center_y,
float end_x, float end_y);
void lv_vg_lite_path_append_arc(lv_vg_lite_path_t * path,
float cx, float cy,
float radius,
float start_angle,
float sweep,
bool pie);
void lv_vg_lite_path_append_path(lv_vg_lite_path_t * dest, const lv_vg_lite_path_t * src);
uint8_t lv_vg_lite_vlc_op_arg_len(uint8_t vlc_op);
uint8_t lv_vg_lite_path_format_len(vg_lite_format_t format);
void lv_vg_lite_path_for_each_data(const vg_lite_path_t * path, lv_vg_lite_path_iter_cb_t cb, void * user_data);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_VG_LITE_PATH_H*/
@@ -0,0 +1,83 @@
/**
* @file lv_vg_lite_pending.h
*
*/
#ifndef LV_VG_LITE_PENDING_H
#define LV_VG_LITE_PENDING_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lvgl.h"
#if LV_USE_DRAW_VG_LITE
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct _lv_vg_lite_pending_t lv_vg_lite_pending_t;
typedef void (*lv_vg_lite_pending_free_cb_t)(void * obj, void * user_data);
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a pending list
* @param obj_size the size of the objects in the list
* @param capacity_default the default capacity of the list
* @return a pointer to the pending list
*/
lv_vg_lite_pending_t * lv_vg_lite_pending_create(size_t obj_size, uint32_t capacity_default);
/**
* Destroy a pending list
* @param pending pointer to the pending list
*/
void lv_vg_lite_pending_destroy(lv_vg_lite_pending_t * pending);
/**
* Set a free callback for the pending list
* @param pending pointer to the pending list
* @param free_cb the free callback
* @param user_data user data to pass to the free callback
*/
void lv_vg_lite_pending_set_free_cb(lv_vg_lite_pending_t * pending, lv_vg_lite_pending_free_cb_t free_cb,
void * user_data);
/**
* Add an object to the pending list
* @param pending pointer to the pending list
* @param obj pointer to the object to add
*/
void lv_vg_lite_pending_add(lv_vg_lite_pending_t * pending, void * obj);
/**
* Remove all objects from the pending list
* @param pending pointer to the pending list
*/
void lv_vg_lite_pending_remove_all(lv_vg_lite_pending_t * pending);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_VG_LITE_PENDING_H*/
@@ -0,0 +1,84 @@
/**
* @file lv_vg_lite_stroke.h
*
*/
#ifndef LV_VG_LITE_STROKE_H
#define LV_VG_LITE_STROKE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_vg_lite_utils.h"
#if LV_USE_DRAW_VG_LITE && LV_USE_VECTOR_GRAPHIC
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_vg_lite_path_t;
struct _lv_draw_vg_lite_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the stroke module
* @param unit pointer to the unit
*/
void lv_vg_lite_stroke_init(struct _lv_draw_vg_lite_unit_t * unit, uint32_t cache_cnt);
/**
* Deinitialize the stroke module
* @param unit pointer to the unit
*/
void lv_vg_lite_stroke_deinit(struct _lv_draw_vg_lite_unit_t * unit);
/**
* Get the stroke cache entry
* @param unit pointer to the unit
* @param path pointer to the path
* @param dsc pointer to the stroke descriptor
* @return pointer to the stroke cache entry
*/
lv_cache_entry_t * lv_vg_lite_stroke_get(struct _lv_draw_vg_lite_unit_t * unit,
struct _lv_vg_lite_path_t * path,
const lv_vector_stroke_dsc_t * dsc);
/**
* Get the path of a stroke
* @param cache_entry pointer to the stroke cache entry
* @return pointer to the path
*/
struct _lv_vg_lite_path_t * lv_vg_lite_stroke_get_path(lv_cache_entry_t * cache_entry);
/**
* Drop the stroke cache entry
* @param unit pointer to the unit
* @param stroke pointer to the stroke
*/
void lv_vg_lite_stroke_drop(struct _lv_draw_vg_lite_unit_t * unit, lv_cache_entry_t * cache_entry);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE && LV_USE_VECTOR_GRAPHIC*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_VG_LITE_STROKE_H*/
@@ -0,0 +1,188 @@
/**
* @file lv_vg_lite_utils.h
*
*/
#ifndef LV_VG_LITE_UTILS_H
#define LV_VG_LITE_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lvgl.h"
#if LV_USE_DRAW_VG_LITE
#include "../../misc/lv_profiler.h"
#include <stdbool.h>
#if LV_USE_VG_LITE_THORVG
#include "../../others/vg_lite_tvg/vg_lite.h"
#else
#include <vg_lite.h>
#endif
/*********************
* DEFINES
*********************/
#define LV_VG_LITE_IS_ERROR(err) (err > 0)
#define VLC_GET_OP_CODE(ptr) (*((uint8_t*)ptr))
#if LV_VG_LITE_USE_ASSERT
#define LV_VG_LITE_ASSERT(expr) LV_ASSERT(expr)
#else
#define LV_VG_LITE_ASSERT(expr)
#endif
#define LV_VG_LITE_CHECK_ERROR(expr) \
do { \
vg_lite_error_t error = expr; \
if (LV_VG_LITE_IS_ERROR(error)) { \
LV_LOG_ERROR("Execute '" #expr "' error(%d): %s", \
(int)error, lv_vg_lite_error_string(error)); \
LV_VG_LITE_ASSERT(false); \
} \
} while (0)
#define LV_VG_LITE_ASSERT_PATH(path) LV_VG_LITE_ASSERT(lv_vg_lite_path_check(path))
#define LV_VG_LITE_ASSERT_SRC_BUFFER(buffer) LV_VG_LITE_ASSERT(lv_vg_lite_buffer_check(buffer, true))
#define LV_VG_LITE_ASSERT_DEST_BUFFER(buffer) LV_VG_LITE_ASSERT(lv_vg_lite_buffer_check(buffer, false))
#define LV_VG_LITE_ASSERT_MATRIX(matrix) LV_VG_LITE_ASSERT(lv_vg_lite_matrix_check(matrix))
#define LV_VG_LITE_ALIGN(number, align_bytes) \
(((number) + ((align_bytes)-1)) & ~((align_bytes)-1))
#define LV_VG_LITE_IS_ALIGNED(num, align) (((uintptr_t)(num) & ((align)-1)) == 0)
#define LV_VG_LITE_IS_INDEX_FMT(fmt) \
((fmt) == VG_LITE_INDEX_1 \
|| (fmt) == VG_LITE_INDEX_2 \
|| (fmt) == VG_LITE_INDEX_4 \
|| (fmt) == VG_LITE_INDEX_8)
/**********************
* TYPEDEFS
**********************/
struct _lv_draw_vg_lite_unit_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/* Print info */
void lv_vg_lite_dump_info(void);
const char * lv_vg_lite_error_string(vg_lite_error_t error);
const char * lv_vg_lite_feature_string(vg_lite_feature_t feature);
const char * lv_vg_lite_buffer_format_string(vg_lite_buffer_format_t format);
const char * lv_vg_lite_vlc_op_string(uint8_t vlc_op);
void lv_vg_lite_path_dump_info(const vg_lite_path_t * path);
void lv_vg_lite_stroke_dump_info(const vg_lite_stroke_t * stroke);
void lv_vg_lite_buffer_dump_info(const vg_lite_buffer_t * buffer);
void lv_vg_lite_matrix_dump_info(const vg_lite_matrix_t * matrix);
bool lv_vg_lite_is_dest_cf_supported(lv_color_format_t cf);
bool lv_vg_lite_is_src_cf_supported(lv_color_format_t cf);
/* Converter */
vg_lite_buffer_format_t lv_vg_lite_vg_fmt(lv_color_format_t cf);
void lv_vg_lite_buffer_format_bytes(
vg_lite_buffer_format_t format,
uint32_t * mul,
uint32_t * div,
uint32_t * bytes_align);
uint32_t lv_vg_lite_width_to_stride(uint32_t w, vg_lite_buffer_format_t color_format);
uint32_t lv_vg_lite_width_align(uint32_t w);
void lv_vg_lite_buffer_init(
vg_lite_buffer_t * buffer,
const void * ptr,
int32_t width,
int32_t height,
uint32_t stride,
vg_lite_buffer_format_t format,
bool tiled);
void lv_vg_lite_buffer_from_draw_buf(vg_lite_buffer_t * buffer, const lv_draw_buf_t * draw_buf);
void lv_vg_lite_image_matrix(vg_lite_matrix_t * matrix, int32_t x, int32_t y, const lv_draw_image_dsc_t * dsc);
void lv_vg_lite_image_dec_init(vg_lite_matrix_t * matrix, int32_t x, int32_t y, const lv_draw_image_dsc_t * dsc);
bool lv_vg_lite_buffer_open_image(vg_lite_buffer_t * buffer, lv_image_decoder_dsc_t * decoder_dsc, const void * src,
bool no_cache, bool premultiply);
void lv_vg_lite_image_dsc_init(struct _lv_draw_vg_lite_unit_t * unit);
void lv_vg_lite_image_dsc_deinit(struct _lv_draw_vg_lite_unit_t * unit);
vg_lite_blend_t lv_vg_lite_blend_mode(lv_blend_mode_t blend_mode, bool has_pre_mul);
uint32_t lv_vg_lite_get_palette_size(vg_lite_buffer_format_t format);
vg_lite_color_t lv_vg_lite_color(lv_color_t color, lv_opa_t opa, bool pre_mul);
void lv_vg_lite_rect(vg_lite_rectangle_t * rect, const lv_area_t * area);
void lv_vg_lite_matrix(vg_lite_matrix_t * dest, const lv_matrix_t * src);
/* Param checker */
bool lv_vg_lite_buffer_check(const vg_lite_buffer_t * buffer, bool is_src);
bool lv_vg_lite_path_check(const vg_lite_path_t * path);
bool lv_vg_lite_matrix_check(const vg_lite_matrix_t * matrix);
/* Wrapper */
bool lv_vg_lite_support_blend_normal(void);
bool lv_vg_lite_16px_align(void);
void lv_vg_lite_matrix_multiply(vg_lite_matrix_t * matrix, const vg_lite_matrix_t * mult);
bool lv_vg_lite_matrix_inverse(vg_lite_matrix_t * result, const vg_lite_matrix_t * matrix);
lv_point_precise_t lv_vg_lite_matrix_transform_point(const vg_lite_matrix_t * matrix, const lv_point_precise_t * point);
void lv_vg_lite_set_scissor_area(const lv_area_t * area);
void lv_vg_lite_disable_scissor(void);
void lv_vg_lite_flush(struct _lv_draw_vg_lite_unit_t * u);
void lv_vg_lite_finish(struct _lv_draw_vg_lite_unit_t * u);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DRAW_VG_LITE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*VG_LITE_UTILS_H*/