gsk: Don't print any sRGB color as rgb() or rgba()

If the color value is not inside the proper range for rgb() or rgba()
values being integers, use color() instead.

Tests added/adapted.
This commit is contained in:
Benjamin Otte
2024-08-16 06:11:39 +02:00
parent a6233ac852
commit 96139a902d
4 changed files with 10 additions and 2 deletions

View File

@@ -3678,7 +3678,10 @@ static void
print_color (Printer *p,
const GdkColor *color)
{
if (gdk_color_state_equal (color->color_state, GDK_COLOR_STATE_SRGB))
if (gdk_color_state_equal (color->color_state, GDK_COLOR_STATE_SRGB) &&
round (CLAMP (color->red, 0, 1) * 255) == color->red * 255 &&
round (CLAMP (color->green, 0, 1) * 255) == color->green * 255 &&
round (CLAMP (color->blue, 0, 1) * 255) == color->blue * 255)
{
gdk_rgba_print ((const GdkRGBA *) color->values, p->str);
}

View File

@@ -431,6 +431,7 @@ node_parser_tests = [
'shadow-fail.node',
'shadow-fail.ref.node',
'shadow-fail.errors',
'srgb-high-accuracy.node',
'string-error.errors',
'string-error.node',
'string-error.ref.node',

View File

@@ -4,7 +4,7 @@ color {
}
color {
bounds: 100 100 200 300;
color: rgb(1,1,0);
color: color(srgb 0.00392157 0.00196078 0.00117647);
}
color {
bounds: 100 100 200 300;

View File

@@ -0,0 +1,4 @@
color {
bounds: 0 0 50 50;
color: color(srgb 0.999 0 0);
}