[gtk/wip/baedert/css-values: 3/5] cssshadowvalue: Only create 2 shadows values for transitions



commit bac51a05db5e98ceef6fd2ea8334ed037392bba7
Author: Timm Bäder <mail baedert org>
Date:   Mon Jan 13 08:37:52 2020 +0100

    cssshadowvalue: Only create 2 shadows values for transitions
    
    This is for cases where we want to transition from "no shadow" to
    "shadow", which we need quite a lot.

 gtk/gtkcssshadowvalue.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index cc123dc8cc..e0213de8be 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -192,17 +192,29 @@ gtk_css_shadow_value_new (GtkCssValue *hoffset,
   return retval;
 }
 
+
+static GtkCssValue transition_inset_singleton  = { &GTK_CSS_VALUE_SHADOW, 1, TRUE, .inset = TRUE };
+static GtkCssValue transition_outset_singleton = { &GTK_CSS_VALUE_SHADOW, 1, TRUE, .inset = FALSE };
+
 GtkCssValue *
 _gtk_css_shadow_value_new_for_transition (GtkCssValue *target)
 {
+  GtkCssValue *result;
+
   g_return_val_if_fail (target->class == &GTK_CSS_VALUE_SHADOW, NULL);
 
-  return gtk_css_shadow_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
-                                   _gtk_css_number_value_new (0, GTK_CSS_PX),
-                                   _gtk_css_number_value_new (0, GTK_CSS_PX),
-                                   _gtk_css_number_value_new (0, GTK_CSS_PX),
-                                   target->inset,
-                                   gtk_css_color_value_new_transparent ());
+  if (target->inset)
+    result = &transition_inset_singleton;
+  else
+    result = &transition_outset_singleton;
+
+  if (G_UNLIKELY (!result->hoffset))
+    {
+      result->hoffset = result->voffset = result->spread = result->radius = _gtk_css_number_value_new (0, 
GTK_CSS_PX);
+      result->color = gtk_css_color_value_new_transparent ();
+    }
+
+  return _gtk_css_value_ref (result);
 }
 
 enum {


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