cssrgbavalue: Add an opaque white singleton

Used a few hundred times in the widget-factory.
This commit is contained in:
Timm Bäder 2019-08-23 08:13:20 +02:00
parent ad1340cab4
commit 19f69f6ac8

View File

@ -109,6 +109,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_RGBA = {
static GtkCssValue transparent_black_singleton = (GtkCssValue) { &GTK_CSS_VALUE_RGBA, 1, { 0, 0, 0, 0 }};
static GtkCssValue transparent_white_singleton = (GtkCssValue) { &GTK_CSS_VALUE_RGBA, 1, { 1, 1, 1, 0 }};
static GtkCssValue opaque_white_singleton = (GtkCssValue) { &GTK_CSS_VALUE_RGBA, 1, { 1, 1, 1, 1 }};
GtkCssValue *
_gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba)
@ -129,6 +130,13 @@ _gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba)
rgba->blue == 0)
return _gtk_css_value_ref (&transparent_black_singleton);
}
else if (gdk_rgba_is_opaque (rgba))
{
if (rgba->red == 1 &&
rgba->green == 1 &&
rgba->blue == 1)
return _gtk_css_value_ref (&opaque_white_singleton);
}
value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_RGBA);
value->rgba = *rgba;