[gtk+/wip/cssnode3: 53/88] cssstyle: Remove unused optimization



commit 58ec57bc9ab25ce2bf6cc653e922a157dc4b85a3
Author: Benjamin Otte <otte redhat com>
Date:   Sat Feb 14 01:59:17 2015 +0100

    cssstyle: Remove unused optimization
    
    After measuring it, I realized the optimization never triggers for
    Adwaita and rarely ever triggers for simple themes. So it is not
    useful to keep it around.

 gtk/gtkcssnode.c               |   33 ------------
 gtk/gtkcssnodeprivate.h        |    3 -
 gtk/gtkcssstaticstyle.c        |  114 ----------------------------------------
 gtk/gtkcssstaticstyleprivate.h |   10 ----
 gtk/gtkcsswidgetnode.c         |    9 +---
 5 files changed, 2 insertions(+), 167 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index e59bce8..b9b6bbc 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -170,39 +170,6 @@ store_in_global_parent_cache (GtkCssNode                  *node,
 }
 
 GtkCssStyle *
-gtk_css_node_update_style (GtkCssNode       *cssnode,
-                           GtkCssStyle      *style,
-                           const GtkBitmask *parent_changes)
-{
-  const GtkCssNodeDeclaration *decl;
-  GtkCssMatcher matcher;
-  GtkCssStyle *parent;
-  GtkCssStyle *result;
-
-  parent = cssnode->parent ? cssnode->parent->style : NULL;
-  decl = gtk_css_node_get_declaration (cssnode);
-
-  result = lookup_in_global_parent_cache (cssnode, parent, decl);
-  if (result)
-    return g_object_ref (result);
-
-  if (!gtk_css_node_init_matcher (cssnode, &matcher))
-    {
-      g_assert_not_reached ();
-    }
-
-  result = gtk_css_static_style_new_update (GTK_CSS_STATIC_STYLE (style),
-                                            parent_changes,
-                                            gtk_css_node_get_style_provider (cssnode),
-                                            &matcher,
-                                            parent);
-
-  store_in_global_parent_cache (cssnode, parent, decl, style);
-
-  return result;
-}
-
-GtkCssStyle *
 gtk_css_node_create_style (GtkCssNode *cssnode)
 {
   const GtkCssNodeDeclaration *decl;
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index ea082ba..c9bbe57 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -130,9 +130,6 @@ GtkCssStyle *           gtk_css_node_get_style          (GtkCssNode            *
 void                    gtk_css_node_set_style          (GtkCssNode            *cssnode,
                                                          GtkCssStyle           *style);
 GtkCssStyle *           gtk_css_node_create_style       (GtkCssNode            *cssnode);
-GtkCssStyle *           gtk_css_node_update_style       (GtkCssNode            *cssnode,
-                                                         GtkCssStyle           *style,
-                                                         const GtkBitmask      *parent_changes);
 
 void                    gtk_css_node_invalidate         (GtkCssNode            *cssnode,
                                                          GtkCssChange           change);
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index 9b0e3d4..e14f59e 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -66,28 +66,6 @@ gtk_css_static_style_get_section (GtkCssStyle *style,
   return g_ptr_array_index (sstyle->sections, id);
 }
 
-/* Compute the bitmask of potentially changed properties if the parent has changed
- * the passed in ones.
- * This is for example needed when changes in the "color" property will affect
- * all properties using "currentColor" as a color.
- */
-static GtkBitmask *
-gtk_css_static_style_compute_dependencies (GtkCssStaticStyle *style,
-                                           const GtkBitmask  *parent_changes)
-{
-  GtkCssStaticStyle *sstyle = GTK_CSS_STATIC_STYLE (style);
-  GtkBitmask *changes;
-
-  changes = _gtk_bitmask_copy (parent_changes);
-  changes = _gtk_bitmask_intersect (changes, sstyle->depends_on_parent);
-  if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_COLOR))
-    changes = _gtk_bitmask_union (changes, sstyle->depends_on_color);
-  if (_gtk_bitmask_get (changes, GTK_CSS_PROPERTY_FONT_SIZE))
-    changes = _gtk_bitmask_union (changes, sstyle->depends_on_font_size);
-
-  return changes;
-}
-
 static void
 gtk_css_static_style_dispose (GObject *object)
 {
@@ -108,26 +86,12 @@ gtk_css_static_style_dispose (GObject *object)
 }
 
 static void
