From 0bb66ffedf7eff7b6da897a061ac158e310bb811 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:01 +0200 Subject: [PATCH] efl: add efl_graphics_path_interpolate and efl_graphics_path_equal_commands. This function will be handy to implement path interpolation in Edje later on. This would be usable by Edje if we do push an Evas_Object_Shape. Not really difficult to add at this stage. --- src/lib/efl/interfaces/efl_graphics_utils.c | 32 ++++++++++++++++++++- src/lib/efl/interfaces/efl_graphics_utils.h | 9 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index 64d70885ce..3aa11c4fb6 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -4,7 +4,7 @@ #include -static unsigned int +static inline unsigned int efl_graphics_path_command_length(Efl_Graphics_Path_Command command) { switch (command) @@ -95,6 +95,36 @@ efl_graphics_path_dup(Efl_Graphics_Path_Command **out_cmd, double **out_pts, return EINA_TRUE; } +EAPI Eina_Bool +efl_graphics_path_equal_commands(const Efl_Graphics_Path_Command *a, + const Efl_Graphics_Path_Command *b) +{ + unsigned int i; + + if (!a && !b) return EINA_TRUE; + if (!a || !b) return EINA_FALSE; + + for (i = 0; a[i] == b[i] && a[i] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END; i++) + ; + + return a[i] == b[i]; +} + +EAPI void +efl_graphics_path_interpolate(const Efl_Graphics_Path_Command *cmd, + double pos_map, + const double *from, const double *to, double *r) +{ + unsigned int i; + unsigned int j; + + if (!cmd) return ; + + for (i = 0; cmd[i] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END; i++) + for (j = 0; j < efl_graphics_path_command_length(cmd[i]); j++) + *r = (*from) * pos_map + ((*to) * (1.0 - pos_map)); +} + EAPI void efl_graphics_path_append_move_to(Efl_Graphics_Path_Command **commands, double **points, double x, double y) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.h b/src/lib/efl/interfaces/efl_graphics_utils.h index 1465e13387..6bf0974046 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.h +++ b/src/lib/efl/interfaces/efl_graphics_utils.h @@ -46,4 +46,13 @@ efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **p double x, double y, double radius); +EAPI void +efl_graphics_path_interpolate(const Efl_Graphics_Path_Command *cmd, + double pos_map, + const double *from, const double *to, double *r); + +EAPI Eina_Bool +efl_graphics_path_equal_commands(const Efl_Graphics_Path_Command *a, + const Efl_Graphics_Path_Command *b); + #endif