[mutter/gnome-3-34] clutter/brightness-contrast-effect: Compare float with G_APPROX_VALUE
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-34] clutter/brightness-contrast-effect: Compare float with G_APPROX_VALUE
- Date: Sun, 2 Feb 2020 16:55:39 +0000 (UTC)
commit 4959ae8bc4670cbd09c683d20fd07ded735e4dab
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
(cherry picked from commit 84ea4ad9902bae6542fb657ce9e12c1038b697fc)
.../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 9bb3d9760..16f3fb7ac 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
@@ -494,9 +494,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;
@@ -584,9 +584,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]