-gtk_css_static_style_finalize (GObject *object)
-{
-  GtkCssStaticStyle *style = GTK_CSS_STATIC_STYLE (object);
-
-  _gtk_bitmask_free (style->depends_on_parent);
-  _gtk_bitmask_free (style->equals_parent);
-  _gtk_bitmask_free (style->depends_on_color);
-  _gtk_bitmask_free (style->depends_on_font_size);
-
-  G_OBJECT_CLASS (gtk_css_static_style_parent_class)->finalize (object);
-}
-
-static void
 gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkCssStyleClass *style_class = GTK_CSS_STYLE_CLASS (klass);
 
   object_class->dispose = gtk_css_static_style_dispose;
-  object_class->finalize = gtk_css_static_style_finalize;
 
   style_class->get_value = gtk_css_static_style_get_value;
   style_class->get_section = gtk_css_static_style_get_section;
@@ -136,10 +100,6 @@ gtk_css_static_style_class_init (GtkCssStaticStyleClass *klass)
 static void
 gtk_css_static_style_init (GtkCssStaticStyle *style)
 {
-  style->depends_on_parent = _gtk_bitmask_new ();
-  style->equals_parent = _gtk_bitmask_new ();
-  style->depends_on_color = _gtk_bitmask_new ();
-  style->depends_on_font_size = _gtk_bitmask_new ();
 }
 
 static void
@@ -235,71 +195,6 @@ gtk_css_static_style_new_compute (GtkStyleProviderPrivate *provider,
   return GTK_CSS_STYLE (result);
 }
 
-GtkCssStyle *
-gtk_css_static_style_new_update (GtkCssStaticStyle       *style,
-                                 const GtkBitmask        *parent_changes,
-                                 GtkStyleProviderPrivate *provider,
-                                 const GtkCssMatcher     *matcher,
-                                 GtkCssStyle             *parent)
-{
-  GtkCssStaticStyle *result;
-  GtkCssLookup *lookup;
-  GtkBitmask *changes;
-  guint i;
-
-  gtk_internal_return_val_if_fail (GTK_IS_CSS_STATIC_STYLE (style), NULL);
-  gtk_internal_return_val_if_fail (parent_changes != NULL, NULL);
-  gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
-  gtk_internal_return_val_if_fail (matcher != NULL, NULL);
-
-  changes = gtk_css_static_style_compute_dependencies (style, parent_changes);
-  if (_gtk_bitmask_is_empty (changes))
-    {
-      _gtk_bitmask_free (changes);
-      return g_object_ref (style);
-    }
-
-  result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
-
-  result->change = style->change;
-  result->depends_on_parent = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_parent, 
style->depends_on_parent),
-                                                     changes);
-  result->equals_parent = _gtk_bitmask_subtract (_gtk_bitmask_union (result->equals_parent, 
style->equals_parent),
-                                                 changes);
-  result->depends_on_color = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_color, 
style->depends_on_color),
-                                                    changes);
-  result->depends_on_font_size = _gtk_bitmask_subtract (_gtk_bitmask_union (result->depends_on_font_size, 
style->depends_on_font_size),
-                                                        changes);
-
-  for (i = 0; i < style->values->len; i++)
-    {
-      if (_gtk_bitmask_get (changes, i))
-        continue;
-
-      gtk_css_static_style_set_value (result,
-                                      i,
-                                      gtk_css_static_style_get_value (GTK_CSS_STYLE (style), i),
-                                      gtk_css_static_style_get_section (GTK_CSS_STYLE (style), i));
-    }
-
-  lookup = _gtk_css_lookup_new (changes);
-
-  _gtk_style_provider_private_lookup (provider,
-                                      matcher,
-                                      lookup,
-                                      NULL);
-
-  _gtk_css_lookup_resolve (lookup, 
-                           provider,
-                           result,
-                           parent);
-
-  _gtk_css_lookup_free (lookup);
-  _gtk_bitmask_free (changes);
-
-  return GTK_CSS_STYLE (result);
-}
-
 void
 gtk_css_static_style_compute_value (GtkCssStaticStyle       *style,
                                     GtkStyleProviderPrivate *provider,
@@ -336,15 +231,6 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle       *style,
 
   gtk_css_static_style_set_value (style, id, value, section);
 
-  if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
-    style->depends_on_parent = _gtk_bitmask_set (style->depends_on_parent, id, TRUE);
-  if (dependencies & (GTK_CSS_EQUALS_PARENT))
-    style->equals_parent = _gtk_bitmask_set (style->equals_parent, id, TRUE);
-  if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
-    style->depends_on_color = _gtk_bitmask_set (style->depends_on_color, id, TRUE);
-  if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
-    style->depends_on_font_size = _gtk_bitmask_set (style->depends_on_font_size, id, TRUE);
-
   _gtk_css_value_unref (value);
   _gtk_css_value_unref (specified);
 }
