mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
scaling test: Avoid dividing zero by zero
If all four of the random colours have alpha channel exactly 0.0, then the computed premultiplied average will also be zero. Normalize the expected colour to (0,0,0,0) rather than (NaN,NaN,NaN,0). Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6977 Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
parent
6e54589d9e
commit
4c4d260199
@ -896,10 +896,22 @@ create_stipple_texture (GdkMemoryFormat format,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
average->red /= average->alpha;
|
if (average->alpha != 0.0f)
|
||||||
average->green /= average->alpha;
|
{
|
||||||
average->blue /= average->alpha;
|
average->red /= average->alpha;
|
||||||
average->alpha /= 4.0f;
|
average->green /= average->alpha;
|
||||||
|
average->blue /= average->alpha;
|
||||||
|
average->alpha /= 4.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Each component of the average has been multiplied by the alpha
|
||||||
|
* already, so if the alpha is zero, all components should also
|
||||||
|
* be zero */
|
||||||
|
g_assert_cmpfloat (average->red, ==, 0.0f);
|
||||||
|
g_assert_cmpfloat (average->green, ==, 0.0f);
|
||||||
|
g_assert_cmpfloat (average->blue, ==, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
texture_builder_init (&builder, format, width, height);
|
texture_builder_init (&builder, format, width, height);
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
|
Loading…
Reference in New Issue
Block a user