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