evas: resolve float compare warnings
authorMike Blumenkrantz <zmike@samsung.com>
Tue, 12 May 2020 07:20:42 +0000 (09:20 +0200)
committerJongmin Lee <jm105.lee@samsung.com>
Tue, 12 May 2020 21:49:07 +0000 (06:49 +0900)
Summary: Depends on D11792

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11793

src/lib/evas/canvas/evas_events.c
src/lib/evas/canvas/evas_object_textblock.c
src/lib/evas/common/evas_map_image_internal_high.c
src/lib/evas/gesture/efl_canvas_gesture_recognizer_flick.c
src/lib/evas/gesture/efl_canvas_gesture_recognizer_zoom.c
src/lib/evas/vg/evas_vg_cache.c
src/modules/evas/vg_savers/svg/evas_vg_save_svg.c

index 4a530f4..2665da0 100644 (file)
@@ -890,7 +890,7 @@ _evas_event_source_mouse_move_events(Evas_Object *eo_obj, Evas *eo_e,
                         ev->action = EFL_POINTER_ACTION_IN;
                         evas_object_event_callback_call(eo_child, child, EVAS_CALLBACK_MOUSE_IN, evt,
                                                         event_id2, EFL_EVENT_POINTER_IN);
-                        if ((cur_pt.x != prev_pt.x) || (cur_pt.y != prev_pt.y))
+                        if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                           {
                              ev->action = EFL_POINTER_ACTION_MOVE;
                              evas_object_event_callback_call(eo_child, child, EVAS_CALLBACK_MOUSE_MOVE, evt,
@@ -1459,7 +1459,7 @@ _evas_event_source_mouse_in_events(Evas_Object *eo_obj, Evas *eo_e,
              ev->action = EFL_POINTER_ACTION_IN;
              evas_object_event_callback_call(eo_child, child, EVAS_CALLBACK_MOUSE_IN, evt,
                                              event_id, EFL_EVENT_POINTER_IN);
-             if ((cur_pt.x != prev_pt.x) || (cur_pt.y != prev_pt.y))
+             if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                {
                   ev->action = EFL_POINTER_ACTION_MOVE;
                   evas_object_event_callback_call(eo_child, child, EVAS_CALLBACK_MOUSE_MOVE, evt,
@@ -2521,7 +2521,7 @@ _canvas_event_feed_mouse_move_internal(Evas_Public_Data *e, Efl_Input_Pointer_Da
 
    _evas_walk(e);
    /* update moved touch point */
-   if ((prev_pt.x != cur_pt.x) || (prev_pt.y != cur_pt.y))
+   if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
      _evas_touch_point_update(eo_e, 0, pdata->seat->x, pdata->seat->y, EVAS_TOUCH_POINT_MOVE);
    /* if our mouse button is grabbed to any objects */
    if (pdata->seat->mouse_grabbed > 0)
@@ -2558,7 +2558,7 @@ _canvas_event_feed_mouse_move_internal(Evas_Public_Data *e, Efl_Input_Pointer_Da
                   ev->cur = cur_pt;
                   ev->prev = prev_pt;
 
-                  if ((prev_pt.x != cur_pt.x) || (prev_pt.y != cur_pt.y))
+                  if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                     {
                        _evas_event_havemap_adjust_f(obj, &ev->cur, &ev->prev, obj_pdata->mouse_grabbed);
 
@@ -2670,7 +2670,7 @@ _canvas_event_feed_mouse_move_internal(Evas_Public_Data *e, Efl_Input_Pointer_Da
                  _evas_event_object_pointer_allow_precise(eo_obj, obj, ev->cur.x, ev->cur.y, ins) &&
                  (obj_pdata->mouse_grabbed || !evas_object_is_source_invisible(eo_obj, obj)))
                {
-                  if ((prev_pt.x != cur_pt.x) || (prev_pt.y != cur_pt.y))
+                  if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                     {
                        ev->action = EFL_POINTER_ACTION_MOVE;
                        evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_MOVE, evt,
@@ -2725,7 +2725,7 @@ _canvas_event_feed_mouse_move_internal(Evas_Public_Data *e, Efl_Input_Pointer_Da
                        ev->action = EFL_POINTER_ACTION_IN;
                        evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_IN, evt,
                                                        event_id, EFL_EVENT_POINTER_IN);
-                       if ((prev_pt.x != cur_pt.x) || (prev_pt.y != cur_pt.y))
+                       if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                           {
                              ev->action = EFL_POINTER_ACTION_MOVE;
                              evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_MOVE, evt,
@@ -2818,7 +2818,7 @@ nogrep:
                  _evas_event_object_pointer_allow_precise(eo_obj, obj, ev->cur.x, ev->cur.y, newin) &&
                  (obj_pdata->mouse_grabbed || !evas_object_is_source_invisible(eo_obj, obj)))
                {
-                  if ((prev_pt.x != cur_pt.x) || (prev_pt.y != cur_pt.y))
+                  if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                     {
                        ev->action = EFL_POINTER_ACTION_MOVE;
                        evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_MOVE, evt,
@@ -2872,7 +2872,7 @@ nogrep:
                   ev->action = EFL_POINTER_ACTION_IN;
                   evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_IN, evt,
                                                   event_id, EFL_EVENT_POINTER_IN);
-                  if ((prev_pt.x != cur_pt.x) || (prev_pt.y != cur_pt.y))
+                  if (!EINA_DBL_EQ(cur_pt.x, prev_pt.x) || !EINA_DBL_EQ(cur_pt.y, prev_pt.y))
                     {
                        ev->action = EFL_POINTER_ACTION_MOVE;
                        evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_MOVE, evt,
@@ -3061,8 +3061,8 @@ _canvas_event_feed_mouse_in_internal(Evas *eo_e, Efl_Input_Pointer_Data *ev)
              efl_ref(eo_obj);
              evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_IN, evt,
                                              event_id, EFL_EVENT_POINTER_IN);
-             if ((pdata->seat->x != ev->prev.x) &&
-                 (pdata->seat->y != ev->prev.y))
+             if (!EINA_DBL_EQ(pdata->seat->x, ev->prev.x) &&
+                 !EINA_DBL_EQ(pdata->seat->y, ev->prev.y))
                {
                   ev->action = EFL_POINTER_ACTION_MOVE;
                   evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_MOVE, evt,
index efad28c..fb96f8d 100644 (file)
@@ -3667,11 +3667,11 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt)
           halign_value_str = "locale";
           break;
         case EVAS_TEXTBLOCK_ALIGN_AUTO_NONE:
-          if (fmt->halign == 0.5)
+          if (EINA_DBL_EQ(fmt->halign, 0.5))
             halign_value_str = "center";
-          else if (fmt->halign == 0.0)
+          else if (EINA_DBL_EQ(fmt->halign, 0.0))
             halign_value_str = "left";
-          else if (fmt->halign == 1.0)
+          else if (EINA_DBL_EQ(fmt->halign, 1.0))
             halign_value_str = "right";
 
           break;
@@ -3685,13 +3685,13 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt)
 
    char *valign_value_str = NULL;
 
-   if (fmt->valign == 0.5)
+   if (EINA_DBL_EQ(fmt->valign, 0.5))
      valign_value_str = "center";
-   else if (fmt->valign == 0.0)
+   else if (EINA_DBL_EQ(fmt->valign, 0.0))
      valign_value_str = "top";
-   else if (fmt->valign == 1.0)
+   else if (EINA_DBL_EQ(fmt->valign, 1.0))
      valign_value_str = "bottom";
-   else if (fmt->valign == -1.0)
+   else if (EINA_DBL_EQ(fmt->valign, -1.0))
      valign_value_str = "baseline";
 
    if (valign_value_str != NULL)
@@ -5000,7 +5000,7 @@ loop_advance:
      }
 
    /* Check current line's height is acceptable or not */
-   if ((fmt->ellipsis == 1.0) &&
+   if (EINA_DBL_EQ(fmt->ellipsis, 1.0) &&
        (c->h > 0) && (c->y + c->ln->h > c->h))
      {
         /* No text is shown when the object height is smaller than actual font size's height.
@@ -17364,6 +17364,10 @@ _efl_canvas_textblock_efl_text_font_properties_font_bitmap_scalable_get(const Eo
    if (_FMT(x) == v) return; \
    _FMT(x) = v; \
    _canvas_text_format_changed(obj, o);
+#define _FMT_SETD(x, v) \
+   if (EINA_DBL_EQ(_FMT(x), v)) return; \
+   _FMT(x) = v; \
+   _canvas_text_format_changed(obj, o);
 
 /* Helper: updates format field of extended format information, and informs if changed. */
 #define _FMT_INFO_SET_START(x, v) \
@@ -17465,7 +17469,7 @@ static void
 _efl_canvas_textblock_efl_text_style_text_underline_height_set(Eo *obj EINA_UNUSED, Efl_Canvas_Textblock_Data *o EINA_UNUSED, double height EINA_UNUSED)
 {
    ASYNC_BLOCK;
-   _FMT_SET(underline_height, height);
+   _FMT_SETD(underline_height, height);
 }
 
 static double
@@ -17734,7 +17738,7 @@ static void
 _efl_canvas_textblock_efl_text_format_ellipsis_set(Eo *obj EINA_UNUSED, Efl_Canvas_Textblock_Data *o EINA_UNUSED, double value EINA_UNUSED)
 {
    ASYNC_BLOCK;
-   _FMT_SET(ellipsis, value);
+   _FMT_SETD(ellipsis, value);
 }
 
 static double
@@ -18020,7 +18024,7 @@ _efl_canvas_textblock_efl_text_format_text_horizontal_align_set(Eo *obj, Efl_Can
    ASYNC_BLOCK;
    if (EINA_DBL_EQ(_FMT(halign), value)) return;
    _FMT(halign_auto) = EVAS_TEXTBLOCK_ALIGN_AUTO_NONE;
-   _FMT_SET(halign, value);
+   _FMT_SETD(halign, value);
 }
 
 static double
@@ -18056,7 +18060,7 @@ _efl_canvas_textblock_efl_text_format_line_gap_set(Eo *obj EINA_UNUSED, Efl_Canv
 
    if (EINA_DBL_EQ(linerelgap, 0.0))
      {
-        _FMT_SET(linegap, value);
+        _FMT_SETD(linegap, value);
      }
    else
     {
@@ -18081,7 +18085,7 @@ _efl_canvas_textblock_efl_text_format_line_rel_gap_set(Eo *obj EINA_UNUSED, Efl_
 
    if (EINA_DBL_EQ(linegap, 0.0))
      {
-        _FMT_SET(linerelgap, value);
+        _FMT_SETD(linerelgap, value);
      }
    else
     {
index 040bab7..0b52eea 100644 (file)
@@ -587,7 +587,7 @@ _map_triangle_draw(RGBA_Image *src, RGBA_Image *dst,
    denom = ((x[2] - x[0]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[2] - y[0]));
 
    //Skip poly if it's an infinitely thin line
-   if (denom == 0) return;
+   if (EINA_DBL_EQ(denom, 0)) return;
 
    denom = 1 / denom;   //Reciprocal for speeding up
    dudx = ((u[2] - u[0]) * (y[1] - y[0]) - (u[1] - u[0]) * (y[2] - y[0])) * denom;
@@ -619,8 +619,8 @@ _map_triangle_draw(RGBA_Image *src, RGBA_Image *dst,
    //Determine which side of the polygon the longer edge is on
    side = (dxdy[1] > dxdy[0]) ? EINA_TRUE:EINA_FALSE;
 
-   if (y[0] == y[1]) side = x[0] > x[1];
-   if (y[1] == y[2]) side = x[2] > x[1];
+   if (EINA_DBL_EQ(y[0], y[1])) side = x[0] > x[1];
+   if (EINA_DBL_EQ(y[1], y[2])) side = x[2] > x[1];
 
    //Longer edge is on the left side
    if (!side)
index b113e61..962ed3d 100644 (file)
@@ -240,7 +240,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
                {
                   /* This is for continues-gesture */
                   /* Finish line on zero momentum for continues gesture */
-                  if ((!fd->momentum.x) && (!fd->momentum.y))
+                  if (EINA_DBL_EQ(fd->momentum.x, 0) && EINA_DBL_EQ(fd->momentum.y, 0))
                     pd->t_end = efl_gesture_touch_current_timestamp_get(event);
                }
           }
index 372fd1e..0a1d2e9 100644 (file)
@@ -218,7 +218,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
 
               return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
            }
-         if ((pd->zoom_base) && (pd->zoom_distance_tolerance == 0))
+         if ((pd->zoom_base) && EINA_DBL_EQ(pd->zoom_distance_tolerance, 0))
            {
               _reset_recognizer(pd);
 
index 719ee0f..86c23df 100644 (file)
@@ -226,7 +226,7 @@ _local_transform(Efl_VG *root, double w, double h, Vg_File_Data *vfd)
    Eina_Matrix3 m;
 
    if (!vfd->static_viewbox) return;
-   if (vfd->view_box.w == w && vfd->view_box.h == h) return;
+   if (EINA_DBL_EQ(vfd->view_box.w, w) && EINA_DBL_EQ(vfd->view_box.h, h)) return;
 
    sx = w / vfd->view_box.w;
    sy = h / vfd->view_box.h;
index e900432..ecb2b84 100644 (file)
@@ -23,7 +23,7 @@ printf_style(Svg_Style_Property *style, Eina_Strbuf *buf)
      eina_strbuf_append_printf(buf, " fill-opacity=\"%f\"", style->fill.opacity / 255.0);
    if ((style->stroke.paint.r) || (style->stroke.paint.g) || (style->stroke.paint.b))
      eina_strbuf_append_printf(buf, " stroke=\"#%02X%02X%02X\" ", style->stroke.paint.r, style->stroke.paint.g, style->stroke.paint.b);
-   if (style->stroke.width)
+   if (EINA_DBL_NONZERO(style->stroke.width))
      eina_strbuf_append_printf(buf, " stroke-width=\"%f\" ", style->stroke.width);
    if (style->stroke.cap == EFL_GFX_CAP_ROUND)
      eina_strbuf_append_printf(buf, " stroke-linecap=\"round\" ");