microvg  2.0.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 Gets the path's array header size.
80  *
81  * The default implementation returns sizeof(MICROVG_PATH_HEADER_t).
82  *
83  * @return the size in bytes.
84  */
85 uint32_t MICROVG_PATH_get_path_header_size(void);
86 
87 /*
88  * @brief Gets the size to add in the path array to encode the command and its parameters.
89  *
90  * The default implementation uses 32-bit fields for the command and for each data.
91  *
92  * @param[in] command: the command to add.
93  * @param[in] nbParams: the available number of command's parameters
94  *
95  * @return the size to add in the path array.
96  */
97 uint32_t MICROVG_PATH_get_path_command_size(jint command, uint32_t nbParams);
98 
99 /*
100  * @brief Appends the command with zero parameter in the path's array.
101  *
102  * The caller ensures the path's array is large enough to encode the command and its parameters.
103  *
104  * The default implementation uses 32-bit fields for the command and for each data.
105  *
106  * @param[in] path: the path's array
107  * @param[in] offset: the offset where store the command
108  * @param[in] cmd: the command to add
109  *
110  * @return the offset after the command and parameters
111  *
112  * @see #MICROVG_PATH_get_path_command_size(jint, uint32_t)
113  */
114 uint32_t MICROVG_PATH_append_path_command0(jbyte* path, uint32_t offset, jint cmd);
115 
116 /*
117  * @brief Appends the command with 1 point parameter in the path's array.
118  *
119  * @param[in] path: the path's array
120  * @param[in] offset: the offset where store the command
121  * @param[in] cmd: the command to add
122  * @param[in] x: the command data 1.
123  * @param[in] y: the command data 2.
124  *
125  * @return the offset after the command and parameters
126  *
127  * @see #MICROVG_PATH_append_path_command0(jbyte*, uint32_t, jint)
128  */
129 uint32_t MICROVG_PATH_append_path_command1(jbyte* path, uint32_t offset, jint cmd, jfloat x, jfloat y);
130 
131 /*
132  * @brief Appends the command with 2 points parameter in the path's array.
133  *
134  * @param[in] path: the path's array
135  * @param[in] offset: the offset where store the command
136  * @param[in] cmd: the command to add
137  * @param[in] x1: the command data 1.
138  * @param[in] y1: the command data 2.
139  * @param[in] x2: the command data 3.
140  * @param[in] y2: the command data 4.
141  *
142  * @return the offset after the command and parameters
143  *
144  * @see #MICROVG_PATH_append_path_command0(jbyte*, uint32_t, jint)
145  */
146 uint32_t MICROVG_PATH_append_path_command2(jbyte* path, uint32_t offset, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2);
147 
148 /*
149  * @brief Appends the command with 3 points parameter in the path's array.
150  *
151  * @param[in] path: the path's array
152  * @param[in] offset: the offset where store the command
153  * @param[in] cmd: the command to add
154  * @param[in] x1: the command data 1.
155  * @param[in] y1: the command data 2.
156  * @param[in] x2: the command data 3.
157  * @param[in] y2: the command data 4.
158  * @param[in] x3: the command data 5.
159  * @param[in] y3: the command data 6.
160  *
161  * @return the offset after the command and parameters
162  *
163  * @see #MICROVG_PATH_append_path_command0(jbyte*, uint32_t, jint)
164  */
165 uint32_t MICROVG_PATH_append_path_command3(jbyte* path, uint32_t offset, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2,
166  jfloat x3, jfloat y3);
167 
168 /*
169  * @brief Gets the number of parameters for a specific command.
170  *
171  * @param[in] command: the command.
172  *
173  * @return the number of parameters for the given command.
174  */
175 uint32_t MICROVG_PATH_get_command_parameter_number(jint command);
176 
177 // -----------------------------------------------------------------------------
178 // EOF
179 // -----------------------------------------------------------------------------
180 
181 #endif // VG_FEATURE_PATH
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif // !defined MICROVG_PATH_H
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities...