Commit 130fc6ce authored by Matthias Clasen's avatar Matthias Clasen

css style: Accumulate changes in place

This avoids allocating a temporary bitmask, and lets us
avoid some value comparisons altogether.
parent ac198a3c
......@@ -83,25 +83,27 @@ gtk_css_style_get_section (GtkCssStyle *style,
}
GtkBitmask *
gtk_css_style_get_difference (GtkCssStyle *style,
gtk_css_style_add_difference (GtkBitmask *accumulated,
GtkCssStyle *style,
GtkCssStyle *other)
{
GtkBitmask *result;
guint i, len;
gint len, i;
if (style == other)
return _gtk_bitmask_new ();
return accumulated;
result = _gtk_bitmask_new ();
len = _gtk_css_style_property_get_n_properties ();
for (i = 0; i < len; i++)
{
if (_gtk_bitmask_get (accumulated, i))
continue;
if (!_gtk_css_value_equal (gtk_css_style_get_value (style, i),
gtk_css_style_get_value (other, i)))
result = _gtk_bitmask_set (result, i, TRUE);
accumulated = _gtk_bitmask_set (accumulated, i, TRUE);
}
return result;
return accumulated;
}
gboolean
......
......@@ -64,7 +64,8 @@ GtkCssValue * gtk_css_style_get_value (GtkCssStyle
guint id);
GtkCssSection * gtk_css_style_get_section (GtkCssStyle *style,
guint id);
GtkBitmask * gtk_css_style_get_difference (GtkCssStyle *style,
GtkBitmask * gtk_css_style_add_difference (GtkBitmask *accumulated,
GtkCssStyle *style,
GtkCssStyle *other);
gboolean gtk_css_style_is_static (GtkCssStyle *style);
......
......@@ -50,7 +50,6 @@ gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
GtkCssStyle *new_style)
{
GtkCssWidgetNode *node;
GtkBitmask *diff;
node = GTK_CSS_WIDGET_NODE (cssnode);
......@@ -59,9 +58,7 @@ gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->style_changed (cssnode, old_style, new_style);
diff = gtk_css_style_get_difference (new_style, old_style);
node->accumulated_changes = _gtk_bitmask_union (node->accumulated_changes, diff);
_gtk_bitmask_free (diff);
node->accumulated_changes = gtk_css_style_add_difference (node->accumulated_changes, new_style, old_style);
}
static gboolean
......@@ -70,7 +67,7 @@ gtk_css_widget_node_queue_callback (GtkWidget *widget,
gpointer user_data)
{
GtkCssNode *node = user_data;
gtk_css_node_invalidate_frame_clock (node, TRUE);
_gtk_container_queue_restyle (GTK_CONTAINER (widget));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment