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 Path operation related fuctions 31 * 32 */ 33 34 #ifndef __NEMA_VG_PATH_H__ 35 #define __NEMA_VG_PATH_H__ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 42 #include "nema_interpolators.h" 43 #include "nema_matrix3x3.h" 44 #include "nema_sys_defs.h" 45 #include "nema_vg_context.h" 46 47 #define NEMA_VG_PRIM_CLOSE (0x00U) /**< Close segment */ 48 #define NEMA_VG_PRIM_MOVE (0x01U) /**< Move segment */ 49 #define NEMA_VG_PRIM_LINE (0x02U) /**< Line segment */ 50 #define NEMA_VG_PRIM_HLINE (0x03U) /**< Horizontal line segment */ 51 #define NEMA_VG_PRIM_VLINE (0x04U) /**< Vertical line segment */ 52 #define NEMA_VG_PRIM_BEZIER_QUAD (0x05U) /**< Quadratic bezier segment */ 53 #define NEMA_VG_PRIM_BEZIER_CUBIC (0x06U) /**< Cubic bezier segment */ 54 #define NEMA_VG_PRIM_BEZIER_SQUAD (0x07U) /**< Smooth quadratic bezier segment */ 55 #define NEMA_VG_PRIM_BEZIER_SCUBIC (0x08U) /**< Smooth cubic bezier segment */ 56 #define NEMA_VG_PRIM_ARC (0x09U) /**< Arc segment */ 57 #define NEMA_VG_PRIM_POLYGON (0x0AU) /**< Polygon segment */ 58 #define NEMA_VG_PRIM_POLYLINE (0x0BU) /**< Polyline segment */ 59 #define NEMA_VG_PRIM_MASK (0x0FU) /**< Mask for all segments */ 60 #define NEMA_VG_REL (0x10U) /**< Rel segment*/ 61 #define NEMA_VG_ARC_LARGE (0x20U) /**< Large arc segment */ 62 #define NEMA_VG_ARC_CW (0x40U) /**< Clockwise arc segment */ 63 #define NEMA_VG_PRIM_SCCWARC (NEMA_VG_PRIM_ARC ) /**< Small counterclockwise arc segment */ 64 #define NEMA_VG_PRIM_SCWARC (NEMA_VG_PRIM_ARC | NEMA_VG_ARC_CW ) /**< Small clockwise arc segment */ 65 #define NEMA_VG_PRIM_LCCWARC (NEMA_VG_PRIM_ARC | NEMA_VG_ARC_LARGE) /**< Large counterclockwise arc segment */ 66 #define NEMA_VG_PRIM_LCWARC (NEMA_VG_PRIM_ARC | NEMA_VG_ARC_CW |NEMA_VG_ARC_LARGE) /**< Large clockwise arc segment */ 67 #define NEMA_VG_PRIM_MOVE_REL (NEMA_VG_PRIM_MOVE | NEMA_VG_REL) /**< Relative move segment */ 68 #define NEMA_VG_PRIM_LINE_REL (NEMA_VG_PRIM_LINE | NEMA_VG_REL) /**< Relative line segment */ 69 #define NEMA_VG_PRIM_HLINE_REL (NEMA_VG_PRIM_HLINE | NEMA_VG_REL) /**< Relative horizontal line segment */ 70 #define NEMA_VG_PRIM_VLINE_REL (NEMA_VG_PRIM_VLINE | NEMA_VG_REL) /**< Relative vertical line segment */ 71 #define NEMA_VG_PRIM_BEZIER_QUAD_REL (NEMA_VG_PRIM_BEZIER_QUAD | NEMA_VG_REL) /**< Relative quadratic bezier segment */ 72 #define NEMA_VG_PRIM_BEZIER_CUBIC_REL (NEMA_VG_PRIM_BEZIER_CUBIC | NEMA_VG_REL) /**< Relative cubic bezier segment */ 73 #define NEMA_VG_PRIM_BEZIER_SQUAD_REL (NEMA_VG_PRIM_BEZIER_SQUAD | NEMA_VG_REL) /**< Relative smooth quadratic bezier segment */ 74 #define NEMA_VG_PRIM_BEZIER_SCUBIC_REL (NEMA_VG_PRIM_BEZIER_SCUBIC | NEMA_VG_REL) /**< Relative smooth cubic bezier segment */ 75 #define NEMA_VG_PRIM_SCCWARC_REL (NEMA_VG_PRIM_SCCWARC | NEMA_VG_REL) /**< Relative small counterclockwise arc segment */ 76 #define NEMA_VG_PRIM_SCWARC_REL (NEMA_VG_PRIM_SCWARC | NEMA_VG_REL) /**< Relative small clockwise arc segment */ 77 #define NEMA_VG_PRIM_LCCWARC_REL (NEMA_VG_PRIM_LCCWARC | NEMA_VG_REL) /**< Relative lareg counterclockwise arc segment */ 78 #define NEMA_VG_PRIM_LCWARC_REL (NEMA_VG_PRIM_LCWARC | NEMA_VG_REL) /**< Relative lareg rclockwise arc segment */ 79 #define NEMA_VG_PRIM_POLYGON_REL (NEMA_VG_PRIM_POLYGON | NEMA_VG_REL) /**< Relative polygon segment */ 80 #define NEMA_VG_PRIM_POLYLINE_REL (NEMA_VG_PRIM_POLYLINE | NEMA_VG_REL) /**< Relative polyline segment */ 81 82 83 /** \brief Create path 84 * 85 * \return Created path 86 * 87 */ 88 NEMA_VG_PATH_HANDLE nema_vg_path_create(); 89 90 /** \brief Destroy path 91 * 92 * \param path Pointer to Path 93 * \return void 94 * 95 */ 96 void nema_vg_path_destroy(NEMA_VG_PATH_HANDLE path); 97 98 /** \brief Clear path 99 * 100 * \param path Pointer to Path 101 * \return void 102 * 103 */ 104 void nema_vg_path_clear(NEMA_VG_PATH_HANDLE path); 105 106 /** \brief Set path shape (vertex buffer) 107 * 108 * \param path Pointer to path 109 * \param seg_size Number of segments to be added 110 * \param seg Pointer to segments 111 * \param data_size Number of data to be added 112 * \param data Pointer to coordinates 113 * 114 */ 115 void nema_vg_path_set_shape(NEMA_VG_PATH_HANDLE path, const size_t seg_size , const uint8_t* seg, const size_t data_size, const nema_vg_float_t* data); 116 117 /** \brief Set path shape (vertex buffer) and bounding box. Same functionality as nema_vg_path_set_shape() 118 * but bbox is given by user (reduces CPU utilization) 119 * 120 * \param path Pointer to path 121 * \param seg_size Number of segments to be added 122 * \param seg Pointer to segments 123 * \param data_size Number of data to be added 124 * \param data Pointer to coordinates 125 * \param bbox Pointer to shape bound box coordinates {min_x, min_y, max_x, max_y} 126 * 127 */ 128 void 129 nema_vg_path_set_shape_and_bbox(NEMA_VG_PATH_HANDLE path, const size_t seg_size, const uint8_t* seg, const size_t data_size, const nema_vg_float_t* data, const nema_vg_float_t *bbox); 130 131 /** \brief Set affine transformation matrix 132 * 133 * \param path Pointer to path 134 * \param m 3x3 affine transformation matrix 135 * 136 */ 137 void nema_vg_path_set_matrix(NEMA_VG_PATH_HANDLE path, nema_matrix3x3_t m); 138 139 #ifdef __cplusplus 140 } 141 #endif 142 143 #endif //__NEMA_VG_PATH_H__ 144