};
Eina_Bool
-_evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Path_Command *op, double *points)
+_evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd,
+ Evas_VG_Path_Command *op, double *points)
{
+ free(pd->points);
+ pd->points = NULL;
+ free(pd->op);
+ pd->op = NULL;
+
+ return evas_vg_path_dup(&pd->op, &pd->points, op, points);
}
Eina_Bool
#include "evas_common_private.h"
#include "evas_private.h"
+#include "evas_vg_private.h"
+
static unsigned int
evas_vg_path_command_length(Evas_VG_Path_Command command)
{
return 0;
}
+static inline void
+_evas_vg_path_length(Evas_VG_Path_Command *commands,
+ unsigned int *cmd_length,
+ unsigned int *pts_length)
+{
+ if (commands)
+ while (commands[*cmd_length] != EVAS_VG_PATH_COMMAND_TYPE_END)
+ {
+ *pts_length += evas_vg_path_command_length(commands[*cmd_length]);
+ (*cmd_length)++;
+ }
+
+ // Accounting for END command and handle gracefully the NULL case at the same time
+ cmd_length++;
+}
+
static inline Eina_Bool
evas_vg_path_grow(Evas_VG_Path_Command command,
Evas_VG_Path_Command **commands, double **points,
double *pts_tmp;
unsigned int cmd_length = 0, pts_length = 0;
- if (command)
- {
- while (commands[cmd_length] != EVAS_VG_PATH_COMMAND_TYPE_END)
- {
- pts_length += evas_vg_path_command_length((*commands)[cmd_length]);
- cmd_length++;
- }
- }
- // Accounting for END command and handle gracefully the NULL case at the same time
- cmd_length++;
+ _evas_vg_path_length(commands, &cmd_length, &pts_length);
if (evas_vg_path_command_length(command))
{
return EINA_TRUE;
}
+Eina_Bool
+evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts,
+ Evas_VG_Path_Command *in_cmd, double *in_pts)
+{
+ unsigned int cmd_length = 0, pts_length = 0;
+
+ _evas_vg_path_length(in_cmd, &cmd_length, &pts_length);
+
+ *out_pts = malloc(pts_length * sizeof (double));
+ *out_cmd = malloc(cmd_length * sizeof (Evas_VG_Path_Command));
+ if (!(*out_pts) || !(*out_cmd))
+ {
+ free(*out_pts);
+ free(*out_cmd);
+ return EINA_FALSE;
+ }
+
+ memcpy(*out_pts, in_pts, pts_length * sizeof (double));
+ memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Evas_VG_Path_Command));
+ return EINA_TRUE;
+}
+
void
evas_vg_path_append_move_to(Evas_VG_Path_Command **commands, double **points,
double x, double y)