1 /* TSI 2023.xmo */ 2 /******************************************************************************* 3 * Copyright (c) 2023 Think Silicon Single Member PC 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this header file and/or associated documentation files to use, copy, 7 * modify, merge, publish, distribute, sublicense, and/or sell copies of the 8 * Materials, and to permit persons to whom the Materials are furnished to do 9 * so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Materials. 13 * 14 * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS 15 * NEMAGFX API. THE UNMODIFIED, NORMATIVE VERSIONS OF THINK-SILICON NEMAGFX 16 * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT: 17 * https://think-silicon.com/products/software/nemagfx-api 18 * 19 * The software is provided 'as is', without warranty of any kind, express or 20 * implied, including but not limited to the warranties of merchantability, 21 * fitness for a particular purpose and noninfringement. In no event shall 22 * Think Silicon Single Member PC be liable for any claim, damages or other 23 * liability, whether in an action of contract, tort or otherwise, arising 24 * from, out of or in connection with the software or the use or other dealings 25 * in the software. 26 ******************************************************************************/ 27 28 /** 29 * @file 30 * @brief NemaVG Context interface. 31 * 32 * Contains NemaVG error codes, fill rules, rendering quality defines and functions for updating various rendering parameters. 33 * The functions defined here can be used to access the context parameters. The Context is an internal (opaque) struct of NemaVG. 34 */ 35 36 #ifndef __NEMA_VG_CONTEXT_H__ 37 #define __NEMA_VG_CONTEXT_H__ 38 39 #include "nema_graphics.h" 40 #include "nema_matrix3x3.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 47 #ifndef NEMA_VG_HANDLE 48 #define NEMA_VG_HANDLE void* /**< NemaVG handle object (void pointer)*/ 49 #endif 50 51 #define NEMA_VG_PATH_HANDLE NEMA_VG_HANDLE /**< NemaVG path handle (pointer to path object)*/ 52 #define NEMA_VG_PAINT_HANDLE NEMA_VG_HANDLE /**< NemaVG paint handle (pointer to paint object)*/ 53 #define NEMA_VG_GRAD_HANDLE NEMA_VG_HANDLE /**< NemaVG gradient handle (pointer to gradient object)*/ 54 55 typedef float nema_vg_float_t; /**< Floating point data type (default is 'float') */ 56 57 #define NEMA_VG_ERR_NO_ERROR (0x00000000U) /**< No Error */ 58 #define NEMA_VG_ERR_BAD_HANDLE (0x00000001U) /**< Bad handle */ 59 #define NEMA_VG_ERR_BAD_BUFFER (0x00000002U) /**< Bad buffer */ 60 #define NEMA_VG_ERR_INVALID_FILL_RULE (0x00000004U) /**< Invalid fill rule*/ 61 #define NEMA_VG_ERR_INVALID_PAINT_TYPE (0x00000008U) /**< Invalid paint type*/ 62 #define NEMA_VG_ERR_INVALID_VERTEX_DATA (0x00000010U) /**< Invalid vertex data*/ 63 #define NEMA_VG_ERR_NO_RADIAL_ENABLED (0x00000020U) /**< Radial not present in HW*/ 64 #define NEMA_VG_ERR_NO_BOUND_CL (0x00000040U) /**< No bound CL*/ 65 #define NEMA_VG_ERR_INVALID_ARGUMENTS (0x00000080U) /**< Invalid arguments*/ 66 #define NEMA_VG_ERR_INVALID_ARC_DATA (0x00000100U) /**< reserved */ 67 #define NEMA_VG_ERR_CL_FULL (0x00000200U) /**< reserved */ 68 #define NEMA_VG_ERR_DRAW_OUT_OF_BOUNDS (0x00000400U) /**< Path is out of the drawing area */ 69 #define NEMA_VG_ERR_INVALID_MASKING_OBJ (0x00000800U) /**< Masking object was not set */ 70 #define NEMA_VG_ERR_INVALID_MASKING_FORMAT (0x00001000U) /**< Invalid Masking object Format */ 71 #define NEMA_VG_ERR_INVALID_LUT_IDX_FORMAT (0x00002000U) /**< Invalid LUT indices object Format */ 72 #define NEMA_VG_ERR_COORDS_OUT_OF_RANGE (0x00004000U) /**< Path coordinates out of supported range */ 73 #define NEMA_VG_ERR_EMPTY_TSVG (0x00008000U) /**< Tsvg has no geometries */ 74 #define NEMA_VG_ERR_NO_BOUND_FONT (0x00010000U) /**< There is no bound font */ 75 #define NEMA_VG_ERR_UNSUPPORTED_FONT (0x00020000U) /**< The font is not supported (eg. older version) by NemaVG API */ 76 #define NEMA_VG_ERR_NON_INVERTIBLE_MATRIX (0x00040000U) /**< A matrix that needs to be inverted, is not invertible */ 77 #define NEMA_VG_ERR_INVALID_GRAD_STOPS (0x00080000U) /**< Gradient stops exceed maximum available stops */ 78 #define NEMA_VG_ERR_NO_INIT (0x00100000U) /**< VG uninitialized */ 79 #define NEMA_VG_ERR_INVALID_STROKE_WIDTH (0x00200000U) /**< Invalid stroke width */ 80 #define NEMA_VG_ERR_INVALID_OPACITY (0x00400000U) /**< Invalid opacity */ 81 #define NEMA_VG_ERR_INVALID_CAP_STYLE (0x00800000U) /**< Invalid cap style */ 82 #define NEMA_VG_ERR_INVALID_JOIN_STYLE (0x01000000U) /**< Invalid join style */ 83 #define NEMA_VG_ERR_INVALID_STENCIL_SIZE (0x02000000U) /**< Invalid stencil buffer size */ 84 85 #define NEMA_VG_FILL_DRAW (0x00U) /**< DEPRECATED Stroke fill rule */ 86 #define NEMA_VG_STROKE (0x00U) /**< Stroke fill rule */ 87 #define NEMA_VG_FILL_EVEN_ODD (0x01U) /**< Evenodd fill rule */ 88 #define NEMA_VG_FILL_NON_ZERO (0x02U) /**< Non zero fill rule */ 89 90 #define NEMA_VG_QUALITY_BETTER (0x00U) /**< Better rendering quality (default option, balances rendering quality and performance)*/ 91 #define NEMA_VG_QUALITY_FASTER (0x01U) /**< Faster rendering quality (favors performance over rendering quality)*/ 92 #define NEMA_VG_QUALITY_MAXIMUM (0x02U) /**< Maximum rendering quality (favors rendering quality over performance)*/ 93 #define NEMA_VG_QUALITY_NON_AA (0x10U) /**< Rendering quality without AA*/ 94 95 #define NEMA_VG_CAP_BUTT (0x00U) /**< Butt cap*/ 96 #define NEMA_VG_CAP_ROUND (0x01U) /**< Round cap*/ 97 #define NEMA_VG_CAP_SQUARE (0x02U) /**< Square cap*/ 98 #define NEMA_VG_CAP_MAX (0x03U) /**< Max value for cap*/ 99 100 #define NEMA_VG_JOIN_BEVEL (0x00U) /**< Bevel join*/ 101 #define NEMA_VG_JOIN_MITER (0x01U) /**< Mitter join*/ 102 #define NEMA_VG_JOIN_ROUND (0x02U) /**< Round join*/ 103 #define NEMA_VG_JOIN_MAX (0x03U) /**< Max for join*/ 104 105 #define NEMA_VG_TSVG_DISABLE_NONE (0x00000000U) /**< Disable none*/ 106 #define NEMA_VG_TSVG_DISABLE_CAPS (0x00000001U) /**< Disable caps*/ 107 #define NEMA_VG_TSVG_DISABLE_JOINS (0x00000002U) /**< Disable joins*/ 108 109 /** \brief Set the global transformation matrix. Global matrix will be applied in all NemaVG rendering operations that will follow. 110 * 111 * \param m transformation matrix 112 * 113 * \return Error code 114 */ 115 uint32_t nema_vg_set_global_matrix(nema_matrix3x3_t m); 116 117 118 /** \brief Disable the global transformation matrix. 119 * 120 */ 121 void nema_vg_reset_global_matrix(void); 122 123 /** \brief Set the fill rule that will be applied when rendering a path. 124 * 125 * \param fill_rule fill rule (NEMA_VG_STROKE, NEMA_VG_FILL_EVEN_ODD, NEMA_VG_FILL_NON_ZERO) 126 * 127 */ 128 void nema_vg_set_fill_rule(uint8_t fill_rule); 129 130 /** \brief Set the stroke width that will be applied when stroking a path. 131 * 132 * \param width Stroke width to be set 133 * 134 */ 135 void nema_vg_stroke_set_width(float width); 136 137 /** \brief Set stroke cap style 138 * 139 * \param cap_style Cap style (NEMA_VG_CAP_BUTT | NEMA_VG_CAP_SQUARE | NEMA_VG_CAP_ROUND) 140 * 141 */ 142 void nema_vg_stroke_set_cap_style(uint8_t start_cap_style, uint8_t end_cap_style); 143 144 /** \brief Set stroke join style 145 * 146 * \param join_style Join style (NEMA_VG_JOIN_BEVEL | NEMA_VG_JOIN_MITER | NEMA_VG_JOIN_ROUND) 147 * 148 */ 149 void nema_vg_stroke_set_join_style(uint8_t join_style); 150 151 /** \brief Set stroke miter limit 152 * If miter join is chosen and miter length is bigger than the product 153 * of miter limit and stroke width a bevel join will be added instead 154 * 155 * \param miter_limit miter join limit to be set 156 * 157 */ 158 void nema_vg_stroke_set_miter_limit(float miter_limit); 159 160 /** \brief Enable/Disable Masking. 161 * 162 * \param masking 1 to enable, 0 to disable 163 * 164 */ 165 void nema_vg_masking(uint8_t masking); 166 167 /** \brief Set the mask object (texture) 168 * 169 * \param mask_obj Texture to be used as mask. Its format must be NEMA_A1, NEMA_A2, NEMA_A4 or Nema_A8, otherwise it will return an error. 170 * \return Error code. If no error occurs, NEMA_VG_ERR_NO_ERROR otherwise NEMA_VG_ERR_INVALID_MASKING_FORMAT. 171 * 172 */ 173 uint32_t nema_vg_set_mask(nema_img_obj_t *mask_obj); 174 175 /** \brief Translate the mask object (texture) with respect to origin point (0, 0). Sets the position of the mask object. 176 * 177 * \param x Horizontal position to place the mask object 178 * \param y Horizontal position to place the mask object 179 * 180 */ 181 void nema_vg_set_mask_translation(float x, float y); 182 183 /** \brief Set the rendering quality 184 * 185 * \param quality level (NEMA_VG_QUALITY_BETTER, NEMA_VG_QUALITY_FASTER, NEMA_VG_QUALITY_MAXIMUM, NEMA_VG_QUALITY_NON_AA) 186 * 187 */ 188 void nema_vg_set_quality(uint8_t quality); 189 190 /** \brief Set the blending mode for VG operations (see nema_blender.h documentation in NemaGFX API Manual) 191 * Additional Blending Operations: only NEMA_BLOP_SRC_PREMULT is supported 192 * 193 * \param blend Blending mode 194 * \see nema_blending_mode() 195 * 196 */ 197 void nema_vg_set_blend(uint32_t blend); 198 199 /** \brief Get the current error code. Clears the error afterwards. 200 * 201 * \return Error code. See NEMA_VG_ERR_* defines for all the possible error codes. 202 */ 203 uint32_t nema_vg_get_error(void); 204 205 /** \brief Enable/disable large coordinates handling when rendering a TSVG, a path or a predefined shape 206 * 207 * \param enable 0 to disable, 1 to enable 208 * \param allow_internal_alloc 0 to not allow internal allocation, 1 to allow 209 * 210 */ 211 void nema_vg_handle_large_coords(uint8_t enable, uint8_t allow_internal_alloc); 212 213 /** \brief Bind segment and data buffers to be used for handling large coordinates 214 * 215 * \param segs Pointer to segment buffer for large coordinates 216 * \param segs_size_bytes Segment buffer size in bytes 217 * \param data Pointer to data buffer for large coordinates 218 * \param data_size_bytes Data buffer size in bytes 219 * 220 */ 221 uint32_t nema_vg_bind_clip_coords_buf(void *segs, uint32_t segs_size_bytes, void *data, uint32_t data_size_bytes); 222 223 /** \brief Unbind segment and data buffers to be used for handling large coordinates 224 * 225 * 226 */ 227 void nema_vg_unbind_clip_coords_buf(void); 228 229 #ifdef __cplusplus 230 } 231 #endif 232 233 #endif //__NEMA_VG_CONTEXT_H__ 234