diff --git a/gtk/gtkcssstaticstyleprivate.h b/gtk/gtkcssstaticstyleprivate.h
index 6abc205..d23b74e 100644
--- a/gtk/gtkcssstaticstyleprivate.h
+++ b/gtk/gtkcssstaticstyleprivate.h
@@ -42,11 +42,6 @@ struct _GtkCssStaticStyle
   GPtrArray             *values;               /* the values */
   GPtrArray             *sections;             /* sections the values are defined in */
 
-  GtkBitmask            *depends_on_parent;    /* values that depend on parent values */
-  GtkBitmask            *equals_parent;        /* values that equal their parent values */
-  GtkBitmask            *depends_on_color;     /* values that depend on the color property */
-  GtkBitmask            *depends_on_font_size; /* values that depend on the font-size property */
-
   GtkCssChange           change;               /* change as returned by value lookup */
 };
 
@@ -61,11 +56,6 @@ GtkCssStyle *           gtk_css_static_style_get_default        (void);
 GtkCssStyle *           gtk_css_static_style_new_compute        (GtkStyleProviderPrivate *provider,
                                                                  const GtkCssMatcher    *matcher,
                                                                  GtkCssStyle            *parent);
-GtkCssStyle *           gtk_css_static_style_new_update         (GtkCssStaticStyle      *style,
-                                                                 const GtkBitmask       *parent_changes,
-                                                                 GtkStyleProviderPrivate *provider,
-                                                                 const GtkCssMatcher    *matcher,
-                                                                 GtkCssStyle            *parent);
 
 void                    gtk_css_static_style_compute_value      (GtkCssStaticStyle      *style,
                                                                  GtkStyleProviderPrivate*provider,
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index eb640ea..9a662df 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -90,16 +90,11 @@ validate_static_style (GtkCssNode       *node,
                        GtkCssChange      change,
                        const GtkBitmask *parent_changes)
 {
-  if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change))
+  if (gtk_css_static_style_needs_revalidate (GTK_CSS_STATIC_STYLE (style), change) ||
+      !_gtk_bitmask_is_empty (parent_changes))
     {
       return gtk_css_node_create_style (node);
     }
-  else if (!_gtk_bitmask_is_empty (parent_changes))
-    {
-      return gtk_css_node_update_style (node,
-                                        style,
-                                        parent_changes);
-    }
   else
     {
       return g_object_ref (style);


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