chore(NemaGFX): update library

This commit is contained in:
liamHowatt 2024-11-15 14:56:38 +01:00 committed by Neo Xu
parent 64920961cf
commit 7232ad74a0
33 changed files with 5033 additions and 4850 deletions

View File

@ -1 +1 @@
// Build Hash: f02602a9bc58957911babb1a647e6b0019983cb7
// Build Hash: 41847c80308e08cc83474b118b1bd53ab622cd7e

View File

@ -68,6 +68,7 @@ extern "C" {
#define NEMA_BLOP_NONE (0U) /**< No extra blending operation */
#define NEMA_BLOP_RECOLOR (0x00100000U) /**< Cconst*Aconst + Csrc*(1-Aconst). Overrides MODULATE_RGB. On NemaP GPU, recolor is available only when HW Rop Blender is enabled */
#define NEMA_BLOP_LUT (0x00200000U) /**< src_tex as index, src2_tex as palette */
#define NEMA_BLOP_STENCIL_XY (0x00400000U) /**< Use TEX3 as mask */
#define NEMA_BLOP_STENCIL_TXTY (0x00800000U) /**< Use TEX3 as mask */
@ -79,7 +80,7 @@ extern "C" {
#define NEMA_BLOP_MODULATE_RGB (0x20000000U) /**< Modulate by Constant Color (RGB) values */
#define NEMA_BLOP_SRC_CKEY (0x40000000U) /**< Apply Source Color Keying - draw only when src color doesn't match colorkey */
#define NEMA_BLOP_DST_CKEY (0x80000000U) /**< Apply Destination Color Keying - draw only when dst color matches colorkey */
#define NEMA_BLOP_MASK (0xffe00000U)
#define NEMA_BLOP_MASK (0xfff00000U)
/** \brief Return blending mode given source and destination blending factors and additional blending operations
*
@ -147,6 +148,15 @@ static inline void nema_set_blend_blit_compose(uint32_t blending_mode) {
*/
void nema_set_const_color(uint32_t rgba);
/** \brief Set recolor color. Overrides constant color
*
* \param rgba RGBA color
* \see nema_rgba(), nema_set_const_color()
*
*/
void nema_set_recolor_color(uint32_t rgba);
/** \brief Set source color key
*
* \param rgba RGBA color key

View File

@ -37,5 +37,6 @@
#include "nema_math.h"
#include "nema_matrix3x3.h"
#include "nema_matrix4x4.h"
#include "nema_version.h"
#endif

View File

@ -175,7 +175,7 @@ void nema_string_indexed_get_bbox(const int *ids, int id_count, int *w, int *h,
/** \brief Returns the horizontal advance (in pixels) of the bound font
*
*/
int nema_font_get_x_advance();
int nema_font_get_x_advance(void);
#ifdef __cplusplus
}

View File

@ -54,7 +54,8 @@ typedef enum {
NEMA_TEX0 = 0, /**< Texture 0 */
NEMA_TEX1 = 1, /**< Texture 1 */
NEMA_TEX2 = 2, /**< Texture 2 */
NEMA_TEX3 = 3 /**< Texture 3 */
NEMA_TEX3 = 3, /**< Texture 3 */
NEMA_TEXMAX = 4 /**< Enum max value */
} nema_tex_t;
#define NEMA_RGBX8888 0x00U /**< RGBX8888 */
@ -120,6 +121,7 @@ typedef enum {
#define NEMA_ABGR4444 0x4bU /**< ABGR4444 (Available if HW enabled - check HW manual) */
#define NEMA_TSC12 0x4cU /**< TSC12 (Available if HW enabled - check HW manual) */
#define NEMA_TSC12A 0x4dU /**< TSC12A (Available if HW enabled - check HW manual) */
#define NEMA_TSC6AP 0x4eU /**< TSC6AP (Available if HW enabled - check HW manual) */
#define NEMA_DITHER 0x80U /**< Nema Dithering */
#define NEMA_FORMAT_MASK 0x7FU /**< Format Mask */

View File

@ -269,7 +269,7 @@ int nema_f2fx(float f); // ((int)(((a)*((float)0x10000)+0.5f)))
* \return Remainder
*
*/
#define nema_fmod(x, y) (x - nema_truncf(x / y) * y)
#define nema_fmod(x, y) ( (x) - nema_truncf( ( (x) / (y) ) ) * (y) )
#ifdef __cplusplus
}

View File

@ -63,6 +63,9 @@ void nema_raster_triangle (int x0, int y0, int x1, int y1, int x2, int y2);
/** \private */
void nema_raster_quad (int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3);
/** \private */
void nema_raster_circle(float x, float y, float r);
/** \private */
void nema_raster_circle_aa(float x, float y, float r);
@ -100,6 +103,13 @@ nema_raster_quad_f(float x0, float y0, float x1, float y1,
void
nema_raster_stroked_arc_aa( float x0, float y0, float r, float w, float start_angle, float end_angle);
/** \private */
// aa_mask:
// RAST_AA_E0: AA on first ending
// RAST_AA_E2: AA on last ending
void
nema_raster_stroked_arc_aa_mask( float x0, float y0, float r, float w, float start_angle, float end_angle, uint32_t aa_mask);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,55 @@
/* TSI 2023.xmo */
/*******************************************************************************
* Copyright (c) 2023 Think Silicon Single Member PC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this header file and/or associated documentation files to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Materials, and to permit persons to whom the Materials are furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Materials.
*
* MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
* NEMAGFX API. THE UNMODIFIED, NORMATIVE VERSIONS OF THINK-SILICON NEMAGFX
* SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT:
* https://think-silicon.com/products/software/nemagfx-api
*
* 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
* Think Silicon Single Member PC 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
* @brief Contains version numbers for NemaGFX API and the currently supported font version.
*
*/
#ifndef NEMA_VERSION_H__
#define NEMA_VERSION_H__
#ifdef __cplusplus
extern "C" {
#endif
#define NEMA_MAJOR_VERSION 0x01U /**< NemaGFX API version, major number */
#define NEMA_MINOR_VERSION 0x04U /**< NemaGFX API version, minor number */
#define NEMA_REVISION_VERSION 0x0BU /**< NemaGFX API version, revision number */
#define NEMA_IMP_VERSION 0x00240600U /**< NemaGFX API version, implementation in format 0x00YYMM00 (Y: year, M: month) */
#define NEMA_API_VERSION ((NEMA_MAJOR_VERSION << 16) + (NEMA_MINOR_VERSION << 8) + (NEMA_REVISION_VERSION)) /**< NemaGFX API version in format 0x00MMmmrr (M:major, m:minor, r:revision if any) */
#define NEMA_FONT_VERSION 0x01U /**< Current font version */
#ifdef __cplusplus
}
#endif
#endif //NEMA_VERSION_H__

View File

@ -59,8 +59,8 @@ void nema_vg_init(int width, int height);
/** \brief Initializes NemaVG library and allocate the stencil buffer in a specific memory pool.
* Call either this or nema_vg_init to allocate the stencil buffer to the default memory pool (NEMA_MEM_POOL_FB)
* or nema_vg_init_stencil_prealloc to provide the stencil buffer
* \param width Framebuffer width
* \param height Framebuffer height
* \param width Stencil buffer width - Must be the first multiple of 4 of the framebuffer width
* \param height Stencil buffer height - Must be the first multiple of 4 of the framebuffer height
* \param pool Memory pool for allocating the stencil buffer (memory pools are platform specific and defined in nema_sys_defs.h file)
*/
void nema_vg_init_stencil_pool(int width, int height, int pool);
@ -68,8 +68,8 @@ void nema_vg_init_stencil_pool(int width, int height, int pool);
/** \brief Initializes NemaVG library without allocating the stencil buffer which is provided by the user.
* Call either this or nema_vg_init to allocate the stencil buffer to the default memory pool (NEMA_MEM_POOL_FB)
* or nema_vg_init_stencil_pool to allocate the stencil buffer to a different memory pool
* \param width Framebuffer width
* \param height Framebuffer height
* \param width Stencil buffer width - Must be the first multiple of 4 of the framebuffer width
* \param height Stencil buffer height - Must be the first multiple of 4 of the framebuffer height
* \param stencil_bo stencil buffer
*/
void nema_vg_init_stencil_prealloc(int width, int height, nema_buffer_t stencil_bo);
@ -78,14 +78,22 @@ void nema_vg_init_stencil_prealloc(int width, int height, nema_buffer_t stencil_
/** \brief Reinitialize NemaVG library after a gpu powerofff
*
*/
void nema_vg_reinit();
void nema_vg_reinit(void);
/** \brief Deinitialize NemaVG library. Free memory from implicitly allocated objects (stencil buffer
* if created inside the library, lut buffer and tsvgs' path, paint and gradient buffers)
*
*
*/
void nema_vg_deinit();
void nema_vg_deinit(void);
/** \brief Initialize NemaVG library for a new thread.
* Must be called for every new thread that is used.
*
*
*/
void nema_vg_thread_init(void);
// -------------------------------------------------------------------------------
// PATH DRAW
@ -201,6 +209,25 @@ uint32_t nema_vg_draw_circle(float cx, float cy, float r,
uint32_t nema_vg_draw_ring(float cx, float cy, float ring_radius, float angle_start, float angle_end,
NEMA_VG_PAINT_HANDLE paint);
/** \private
* \brief Draw a filled ring with flat ending or rounded ending caps. In case of a conical gradient paint type,
* the conical gradient center should be at the center of the ring(cx, cy). In other case, where the two centers do not match,
* the ring should be drawn with NEMA_VG_QUALITY_MAXIMUM. The ring width can be set with the paint's stroke_width.
*
* \param cx The center x coordinate of the ring
* \param cy The center y coordinate of the ring
* \param ring_radius The radius of the ring
* \param angle_start The angle in degrees of the ring
* \param angle_end The angle in degrees that ends this ring
* \param paint The paint to draw
* \param has_caps 1 For caps 0 for flat ending
* \return Error code. See NEMA_VG_ERR_* defines in "nema_vg_context.h" header file for the error codes.
*
*/
uint32_t nema_vg_draw_ring_generic(float cx, float cy, float ring_radius, float angle_start, float angle_end,
NEMA_VG_PAINT_HANDLE paint, uint8_t has_caps);
/** \brief Returns the minimum and maximum values for the coordinates that
* can be handled by the underlying hardware
@ -211,6 +238,15 @@ uint32_t nema_vg_draw_ring(float cx, float cy, float ring_radius, float angle_st
*/
void nema_vg_get_coord_limits(float *min_coord, float *max_coord);
/** \brief Disables tsvg features from rendering. Should be set before
* nema_vg_draw_tsvg()
*
* \param feature feature to be disabled
*
*/
void nema_vg_tsvg_disable_feature(uint32_t feature);
#ifdef __cplusplus
}
#endif

View File

@ -78,6 +78,9 @@ typedef float nema_vg_float_t; /**< Floating point data type (default is 'float'
#define NEMA_VG_ERR_NO_INIT (0x00100000U) /**< VG uninitialized */
#define NEMA_VG_ERR_INVALID_STROKE_WIDTH (0x00200000U) /**< Invalid stroke width */
#define NEMA_VG_ERR_INVALID_OPACITY (0x00400000U) /**< Invalid opacity */
#define NEMA_VG_ERR_INVALID_CAP_STYLE (0x00800000U) /**< Invalid cap style */
#define NEMA_VG_ERR_INVALID_JOIN_STYLE (0x01000000U) /**< Invalid join style */
#define NEMA_VG_ERR_INVALID_STENCIL_SIZE (0x02000000U) /**< Invalid stencil buffer size */
#define NEMA_VG_FILL_DRAW (0x00U) /**< DEPRECATED Stroke fill rule */
#define NEMA_VG_STROKE (0x00U) /**< Stroke fill rule */
@ -89,6 +92,19 @@ typedef float nema_vg_float_t; /**< Floating point data type (default is 'float'
#define NEMA_VG_QUALITY_MAXIMUM (0x02U) /**< Maximum rendering quality (favors rendering quality over performance)*/
#define NEMA_VG_QUALITY_NON_AA (0x10U) /**< Rendering quality without AA*/
#define NEMA_VG_CAP_BUTT (0x00U) /**< Butt cap*/
#define NEMA_VG_CAP_ROUND (0x01U) /**< Round cap*/
#define NEMA_VG_CAP_SQUARE (0x02U) /**< Square cap*/
#define NEMA_VG_CAP_MAX (0x03U) /**< Max value for cap*/
#define NEMA_VG_JOIN_BEVEL (0x00U) /**< Bevel join*/
#define NEMA_VG_JOIN_MITER (0x01U) /**< Mitter join*/
#define NEMA_VG_JOIN_ROUND (0x02U) /**< Round join*/
#define NEMA_VG_JOIN_MAX (0x03U) /**< Max for join*/
#define NEMA_VG_TSVG_DISABLE_NONE (0x00000000U) /**< Disable none*/
#define NEMA_VG_TSVG_DISABLE_CAPS (0x00000001U) /**< Disable caps*/
#define NEMA_VG_TSVG_DISABLE_JOINS (0x00000002U) /**< Disable joins*/
/** \brief Set the global transformation matrix. Global matrix will be applied in all NemaVG rendering operations that will follow.
*
@ -111,6 +127,36 @@ void nema_vg_reset_global_matrix(void);
*/
void nema_vg_set_fill_rule(uint8_t fill_rule);
/** \brief Set the stroke width that will be applied when stroking a path.
*
* \param width Stroke width to be set
*
*/
void nema_vg_stroke_set_width(float width);
/** \brief Set stroke cap style
*
* \param cap_style Cap style (NEMA_VG_CAP_BUTT | NEMA_VG_CAP_SQUARE | NEMA_VG_CAP_ROUND)
*
*/
void nema_vg_stroke_set_cap_style(uint8_t start_cap_style, uint8_t end_cap_style);
/** \brief Set stroke join style
*
* \param join_style Join style (NEMA_VG_JOIN_BEVEL | NEMA_VG_JOIN_MITER | NEMA_VG_JOIN_ROUND)
*
*/
void nema_vg_stroke_set_join_style(uint8_t join_style);
/** \brief Set stroke miter limit
* If miter join is chosen and miter length is bigger than the product
* of miter limit and stroke width a bevel join will be added instead
*
* \param miter_limit miter join limit to be set
*
*/
void nema_vg_stroke_set_miter_limit(float miter_limit);
/** \brief Enable/Disable Masking.
*
* \param masking 1 to enable, 0 to disable

View File

@ -40,6 +40,7 @@
#include "nema_matrix3x3.h"
#include "nema_vg.h"
#include "nema_vg_context.h"
#include "nema_font.h" //vector to raster conversion
#ifdef __cplusplus
extern "C" {
@ -156,7 +157,7 @@ int nema_vg_string_get_bbox(const char *str, float *w, float *h, float max_w, u
* \return Ascender pt
*
*/
int nema_vg_get_ascender_pt();
int nema_vg_get_ascender_pt(void);
/** \brief Print a single character
*
@ -178,6 +179,31 @@ int nema_vg_get_ascender_pt();
*/
float nema_vg_print_char(NEMA_VG_PAINT_HANDLE paint, char ch, float x, float y, nema_matrix3x3_t m, uint32_t orientation);
/** \brief Generates a raster font from a vector font
*
* \details Creates an 8-bpp raster version of the bound vector font. Performs dynamic memory allocation in
* the graphics memory (for the font bitmaps) and in the heap (for the data structs accessed by the CPU).
* When the font is no longer needed, function "nema_vg_destroy_raster_font()" can be used to free the allocated
* memory. The font generation may fail when there is not enough memory to generate the font or when the font
* size is greater than the height of the framebuffer.
*
* \param size The size of the font that will be generated
* \param pool Memory pool to store the font bitmaps
* \return Pointer to the data struct of generated raster font. If the font was not generated (due to insufficient memory) it returns NULL.
*
*/
nema_font_t* nema_vg_generate_raster_font(int size, int pool);
/** \brief Frees the memory that was allocated for a font data struct
*
* \details This function frees memory that was allocated at runtime. Input must be
* a font data struct that was generated by the "nema_vg_generate_raster_font" function.
*
* \param font Pointer to the raster font data struct that will be erased from the memory
*
*/
void nema_vg_destroy_raster_font(nema_font_t *font);
#ifdef __cplusplus
}
#endif

View File

@ -125,7 +125,7 @@ void nema_vg_paint_set_paint_color(NEMA_VG_PAINT_HANDLE paint, uint32_t rgba);
*/
void nema_vg_paint_set_opacity(NEMA_VG_PAINT_HANDLE paint, float opacity);
/** \brief Set stroke width
/** \brief Set stroke width - DEPRECATED USE nema_vg_stroke_set_width
*
* \param paint Pointer (handle) to paint object
* \param stroke_width Stroke width to be set

View File

@ -40,8 +40,8 @@ extern "C" {
#define NEMA_VG_MAJOR_VERSION 0x01U /**< NemaVG API version, major number */
#define NEMA_VG_MINOR_VERSION 0x01U /**< NemaVG API version, minor number */
#define NEMA_VG_REVISION_VERSION 0x05U /**< NemaVG API version, revision number */
#define NEMA_VG_IMP_VERSION 0x00231000U /**< NemaVG API version, implementation in format 0x00YYMM00 (Y: year, M: month) */
#define NEMA_VG_REVISION_VERSION 0x07U /**< NemaVG API version, revision number */
#define NEMA_VG_IMP_VERSION 0x00240600U /**< NemaVG API version, implementation in format 0x00YYMM00 (Y: year, M: month) */
#define NEMA_VG_API_VERSION ((NEMA_VG_MAJOR_VERSION << 16) + (NEMA_VG_MINOR_VERSION << 8) + (NEMA_VG_REVISION_VERSION)) /**< NemaVG API version in format 0x00MMmmrr (M:major, m:minor, r:revision if any) */

View File

@ -140,10 +140,7 @@ static int32_t nema_gfx_evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * ta
}
#if LV_USE_NEMA_VG
case LV_DRAW_TASK_TYPE_TRIANGLE:
case LV_DRAW_TASK_TYPE_ARC: {
lv_draw_arc_dsc_t * draw_arc_dsc = (lv_draw_arc_dsc_t *) task->draw_dsc;
if(draw_arc_dsc->rounded == 0) break;
}
case LV_DRAW_TASK_TYPE_ARC:
case LV_DRAW_TASK_TYPE_FILL: {
if(task->preference_score > 80) {
task->preference_score = 80;

View File

@ -93,8 +93,8 @@ void lv_draw_nema_gfx_arc(lv_draw_unit_t * draw_unit, const lv_draw_arc_dsc_t *
draw_nema_gfx_unit->paint);
}
else {
/* nema_vg_draw_ring_generic(center.x, center.y, (float)dsc->radius - (float)dsc->width * 0.5f, start_angle,
end_angle, draw_nema_gfx_unit->paint, 0U); */
nema_vg_draw_ring_generic(center.x, center.y, (float)dsc->radius - (float)dsc->width * 0.5f, start_angle,
end_angle, draw_nema_gfx_unit->paint, 0U);
}
nema_cl_submit(&(draw_nema_gfx_unit->cl));