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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
4
testsuite/gsk/nodeparser/srgb-high-accuracy.node
Normal file
4
testsuite/gsk/nodeparser/srgb-high-accuracy.node
Normal file
@@ -0,0 +1,4 @@
|
||||
color {
|
||||
bounds: 0 0 50 50;
|
||||
color: color(srgb 0.999 0 0);
|
||||
}
|
||||
Reference in New Issue
Block a user