23 #if defined(VG_FEATURE_PATH) && defined(VG_FEATURE_PATH_DUAL_ARRAY) && (VG_FEATURE_PATH == VG_FEATURE_PATH_DUAL_ARRAY)
34 #include <LLVG_PATH_impl.h>
51 static int32_t _extend_path(
VG_PATH_HEADER_t *path, jint array_length, VG_path_command_t cmd, uint32_t nb_params) {
52 size_t current_size = VG_PATH_get_path_header_size() + path->param_length *
sizeof(VG_path_param_t) +
53 path->cmd_length *
sizeof(VG_path_command_t);
54 size_t required_size = current_size + VG_PATH_get_path_command_size(cmd, nb_params);
58 if (required_size > array_length) {
59 ret = array_length - required_size;
62 ((uint8_t *)VG_PATH_get_path_param_end(path)) + nb_params *
sizeof(VG_path_param_t) >
63 (uint8_t *)VG_PATH_get_path_command_begin(path)
69 || ((uint8_t *)VG_PATH_get_path_command_end(path)) +
sizeof(VG_path_command_t) >
70 ((uint8_t *)path) + array_length
78 size_t new_cmd_offset = array_length - VG_PATH_get_path_header_size() - (path->cmd_length + 1) *
79 sizeof(VG_path_command_t);
81 memmove(((uint8_t *)VG_PATH_get_path_param_begin(path)) + new_cmd_offset,
82 VG_PATH_get_path_command_begin(path), path->cmd_length *
sizeof(VG_path_command_t));
83 path->cmd_offset = new_cmd_offset;
91 static int32_t _close_path(
VG_PATH_HEADER_t *path, jint length, jfloat x1, jfloat y1, jfloat x2, jfloat y2) {
92 int32_t index = _extend_path(path, length, LLVG_PATH_CMD_CLOSE, 0);
93 int32_t ret = LLVG_SUCCESS;
96 path->bounds_xmin = x1;
97 path->bounds_xmax = x2;
98 path->bounds_ymin = y1;
99 path->bounds_ymax = y2;
100 (void)VG_PATH_append_path_command0((jbyte *)path, (uint32_t)index, LLVG_PATH_CMD_CLOSE);
113 BSP_DECLARE_WEAK_FCNT
void VG_PATH_initialize(
void) {
118 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_get_path_header_size(
void) {
123 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_get_path_command_size(jint command, uint32_t nbParams) {
125 return 1u *
sizeof(VG_path_command_t) + nbParams *
sizeof(VG_path_param_t);
129 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command0(jbyte *bytes, jint array_length, jint cmd) {
132 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
133 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
135 path->cmd_length += 1;
141 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command1(jbyte *bytes, jint array_length, jint cmd, jfloat x,
145 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
147 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
151 path->cmd_length += 1;
152 path->param_length += 2;
158 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command2(jbyte *bytes, jint array_length, jint cmd, jfloat x1,
159 jfloat y1, jfloat x2, jfloat y2) {
162 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
164 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
170 path->cmd_length += 1;
171 path->param_length += 4;
177 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command3(jbyte *bytes, jint array_length, jint cmd, jfloat x1,
178 jfloat y1, jfloat x2, jfloat y2,
179 jfloat x3, jfloat y3) {
182 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
184 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
192 path->cmd_length += 1;
193 path->param_length += 6;
203 jint LLVG_PATH_IMPL_initializePath(jbyte *jpath, jint length) {
205 uint32_t header_size = VG_PATH_get_path_header_size();
206 jint ret = LLVG_SUCCESS;
208 if (length >= header_size) {
209 path->cmd_length = 0;
210 path->param_length = 0;
211 path->cmd_offset = 0;
212 path->format = VG_PATH_get_path_encoder_format();
222 jint LLVG_PATH_IMPL_appendPathCommand1(jbyte *jpath, jint length, jint cmd, jfloat x, jfloat y) {
224 jint ret = LLVG_SUCCESS;
226 int32_t index = _extend_path(path, length, cmd, 2);
228 (void)VG_PATH_append_path_command1((jbyte *)path, (uint32_t)length, cmd, x, y);
238 jint LLVG_PATH_IMPL_appendPathCommand2(jbyte *jpath, jint length, jint cmd, jfloat x1, jfloat y1, jfloat x2,
241 jint ret = LLVG_SUCCESS;
243 if (LLVG_PATH_CMD_CLOSE == cmd) {
245 ret = _close_path(path, length, x1, y1, x2, y2);
247 int32_t index = _extend_path(path, length, cmd, 4);
249 (void)VG_PATH_append_path_command2((jbyte *)path, (uint32_t)length, cmd, x1, y1, x2, y2);
260 jint LLVG_PATH_IMPL_appendPathCommand3(jbyte *jpath, jint length, jint cmd, jfloat x1, jfloat y1, jfloat x2,
261 jfloat y2, jfloat x3, jfloat y3) {
263 jint ret = LLVG_SUCCESS;
265 int32_t index = _extend_path(path, length, cmd, 6);
267 (void)VG_PATH_append_path_command3((jbyte *)path, (uint32_t)length, cmd, x1, y1, x2, y2, x3, y3);
277 void LLVG_PATH_IMPL_reopenPath(jbyte *jpath) {
279 path->cmd_length -= 1;
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities.
MicroEJ MicroVG library low level API: helper to implement library natives methods.
MicroEJ MicroVG library low level API: implementation of Path.