From 0d1c0773a084ae3a13ecac176e96c5f8b00b7ede Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Tue, 20 Dec 2016 10:21:02 -0800 Subject: [PATCH] triangulator: fix float comparison warning. --- .../triangulator/triangulator_stroker.c | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/static_libs/triangulator/triangulator_stroker.c b/src/static_libs/triangulator/triangulator_stroker.c index 18f7ead..436229b 100644 --- a/src/static_libs/triangulator/triangulator_stroker.c +++ b/src/static_libs/triangulator/triangulator_stroker.c @@ -1,4 +1,3 @@ - #include "triangulator_stroker.h" #include @@ -31,9 +30,9 @@ normal_vector(float x1, float y1, float x2, float y2, float width, float dx = x2 - x1; float dy = y2 - y1; - if (dx == 0) + if (EINA_FLT_CMP(dx, 0)) pw = width / fabsf(dy); - else if (dy == 0) + else if (EINA_FLT_CMP(dy, 0)) pw = width / fabsf(dx); else pw = width / sqrtf(dx*dx + dy*dy); @@ -397,7 +396,7 @@ static inline void _skip_duplicate_points(const double **pts, const double *end_pts) { while ((*pts + 2) < end_pts && (*pts)[0] == (*pts)[2] && - (*pts)[1] == (*pts)[3]) + EINA_FLT_CMP((*pts)[1], (*pts)[3])) { *pts += 2; } @@ -425,7 +424,7 @@ _path_info_get(const Efl_Gfx_Path_Command *cmds, const double *pts, Eina_Bool *i *implicit_close = EINA_TRUE; // fall through case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO: - if ((pts[0] == pts[i]) && (pts[1] == pts[i+1])) + if (EINA_FLT_CMP(pts[0], pts[i]) && EINA_FLT_CMP(pts[1], pts[i+1])) *ends_at_start = EINA_TRUE; return; default: @@ -433,8 +432,8 @@ _path_info_get(const Efl_Gfx_Path_Command *cmds, const double *pts, Eina_Bool *i } } // this path is the last path with out implicit close. - *ends_at_start = pts[0] == pts[i] && - pts[1] == pts[i+1]; + *ends_at_start = EINA_FLT_CMP(pts[0], pts[i]) && + EINA_FLT_CMP(pts[1], pts[i+1]); } void @@ -493,7 +492,7 @@ triangulator_stroker_process(Triangulator_Stroker *stroker, break; } case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO: - if (stroker->cx != (float)pts[0] || stroker->cy != (float)pts[1]) + if (!EINA_FLT_CMP(stroker->cx, pts[0]) || !EINA_FLT_CMP(stroker->cy, (float)pts[1])) { if (previous_type != EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO) add_join(stroker, pts[0], pts[1]); @@ -503,11 +502,15 @@ triangulator_stroker_process(Triangulator_Stroker *stroker, pts+=2; break; case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO: - if (stroker->cx != (float)pts[0] || stroker->cy != (float)pts[1] || - (float)pts[0] != (float)pts[2] || (float)pts[1] != (float)pts[3] || - (float)pts[2] != (float)pts[4] || (float)pts[3] != (float)pts[5]) + if (!EINA_FLT_CMP(stroker->cx, pts[0]) || + !EINA_FLT_CMP(stroker->cy, pts[1]) || + !EINA_FLT_CMP(pts[0], pts[2]) || + !EINA_FLT_CMP(pts[1], pts[3]) || + !EINA_FLT_CMP(pts[2], pts[4]) || + !EINA_FLT_CMP(pts[3], pts[5])) { - if (stroker->cx != (float)pts[0] || stroker->cy != (float)pts[1]) + if (!EINA_FLT_CMP(stroker->cx, pts[0]) || + !EINA_FLT_CMP(stroker->cy, pts[1])) { if (previous_type != EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO) add_join(stroker, pts[0], pts[1]); -- 2.7.4