mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
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
This commit is contained in:
parent
64685f4b20
commit
84ea4ad990
@ -121,12 +121,12 @@ G_DEFINE_TYPE (ClutterBrightnessContrastEffect,
|
|||||||
static gboolean
|
static gboolean
|
||||||
will_have_no_effect (ClutterBrightnessContrastEffect *self)
|
will_have_no_effect (ClutterBrightnessContrastEffect *self)
|
||||||
{
|
{
|
||||||
return (self->brightness_red == no_change &&
|
return (G_APPROX_VALUE (self->brightness_red, no_change, FLT_EPSILON) &&
|
||||||
self->brightness_green == no_change &&
|
G_APPROX_VALUE (self->brightness_green, no_change, FLT_EPSILON) &&
|
||||||
self->brightness_blue == no_change &&
|
G_APPROX_VALUE (self->brightness_blue, no_change, FLT_EPSILON) &&
|
||||||
self->contrast_red == no_change &&
|
G_APPROX_VALUE (self->contrast_red, no_change, FLT_EPSILON) &&
|
||||||
self->contrast_green == no_change &&
|
G_APPROX_VALUE (self->contrast_green, no_change, FLT_EPSILON) &&
|
||||||
self->contrast_blue == no_change);
|
G_APPROX_VALUE (self->contrast_blue, no_change, FLT_EPSILON));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -497,9 +497,9 @@ clutter_brightness_contrast_effect_set_brightness_full (ClutterBrightnessContras
|
|||||||
{
|
{
|
||||||
g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect));
|
g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect));
|
||||||
|
|
||||||
if (red == effect->brightness_red &&
|
if (G_APPROX_VALUE (red, effect->brightness_red, FLT_EPSILON) &&
|
||||||
green == effect->brightness_green &&
|
G_APPROX_VALUE (green, effect->brightness_green, FLT_EPSILON) &&
|
||||||
blue == effect->brightness_blue)
|
G_APPROX_VALUE (blue, effect->brightness_blue, FLT_EPSILON))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
effect->brightness_red = red;
|
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));
|
g_return_if_fail (CLUTTER_IS_BRIGHTNESS_CONTRAST_EFFECT (effect));
|
||||||
|
|
||||||
if (red == effect->contrast_red &&
|
if (G_APPROX_VALUE (red, effect->contrast_red, FLT_EPSILON) &&
|
||||||
green == effect->contrast_green &&
|
G_APPROX_VALUE (green, effect->contrast_green, FLT_EPSILON) &&
|
||||||
blue == effect->contrast_blue)
|
G_APPROX_VALUE (blue, effect->contrast_blue, FLT_EPSILON))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
effect->contrast_red = red;
|
effect->contrast_red = red;
|
||||||
|
Loading…
Reference in New Issue
Block a user