[gtk+/wip/cssnode3: 75/81] cssnode: Redo style changed tracking



commit 0b3123798f6592c64b76098e0099b6da7b81d71f
Author: Benjamin Otte <otte redhat com>
Date:   Wed Feb 25 18:05:07 2015 +0100

    cssnode: Redo style changed tracking
    
    We don't return a NULL style to mean "no changes" anymore, instead
    we check new_style == old_style to mean that.
    
    Make sure the code reflects this, otherwise we'll send
    GTK_CSS_CHANGE_PARENT_STYLE invalidations everywhere and screw up
    performance.

 gtk/gtkcssnode.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 5770df2..03f378d 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -588,12 +588,12 @@ gtk_css_node_get_next_sibling (GtkCssNode *cssnode)
   return cssnode->next_sibling;
 }
 
-static void
+static gboolean
 gtk_css_node_set_style (GtkCssNode  *cssnode,
                         GtkCssStyle *style)
 {
   if (cssnode->style == style)
-    return;
+    return FALSE;
 
   if (style)
     g_object_ref (style);
@@ -602,6 +602,8 @@ gtk_css_node_set_style (GtkCssNode  *cssnode,
     g_object_unref (cssnode->style);
 
   cssnode->style = style;
+
+  return TRUE;
 }
 
 static void
@@ -645,6 +647,7 @@ gtk_css_node_compute_style (GtkCssNode *cssnode,
                             gint64      timestamp)
 {
   GtkCssStyle *new_style;
+  gboolean style_changed;
 
   if (cssnode->parent && gtk_css_node_needs_new_style (cssnode->parent))
     gtk_css_node_compute_style (cssnode->parent, timestamp);
@@ -657,15 +660,12 @@ gtk_css_node_compute_style (GtkCssNode *cssnode,
                                                               timestamp,
                                                               cssnode->style);
 
-  gtk_css_node_propagate_pending_changes (cssnode, new_style != NULL);
+  style_changed = gtk_css_node_set_style (cssnode, new_style);
+  g_object_unref (new_style);
 
-  if (new_style)
-    {
-      gtk_css_node_set_style (cssnode, new_style);
-      g_object_unref (new_style);
-      cssnode->pending_changes = 0;
-    }
-  
+  gtk_css_node_propagate_pending_changes (cssnode, style_changed);
+
+  cssnode->pending_changes = 0;
   cssnode->style_is_invalid = FALSE;
 }
 


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