From 7807eba1d222033b744d39ceaecc63125cdc8309 Mon Sep 17 00:00:00 2001 From: Michal Szczecinski Date: Sun, 31 Jan 2021 12:11:11 +0100 Subject: [PATCH] evas canvas: code cleanup. Removed warnings. Change-Id: Ib475a8e806556c06c2eb11aa9b9e0d61d369e7cd --- src/lib/evas/canvas/efl_canvas_vg_container.c | 73 +++++++++++----------- src/lib/evas/canvas/efl_canvas_vg_shape.c | 2 +- src/lib/evas/canvas/evas_tvg_path_helpers.h | 42 ++++++------- src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c | 8 +-- 4 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/lib/evas/canvas/efl_canvas_vg_container.c b/src/lib/evas/canvas/efl_canvas_vg_container.c index b470b4d..09a3bcf 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_container.c +++ b/src/lib/evas/canvas/efl_canvas_vg_container.c @@ -47,41 +47,6 @@ _draw_comp(Evas_Object_Protected_Data *obj, Efl_VG *node, ENFN->ector_renderer_draw(engine, output, context, nd->renderer, NULL, EINA_FALSE); } } -#else -static void -_efl_canvas_vg_container_render_pre_tvg(Evas_Object_Protected_Data *obj, - Efl_VG *node, - Efl_Canvas_Vg_Node_Data *nd, - Eina_Matrix3 *pTransform, - void *canvas, void *scene, int w, int h) -{ - Efl_Canvas_Vg_Container_Data *cd = NULL; - Efl_VG *child = NULL; - Eina_List *l = NULL; - - if (!nd || !nd->data) return; - cd = nd->data; - - tvg_scene_clear(cd->scene); - - if (!nd->visibility) - return; - - if (scene != NULL) - tvg_scene_push(scene, cd->scene); - else if (scene == NULL && canvas != NULL) - tvg_canvas_push(canvas, cd->scene); - - EFL_CANVAS_VG_COMPUTE_MATRIX(cTransform, pTransform, nd); - - EINA_LIST_FOREACH(cd->children, l, child) - { - Efl_Canvas_Vg_Node_Data *cnd = efl_data_scope_get(child, EFL_CANVAS_VG_NODE_CLASS); - if (cnd && cnd->render_pre_tvg) - cnd->render_pre_tvg(obj, child, cnd, cTransform, canvas, cd->scene); - } -} -#endif static Ector_Buffer * _prepare_comp(Evas_Object_Protected_Data *obj, //vector object @@ -186,12 +151,46 @@ _prepare_comp(Evas_Object_Protected_Data *obj, //vector object ector_buffer_pixels_set(surface, pd->comp.pixels, size.w, size.h, pd->comp.stride, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE); ector_surface_reference_point_set(surface, 0, 0); -#ifndef HAVE_THORVG _draw_comp(obj, comp_target, surface, engine, output, context); -#endif return pd->comp.buffer; } +#else +static void +_efl_canvas_vg_container_render_pre_tvg(Evas_Object_Protected_Data *obj, + Efl_VG *node, + Efl_Canvas_Vg_Node_Data *nd, + Eina_Matrix3 *pTransform, + void *canvas, void *scene, + EINA_UNUSED int w, EINA_UNUSED int h) +{ + Efl_Canvas_Vg_Container_Data *cd = NULL; + Efl_VG *child = NULL; + Eina_List *l = NULL; + + if (!nd || !nd->data) return; + cd = nd->data; + + tvg_scene_clear(cd->scene); + + if (!nd->visibility) + return; + + if (scene != NULL) + tvg_scene_push(scene, cd->scene); + else if (scene == NULL && canvas != NULL) + tvg_canvas_push(canvas, cd->scene); + + EFL_CANVAS_VG_COMPUTE_MATRIX(cTransform, pTransform, nd); + + EINA_LIST_FOREACH(cd->children, l, child) + { + Efl_Canvas_Vg_Node_Data *cnd = efl_data_scope_get(child, EFL_CANVAS_VG_NODE_CLASS); + if (cnd && cnd->render_pre_tvg) + cnd->render_pre_tvg(obj, child, cnd, cTransform, canvas, cd->scene); + } +} +#endif static void _efl_canvas_vg_container_render_pre(Evas_Object_Protected_Data *vg_pd, diff --git a/src/lib/evas/canvas/efl_canvas_vg_shape.c b/src/lib/evas/canvas/efl_canvas_vg_shape.c index 4096be1..bf4b5c5 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_shape.c +++ b/src/lib/evas/canvas/efl_canvas_vg_shape.c @@ -145,7 +145,7 @@ _get_path_length(const Evas_Vg_Path_Command *commands, { if (commands) { - while (commands[*cmd_length] != EFL_GFX_PATH_COMMAND_TYPE_END) + while (commands[*cmd_length] != EVAS_VG_PATH_COMMAND_END) { *pts_length += _get_command_length(commands[*cmd_length]); (*cmd_length)++; diff --git a/src/lib/evas/canvas/evas_tvg_path_helpers.h b/src/lib/evas/canvas/evas_tvg_path_helpers.h index 99234d6..5497b15 100644 --- a/src/lib/evas/canvas/evas_tvg_path_helpers.h +++ b/src/lib/evas/canvas/evas_tvg_path_helpers.h @@ -115,7 +115,7 @@ _number_count(char cmd) static char* _next_command(char *path, char *cmd, double *arr, int *count) { - int i = 0, large, sweep; + int i = 0, large = 0, sweep = 0; path = _skipcomma(path); if (isalpha(*path)) @@ -172,17 +172,17 @@ _arc_to_variables_initialization(double x, double y, double rx, double ry, double angle, Eina_Bool large_arc, Eina_Bool sweep, double sx, double sy, Arc_To_Init_Variables *var) { - double cxp, cyp; - double cos_phi, sin_phi; - double dx2, dy2; - double x1p, y1p; - double x1p2, y1p2; - double rx2, ry2; - double lambda; - double c; - double at; - double delta_theta; - double nat; + double cxp = 0, cyp = 0; + double cos_phi = 0, sin_phi = 0; + double dx2 = 0, dy2 = 0; + double x1p = 0, y1p = 0; + double x1p2 = 0, y1p2 = 0; + double rx2 = 0, ry2 = 0; + double lambda = 0; + double c = 0; + double at = 0; + double delta_theta = 0; + double nat = 0; angle = angle * M_PI / 180.0; cos_phi = cos(angle); @@ -327,7 +327,7 @@ _process_command(Efl_Tvg_Shape_Svg_Path *svg_path, char c, double *pts, int *number_array, double *cur_x, double *cur_y, double *cur_ctl_x, double *cur_ctl_y, Eina_Bool *is_quadratic) { - int i; + int i = 0; switch (c) { case 'm': @@ -409,7 +409,7 @@ _process_command(Efl_Tvg_Shape_Svg_Path *svg_path, char c, double *pts, case 's': case 'S': { - double ctrl_x, ctrl_y; + double ctrl_x = 0, ctrl_y = 0; ctrl_x = *cur_x; ctrl_y = *cur_y; if ((svg_path->cmds_cnt > 1) && (svg_path->cmds[svg_path->cmds_cnt - 1] == @@ -458,7 +458,7 @@ _process_command(Efl_Tvg_Shape_Svg_Path *svg_path, char c, double *pts, case 't': case 'T': { - double ctrl_x, ctrl_y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1; + double ctrl_x = 0, ctrl_y = 0, ctrl_x0 = 0, ctrl_y0 = 0, ctrl_x1 = 0, ctrl_y1 = 0; ctrl_x = *cur_x; ctrl_y = *cur_y; if ((svg_path->cmds_cnt > 1) && (svg_path->cmds[svg_path->cmds_cnt - 1] == @@ -510,12 +510,12 @@ _process_command(Efl_Tvg_Shape_Svg_Path *svg_path, char c, double *pts, case 'A': { Arc_To_Init_Variables var; - double x, y, rx, ry; - double sx, sy, ex, ey; - double c1x, c1y, c2x, c2y; - double theta2; - double cos_theta2, sin_theta2; - int i; + double x = 0, y = 0, rx = 0, ry = 0; + double sx = 0, sy = 0, ex = 0, ey = 0; + double c1x = 0, c1y = 0, c2x = 0, c2y = 0; + double theta2 = 0; + double cos_theta2 = 0, sin_theta2 = 0; + int i = 0; x = pts[5]; y = pts[6]; diff --git a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c index e8c46ce..77058b9 100644 --- a/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c +++ b/src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c @@ -265,7 +265,7 @@ _PARSE_TAG(Efl_Gfx_Fill_Rule, fill_rule, fill_rule_tags, EFL_GFX_FILL_RULE_WINDI * https://www.w3.org/TR/SVG/painting.html */ static inline void -_parse_dash_array(const char *str, Efl_Gfx_Dash** dash, int *length) +_parse_dash_array(const char *str, Evas_Vg_Dash** dash, int *length) { // It is assumed that the length of the dasharray string is 255 or less. double tmp[255]; @@ -283,7 +283,7 @@ _parse_dash_array(const char *str, Efl_Gfx_Dash** dash, int *length) if (count & 0x1) { // odd case. *length = count; - *dash = calloc(*length, sizeof(Efl_Gfx_Dash)); + *dash = calloc(*length, sizeof(Evas_Vg_Dash)); while (index < count) { leni = (2 * index) % count; @@ -296,7 +296,7 @@ _parse_dash_array(const char *str, Efl_Gfx_Dash** dash, int *length) else { // even case *length = count/2; - *dash = calloc(*length, sizeof(Efl_Gfx_Dash)); + *dash = calloc(*length, sizeof(Evas_Vg_Dash)); while (index < *length) { (*dash)[index].length = tmp[2 * index]; @@ -2474,7 +2474,7 @@ _inherit_style(Svg_Style_Property *child, Svg_Style_Property *parent) if (count > 0) { if (child->stroke.dash) free(child->stroke.dash); - child->stroke.dash = calloc(count, sizeof(Efl_Gfx_Dash)); + child->stroke.dash = calloc(count, sizeof(Evas_Vg_Dash)); child->stroke.dash_count = count; for (i = 0; i < count; i++) { -- 2.7.4