From 7b1f471fe87455e9f9b673aee9e82cb0edadeb89 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Fri, 7 Oct 2016 16:56:20 +0900 Subject: [PATCH] Revert "efl/interface: refactored svg_path() api as well as added arc animation" This reverts commit 72473754653d1ef61a4822211fb7f0b27d360a28. Change-Id: If6fc6ce807cfc344a2e83949378b647e191c4a5e --- src/lib/efl/interfaces/efl_gfx_shape.c | 830 +++++++++++++++++++-------------- 1 file changed, 473 insertions(+), 357 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index a5b7097..7ffcda5 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -28,7 +28,6 @@ struct _Efl_Gfx_Shape_Data unsigned int commands_count; unsigned int points_count; - char *path_data; Eina_Bool convex; }; @@ -316,9 +315,6 @@ _efl_gfx_property_get(const Eo *obj, Efl_Gfx_Property *property) property->j = efl_gfx_shape_stroke_join_get()); } -static void _path_interpolation(Eo *obj, Efl_Gfx_Shape_Data *pd, char *from, char *to, double pos); -static void _efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd); - static Eina_Bool _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, const Eo *from, const Eo *to, double pos_map) @@ -335,70 +331,61 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, if (!eo_isa(from, EFL_GFX_SHAPE_MIXIN) || !eo_isa(to, EFL_GFX_SHAPE_MIXIN)) return EINA_FALSE; if (pd == from_pd || pd == to_pd) return EINA_FALSE; - + if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) + return EINA_FALSE; _efl_gfx_property_get(from, &property_from); _efl_gfx_property_get(to, &property_to); if (property_from.dash_length != property_to.dash_length) return EINA_FALSE; - if (from_pd->path_data && to_pd->path_data) - { - _efl_gfx_shape_reset(obj, pd); - _path_interpolation(obj, pd, from_pd->path_data, to_pd->path_data, pos_map); - } - else + cmds = realloc(pd->commands, + sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); + if (!cmds && from_pd->commands_count) return EINA_FALSE; + pd->commands = cmds; + + pts = realloc(pd->points, + sizeof (double) * from_pd->points_count); + if (!pts && from_pd->points_count) return EINA_FALSE; + pd->points = pts; + + if (cmds) { - if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) - return EINA_FALSE; - cmds = realloc(pd->commands, - sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); - if (!cmds && from_pd->commands_count) return EINA_FALSE; - pd->commands = cmds; - - pts = realloc(pd->points, - sizeof (double) * from_pd->points_count); - if (!pts && from_pd->points_count) return EINA_FALSE; - pd->points = pts; - - if (cmds) - { - memcpy(cmds, from_pd->commands, - sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); + memcpy(cmds, from_pd->commands, + sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); - if (pts) - { - double *to_pts = to_pd->points; - double *from_pts = from_pd->points; - - for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) - for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++) - { - *pts = interpolate(*from_pts, *to_pts, pos_map); - - pts++; - from_pts++; - to_pts++; - } - } + if (pts) + { + double *to_pts = to_pd->points; + double *from_pts = from_pd->points; + + for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) + for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++) + { + *pts = interpolate(*from_pts, *to_pts, pos_map); + + pts++; + from_pts++; + to_pts++; + } } + } - pd->points_count = from_pd->points_count; - pd->commands_count = from_pd->commands_count; - - pd->current.x = interpolate(from_pd->current.x, - to_pd->current.x, + pd->points_count = from_pd->points_count; + pd->commands_count = from_pd->commands_count; + + pd->current.x = interpolate(from_pd->current.x, + to_pd->current.x, + pos_map); + pd->current.y = interpolate(from_pd->current.y, + to_pd->current.y, + pos_map); + pd->current_ctrl.x = interpolate(from_pd->current_ctrl.x, + to_pd->current_ctrl.x, pos_map); - pd->current.y = interpolate(from_pd->current.y, - to_pd->current.y, + pd->current_ctrl.y = interpolate(from_pd->current_ctrl.y, + to_pd->current_ctrl.y, pos_map); - pd->current_ctrl.x = interpolate(from_pd->current_ctrl.x, - to_pd->current_ctrl.x, - pos_map); - pd->current_ctrl.y = interpolate(from_pd->current_ctrl.y, - to_pd->current_ctrl.y, - pos_map); - } if (property_to.dash_length) { @@ -460,8 +447,6 @@ _efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd) free(pd->points); pd->points = NULL; pd->points_count = 0; - free(pd->path_data); - pd->path_data = NULL; pd->current.x = 0; pd->current.y = 0; @@ -1197,6 +1182,15 @@ _skipcomma(const char *content) } static inline Eina_Bool +_next_isnumber(const char *content) +{ + char *tmp = NULL; + + (void) strtod(content, &tmp); + return content != tmp; +} + +static inline Eina_Bool _parse_number(char **content, double *number) { char *end = NULL; @@ -1208,319 +1202,286 @@ _parse_number(char **content, double *number) return EINA_TRUE; } -static inline Eina_Bool -_parse_long(char **content, int *number) +static Eina_Bool +_efl_gfx_path_parse_pair(const char *content, char **end, double *x, double *y) { - char *end = NULL; - *number = strtol(*content, &end, 10) ? 1 : 0; - // if the start of string is not number - if ((*content) == end) return EINA_FALSE; - *content = _skipcomma(end); - return EINA_TRUE; -} + char *str = (char *) content; + if (_parse_number(&str, x)) + if (_parse_number(&str, y)) + { + *end = str; + return EINA_TRUE; + } + return EINA_FALSE; +} -static int -_number_count(char cmd) +static Eina_Bool +_efl_gfx_path_parse_pair_to(const char *content, char **end, + Eo *obj, Efl_Gfx_Shape_Data *pd, + double *current_x, double *current_y, + void (*func)(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y), + Eina_Bool rel) { - int count = 0; - switch (cmd) - { - case 'M': - case 'm': - case 'L': - case 'l': - { - count = 2; - break; - } - case 'C': - case 'c': - case 'E': - case 'e': - { - count = 6; - break; - } - case 'H': - case 'h': - case 'V': - case 'v': - { - count = 1; - break; - } - case 'S': - case 's': - case 'Q': - case 'q': - case 'T': - case 't': - { - count = 4; - break; - } - case 'A': - case 'a': - { - count = 7; - break; - } - default: - break; - } - return count; -} - -static void -process_command(Eo *obj, Efl_Gfx_Shape_Data *pd, char cmd, double *arr, int count, double *cur_x, double *cur_y) -{ - int i; - switch (cmd) - { - case 'm': - case 'l': - case 'c': - case 's': - case 'q': - case 't': - { - for(i=0; ipath_data) - free(pd->path_data); - pd->path_data = malloc(strlen(svg_path_data) + 1); - strcpy(pd->path_data, svg_path_data); } - // TIZEN_ONLY(20160420): efl/interface: update locale before parsing svg path error: setlocale(LC_NUMERIC, cur_locale); -- 2.7.4