[mutter/gbsneto/offscreen-fix: 4/4] clutter/brightness-contrast-effect: Compare float with G_APPROX_VALUE



commit ed2772569c1bd6c1e45965e0cf2ea4499428b668
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Jan 7 13:59:50 2020 -0300

    clutter/brightness-contrast-effect: Compare float with G_APPROX_VALUE
    
    Nobody should ever compare float for equality. Use G_APPROX_VALUE to
    check that.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/992

 .../clutter/clutter-brightness-contrast-effect.c   | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/clutter/clutter/clutter-brightness-contrast-effect.c 
b/clutter/clutter/clutter-brightness-contrast-effect.c
index b984e2d82..be1df01cc 100644
--- a/clutter/clutter/clutter-brightness-contrast-effect.c
+++ b/clutter/clutter/clutter-brightness-contrast-effect.c
@@ -121,12 +121,12 @@ G_DEFINE_TYPE (ClutterBrightnessContrastEffect,
 static gboolean
 will_have_no_effect (ClutterBrightnessContrastEffect *self)
 {
-  return (self->brightness_red == no_change &&
-          self->brightness_green == no_change &&
-          self->brightness_blue == no_change &&
-          self->contrast_red == no_change &&
-          self->contrast_green == no_change &&
-          self->contrast_blue == no_change);
+  return (G_APPROX_VALUE (self->brightness_red, no_change, FLT_EPSILON) &&
+          G_APPROX_VALUE (self->brightness_green, no_change, FLT_EPSILON) &&
+          G_APPROX_VALUE (self->brightness_blue, no_change, FLT_EPSILON) &&
+          G_APPROX_VALUE (self->contrast_red, no_change, FLT_EPSILON) &&
+          G_APPROX_VALUE (self->contrast_green, no_change, FLT_EPSILON) &&
+          G_APPROX_VALUE (self->contrast_blue, no_change, FLT_EPSILON));
 }
 
 static gboolean
@@ -497,9 +497,9 @@ clutter_brightness_contrast_effect_set_brightness_full (ClutterBrightnessContras
 {
   g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect));
 
-  if (red == effect->brightness_red &&
-      green == effect->brightness_green &&
-      blue == effect->brightness_blue)
+  if (G_APPROX_VALUE (red, effect->brightness_red, FLT_EPSILON) &&
+      G_APPROX_VALUE (green, effect->brightness_green, FLT_EPSILON) &&
+      G_APPROX_VALUE (blue, effect->brightness_blue, FLT_EPSILON))
     return;
 
   effect->brightness_red = red;
@@ -587,9 +587,9 @@ clutter_brightness_contrast_effect_set_contrast_full (ClutterBrightnessContrastE
 {
   g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect));
 
-  if (red == effect->contrast_red &&
-      green == effect->contrast_green &&
-      blue == effect->contrast_blue)
+  if (G_APPROX_VALUE (red, effect->contrast_red, FLT_EPSILON) &&
+      G_APPROX_VALUE (green, effect->contrast_green, FLT_EPSILON) &&
+      G_APPROX_VALUE (blue, effect->contrast_blue, FLT_EPSILON))
     return;
 
   effect->contrast_red = red;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]