microvg  5.0.0
microvg
microvg_path.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2022-2023 MicroEJ Corp. All rights reserved.
5  * Use of this source code is governed by a BSD-style license that can be found with this software.
6  */
7 
15 #if !defined MICROVG_PATH_H
16 #define MICROVG_PATH_H
17 
18 #if defined __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "microvg_configuration.h"
23 
24 #ifdef VG_FEATURE_PATH
25 
26 // -----------------------------------------------------------------------------
27 // Includes
28 // -----------------------------------------------------------------------------
29 
30 #include <sni.h>
31 
32 // -----------------------------------------------------------------------------
33 // Structs
34 // -----------------------------------------------------------------------------
35 
36 /*
37  * @brief Map a jbyte array that represents a path
38  */
39 typedef struct MICROVG_PATH_HEADER {
40  uint32_t data_size; /* data size (without header) */
41  uint8_t format;
42  uint8_t padding1;
43  uint8_t padding2;
44  uint8_t padding3;
45  float bounds_xmin; /* left */
46  float bounds_xmax; /* right */
47  float bounds_ymin; /* top */
48  float bounds_ymax; /* bottom */
50 
51 // -----------------------------------------------------------------------------
52 // Specific path formatting functions [mandatory]
53 // -----------------------------------------------------------------------------
54 
55 /*
56  * @brief Gets the path's array format used to encode the commands and parameters. This format is stored into the path's
57  * header.
58  *
59  * @return the path's format
60  */
61 uint8_t MICROVG_PATH_get_path_encoder_format(void);
62 
63 /*
64  * @brief Converts the command in destination format.
65  *
66  * @param[in] command: the command to convert
67  *
68  * @return the converted command
69  */
70 uint32_t MICROVG_PATH_convert_path_command(jint command);
71 
72 // -----------------------------------------------------------------------------
73 // Specific path formatting functions [optional]
74 // -----------------------------------------------------------------------------
75 
76 /*
77  * @brief Initializes the path builder.
78  *
79  * The default implementation does nothing.
80  */
81 void MICROVG_PATH_initialize(void);
82 
83 /*
84  * @brief Gets the path's array header size.
85  *
86  * The default implementation returns sizeof(MICROVG_PATH_HEADER_t).
87  *
88  * @return the size in bytes.
89  */
90 uint32_t MICROVG_PATH_get_path_header_size(void);
91 
92 /*
93  * @brief Gets the size to add in the path array to encode the command and its parameters.
94  *
95  * The default implementation uses 32-bit fields for the command and for each data.
96  *
97  * @param[in] command: the command to add.
98  * @param[in] nbParams: the available number of command's parameters
99  *
100  * @return the size to add in the path array.
101  */
102 uint32_t MICROVG_PATH_get_path_command_size(jint command, uint32_t nbParams);
103 
104 /*
105  * @brief Appends the command with zero parameter in the path's array.
106  *
107  * The caller ensures the path's array is large enough to encode the command and its parameters.
108  *
109  * The default implementation uses 32-bit fields for the command and for each data.
110  *
111  * @param[in] path: the path's array
112  * @param[in] offset: the offset where store the command
113  * @param[in] cmd: the command to add
114  *
115  * @return the offset after the command and parameters
116  *
117  * @see #MICROVG_PATH_get_path_command_size(jint, uint32_t)
118  */
119 uint32_t MICROVG_PATH_append_path_command0(jbyte* path, uint32_t offset, jint cmd);
120 
121 /*
122  * @brief Appends the command with 1 point parameter in the path's array.
123  *
124  * @param[in] path: the path's array
125  * @param[in] offset: the offset where store the command
126  * @param[in] cmd: the command to add
127  * @param[in] x: the command data 1.
128  * @param[in] y: the command data 2.
129  *
130  * @return the offset after the command and parameters
131  *
132  * @see #MICROVG_PATH_append_path_command0(jbyte*, uint32_t, jint)
133  */
134 uint32_t MICROVG_PATH_append_path_command1(jbyte* path, uint32_t offset, jint cmd, jfloat x, jfloat y);
135 
136 /*
137  * @brief Appends the command with 2 points parameter in the path's array.
138  *
139  * @param[in] path: the path's array
140  * @param[in] offset: the offset where store the command
141  * @param[in] cmd: the command to add
142  * @param[in] x1: the command data 1.
143  * @param[in] y1: the command data 2.
144  * @param[in] x2: the command data 3.
145  * @param[in] y2: the command data 4.
146  *
147  * @return the offset after the command and parameters
148  *
149  * @see #MICROVG_PATH_append_path_command0(jbyte*, uint32_t, jint)
150  */
151 uint32_t MICROVG_PATH_append_path_command2(jbyte* path, uint32_t offset, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2);
152 
153 /*
154  * @brief Appends the command with 3 points parameter in the path's array.
155  *
156  * @param[in] path: the path's array
157  * @param[in] offset: the offset where store the command
158  * @param[in] cmd: the command to add
159  * @param[in] x1: the command data 1.
160  * @param[in] y1: the command data 2.
161  * @param[in] x2: the command data 3.
162  * @param[in] y2: the command data 4.
163  * @param[in] x3: the command data 5.
164  * @param[in] y3: the command data 6.
165  *
166  * @return the offset after the command and parameters
167  *
168  * @see #MICROVG_PATH_append_path_command0(jbyte*, uint32_t, jint)
169  */
170 uint32_t MICROVG_PATH_append_path_command3(jbyte* path, uint32_t offset, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2,
171  jfloat x3, jfloat y3);
172 
173 /*
174  * @brief Gets the number of parameters for a specific command.
175  *
176  * @param[in] command: the command.
177  *
178  * @return the number of parameters for the given command.
179  */
180 uint32_t MICROVG_PATH_get_command_parameter_number(jint command);
181 
182 // -----------------------------------------------------------------------------
183 // EOF
184 // -----------------------------------------------------------------------------
185 
186 #endif // VG_FEATURE_PATH
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif // !defined MICROVG_PATH_H
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities...