[gtk/wip/baedert/css-values: 68/84] csscolorvalue: check for singletons in new_literal



commit 4fc77b7091785de1b93389178b70b903a840d127
Author: Timm Bäder <mail baedert org>
Date:   Sun Jan 12 15:53:26 2020 +0100

    csscolorvalue: check for singletons in new_literal
    
    Gets rid of another ~400 GtkCssValue instances in the widget-factory.

 gtk/gtkcsscolorvalue.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/gtk/gtkcsscolorvalue.c b/gtk/gtkcsscolorvalue.c
index 520a6ee852..80cc7a3d21 100644
--- a/gtk/gtkcsscolorvalue.c
+++ b/gtk/gtkcsscolorvalue.c
@@ -507,6 +507,12 @@ _gtk_css_color_value_new_literal (const GdkRGBA *color)
 
   g_return_val_if_fail (color != NULL, NULL);
 
+  if (gdk_rgba_equal (color, &white_singleton.sym_col.rgba))
+    return _gtk_css_value_ref (&white_singleton);
+
+  if (gdk_rgba_equal (color, &transparent_black_singleton.sym_col.rgba))
+    return _gtk_css_value_ref (&transparent_black_singleton);
+
   value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
   value->type = COLOR_TYPE_LITERAL;
   value->is_computed = TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]