microvg  8.0.3
microvg
vg_path.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2022-2026 MicroEJ Corp. All rights reserved.
5  * MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */
7 
15 #if !defined VG_PATH_H
16 #define VG_PATH_H
17 
18 #if defined __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "vg_configuration.h"
23 
24 #ifdef VG_FEATURE_PATH
25 
26 // -----------------------------------------------------------------------------
27 // Includes
28 // -----------------------------------------------------------------------------
29 
30 #include <sni.h>
31 #include <stddef.h>
32 
33 // -----------------------------------------------------------------------------
34 // Typedefs
35 // -----------------------------------------------------------------------------
36 
37 #if defined(VG_FEATURE_PATH_DUAL_ARRAY) && (VG_FEATURE_PATH == VG_FEATURE_PATH_DUAL_ARRAY)
38 
42 typedef uint8_t VG_path_command_t;
43 
47 typedef float VG_path_param_t;
48 
49 #endif // VG_FEATURE_PATH_DUAL_ARRAY
50 
54 typedef struct MICROVG_PATH_HEADER {
55 #if defined(VG_FEATURE_PATH_SINGLE_ARRAY) && (VG_FEATURE_PATH == VG_FEATURE_PATH_SINGLE_ARRAY)
56  uint32_t data_size;
57 #else // VG_FEATURE_PATH_DUAL_ARRAY
58  size_t param_length;
59  size_t cmd_length;
60  size_t cmd_offset;
61 #endif
62  uint8_t format;
63  uint8_t padding1;
64  uint8_t padding2;
65  uint8_t padding3;
66  float bounds_xmin;
67  float bounds_xmax;
68  float bounds_ymin;
69  float bounds_ymax;
71 
72 // -----------------------------------------------------------------------------
73 // Specific path formatting functions [mandatory]
74 // -----------------------------------------------------------------------------
75 
83 
91 uint32_t VG_PATH_convert_path_command(jint command);
92 
93 // -----------------------------------------------------------------------------
94 // Specific path formatting functions [optional]
95 // -----------------------------------------------------------------------------
96 
103 
112 
123 uint32_t VG_PATH_get_path_command_size(jint command, uint32_t nbParams);
124 
140 uint32_t VG_PATH_append_path_command0(jbyte *path, jint array_length, jint cmd);
141 
155 uint32_t VG_PATH_append_path_command1(jbyte *path, jint array_length, jint cmd, jfloat x, jfloat y);
156 
172 uint32_t VG_PATH_append_path_command2(jbyte *path, jint array_length, jint cmd, jfloat x1, jfloat y1, jfloat x2,
173  jfloat y2);
174 
192 uint32_t VG_PATH_append_path_command3(jbyte *path, jint array_length, jint cmd, jfloat x1, jfloat y1, jfloat x2,
193  jfloat y2, jfloat x3, jfloat y3);
194 
203 
204 #if defined(VG_FEATURE_PATH_DUAL_ARRAY) && (VG_FEATURE_PATH == VG_FEATURE_PATH_DUAL_ARRAY)
205 
212 static inline VG_path_param_t * VG_PATH_get_path_param_begin(VG_PATH_HEADER_t *path) {
213  // cppcheck-suppress [misra-c2012-11.3,invalidPointerCast] cast is valid
214  return (VG_path_param_t *)(((uint8_t *)path) + VG_PATH_get_path_header_size());
215 }
216 
223 static inline VG_path_param_t * VG_PATH_get_path_param_end(VG_PATH_HEADER_t *path) {
224  return (VG_PATH_get_path_param_begin(path)) + path->param_length;
225 }
226 
233 static inline VG_path_command_t * VG_PATH_get_path_command_begin(VG_PATH_HEADER_t *path) {
234  return ((uint8_t *)VG_PATH_get_path_param_begin(path)) + path->cmd_offset;
235 }
236 
243 static inline VG_path_command_t * VG_PATH_get_path_command_end(VG_PATH_HEADER_t *path) {
244  return (VG_PATH_get_path_command_begin(path)) + path->cmd_length;
245 }
246 
247 #endif // VG_FEATURE_PATH_DUAL_ARRAY
248 
249 // -----------------------------------------------------------------------------
250 // EOF
251 // -----------------------------------------------------------------------------
252 
253 #endif // VG_FEATURE_PATH
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif // !defined VG_PATH_H
Map a jbyte array that represents a path.
Definition: vg_path.h:54
uint8_t padding2
Definition: vg_path.h:64
uint8_t padding3
Definition: vg_path.h:65
uint32_t data_size
Definition: vg_path.h:56
uint8_t padding1
Definition: vg_path.h:63
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities.
uint32_t VG_PATH_append_path_command1(jbyte *path, jint array_length, jint cmd, jfloat x, jfloat y)
Appends the command with 1 point parameter in the path's array.
void VG_PATH_initialize(void)
Initializes the path builder.
uint32_t VG_PATH_append_path_command0(jbyte *path, jint array_length, jint cmd)
Appends the command with zero parameter in the path's array.
uint32_t VG_PATH_get_command_parameter_number(jint command)
Gets the number of parameters for a specific command.
uint32_t VG_PATH_append_path_command3(jbyte *path, jint array_length, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3)
Appends the command with 3 points parameter in the path's array.
uint32_t VG_PATH_convert_path_command(jint command)
Converts the command in destination format.
uint32_t VG_PATH_append_path_command2(jbyte *path, jint array_length, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2)
Appends the command with 2 points parameter in the path's array.
struct MICROVG_PATH_HEADER VG_PATH_HEADER_t
Map a jbyte array that represents a path.
uint32_t VG_PATH_get_path_command_size(jint command, uint32_t nbParams)
Gets the size to add in the path array to encode the command and its parameters.
uint32_t VG_PATH_get_path_header_size(void)
Gets the path's array header size.
uint8_t VG_PATH_get_path_encoder_format(void)
Gets the path's array format used to encode the commands and parameters. This format is stored into t...