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;
65 ((uint8_t *)VG_PATH_get_path_param_end(path)) + (nb_params *
sizeof(VG_path_param_t)) >
66 (uint8_t *)VG_PATH_get_path_command_begin(path)
67 || ((uint8_t *)VG_PATH_get_path_command_end(path)) +
sizeof(VG_path_command_t) >
68 ((uint8_t *)path) + array_length
70 size_t new_cmd_offset = array_length - VG_PATH_get_path_header_size() - ((path->cmd_length + 1u) *
71 sizeof(VG_path_command_t));
73 (void)memmove(((uint8_t *)VG_PATH_get_path_param_begin(path)) + new_cmd_offset,
74 VG_PATH_get_path_command_begin(path), path->cmd_length *
sizeof(VG_path_command_t));
75 path->cmd_offset = new_cmd_offset;
83 static int32_t _close_path(
VG_PATH_HEADER_t *path, jint length, jfloat x1, jfloat y1, jfloat x2, jfloat y2) {
84 int32_t index = _extend_path(path, length, LLVG_PATH_CMD_CLOSE, 0);
85 int32_t ret = LLVG_SUCCESS;
88 path->bounds_xmin = x1;
89 path->bounds_xmax = x2;
90 path->bounds_ymin = y1;
91 path->bounds_ymax = y2;
92 (void)VG_PATH_append_path_command0((jbyte *)path, (uint32_t)index, LLVG_PATH_CMD_CLOSE);
105 BSP_DECLARE_WEAK_FCNT
void VG_PATH_initialize(
void) {
110 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_get_path_header_size(
void) {
115 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_get_path_command_size(jint command, uint32_t nbParams) {
117 return (1u *
sizeof(VG_path_command_t)) + (nbParams *
sizeof(VG_path_param_t));
121 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command0(jbyte *bytes, jint array_length, jint cmd) {
126 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
128 path->cmd_length += 1u;
134 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command1(jbyte *bytes, jint array_length, jint cmd, jfloat x,
139 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
141 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
145 path->cmd_length += 1u;
146 path->param_length += 2u;
152 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command2(jbyte *bytes, jint array_length, jint cmd, jfloat x1,
153 jfloat y1, jfloat x2, jfloat y2) {
157 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
159 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
165 path->cmd_length += 1u;
166 path->param_length += 4u;
172 BSP_DECLARE_WEAK_FCNT uint32_t VG_PATH_append_path_command3(jbyte *bytes, jint array_length, jint cmd, jfloat x1,
173 jfloat y1, jfloat x2, jfloat y2, jfloat x3, jfloat y3) {
177 *VG_PATH_get_path_command_end(path) = VG_PATH_convert_path_command(cmd);
179 VG_path_param_t *param_ptr = VG_PATH_get_path_param_end(path);
187 path->cmd_length += 1u;
188 path->param_length += 6u;
198 jint LLVG_PATH_IMPL_initializePath(jbyte *jpath, jint length) {
200 uint32_t header_size = VG_PATH_get_path_header_size();
201 jint ret = LLVG_SUCCESS;
203 if (length >= header_size) {
204 path->cmd_length = 0;
205 path->param_length = 0;
206 path->cmd_offset = 0;
207 path->format = VG_PATH_get_path_encoder_format();
217 jint LLVG_PATH_IMPL_appendPathCommand1(jbyte *jpath, jint length, jint cmd, jfloat x, jfloat y) {
219 jint ret = LLVG_SUCCESS;
221 int32_t index = _extend_path(path, length, cmd, 2);
223 (void)VG_PATH_append_path_command1((jbyte *)path, (uint32_t)length, cmd, x, y);
233 jint LLVG_PATH_IMPL_appendPathCommand2(jbyte *jpath, jint length, jint cmd, jfloat x1, jfloat y1, jfloat x2,
236 jint ret = LLVG_SUCCESS;
238 if (LLVG_PATH_CMD_CLOSE == cmd) {
240 ret = _close_path(path, length, x1, y1, x2, y2);
242 int32_t index = _extend_path(path, length, cmd, 4);
244 (void)VG_PATH_append_path_command2((jbyte *)path, (uint32_t)length, cmd, x1, y1, x2, y2);
255 jint LLVG_PATH_IMPL_appendPathCommand3(jbyte *jpath, jint length, jint cmd, jfloat x1, jfloat y1, jfloat x2, jfloat y2,
256 jfloat x3, jfloat y3) {
258 jint ret = LLVG_SUCCESS;
260 int32_t index = _extend_path(path, length, cmd, 6);
262 (void)VG_PATH_append_path_command3((jbyte *)path, (uint32_t)length, cmd, x1, y1, x2, y2, x3, y3);
272 void LLVG_PATH_IMPL_reopenPath(jbyte *jpath) {
274 path->cmd_length -= 1u;
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.