[gtk+/composite-templates] cssomputedvalues: Track dependencies
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates] cssomputedvalues: Track dependencies
- Date: Fri, 14 Sep 2012 21:21:01 +0000 (UTC)
commit d61c953c46bf030ec5a9c179328b3efd246f476c
Author: Benjamin Otte <otte redhat com>
Date: Mon Jul 23 16:14:20 2012 +0200
cssomputedvalues: Track dependencies
We now track what values have dependencies on what other values so that
we could in theory recompute them when we need to.
gtk/gtkcssanimatedvalues.c | 9 +++++++++
gtk/gtkcsscomputedvalues.c | 33 ++++++++++++++++++++++++++++++---
gtk/gtkcsscomputedvaluesprivate.h | 6 +++++-
3 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcssanimatedvalues.c b/gtk/gtkcssanimatedvalues.c
index c5e4e3b..7617faa 100644
--- a/gtk/gtkcssanimatedvalues.c
+++ b/gtk/gtkcssanimatedvalues.c
@@ -254,6 +254,15 @@ _gtk_css_animated_values_new (GtkCssComputedValues *computed,
_gtk_css_computed_values_get_section (computed, i));
}
+ _gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->depends_on_parent);
+ _gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->equals_parent);
+ _gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->depends_on_color);
+ _gtk_bitmask_free (GTK_CSS_COMPUTED_VALUES (values)->depends_on_font_size);
+ GTK_CSS_COMPUTED_VALUES (values)->depends_on_parent = _gtk_bitmask_copy (computed->depends_on_parent);
+ GTK_CSS_COMPUTED_VALUES (values)->equals_parent = _gtk_bitmask_copy (computed->equals_parent);
+ GTK_CSS_COMPUTED_VALUES (values)->depends_on_color = _gtk_bitmask_copy (computed->depends_on_color);
+ GTK_CSS_COMPUTED_VALUES (values)->depends_on_font_size = _gtk_bitmask_copy (computed->depends_on_font_size);
+
gtk_css_animated_values_start_animations (values, timestamp, source);
ignore = _gtk_css_animated_values_advance (values, timestamp);
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c
index ad03530..63b0ee7 100644
--- a/gtk/gtkcsscomputedvalues.c
+++ b/gtk/gtkcsscomputedvalues.c
@@ -47,17 +47,34 @@ gtk_css_computed_values_dispose (GObject *object)
}
static void
+gtk_css_computed_values_finalize (GObject *object)
+{
+ GtkCssComputedValues *values = GTK_CSS_COMPUTED_VALUES (object);
+
+ _gtk_bitmask_free (values->depends_on_parent);
+ _gtk_bitmask_free (values->equals_parent);
+ _gtk_bitmask_free (values->depends_on_color);
+ _gtk_bitmask_free (values->depends_on_font_size);
+
+ G_OBJECT_CLASS (_gtk_css_computed_values_parent_class)->finalize (object);
+}
+
+static void
_gtk_css_computed_values_class_init (GtkCssComputedValuesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_css_computed_values_dispose;
+ object_class->finalize = gtk_css_computed_values_finalize;
}
static void
-_gtk_css_computed_values_init (GtkCssComputedValues *computed_values)
+_gtk_css_computed_values_init (GtkCssComputedValues *values)
{
-
+ values->depends_on_parent = _gtk_bitmask_new ();
+ values->equals_parent = _gtk_bitmask_new ();
+ values->depends_on_color = _gtk_bitmask_new ();
+ values->depends_on_font_size = _gtk_bitmask_new ();
}
GtkCssComputedValues *
@@ -90,6 +107,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkCssValue *specified,
GtkCssSection *section)
{
+ GtkCssDependencies dependencies;
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
@@ -113,7 +131,16 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
else
_gtk_css_value_ref (specified);
- g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context, NULL);
+ g_ptr_array_index (values->values, id) = _gtk_css_value_compute (specified, id, context, &dependencies);
+
+ if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT))
+ values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE);
+ if (dependencies & (GTK_CSS_EQUALS_PARENT))
+ values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE);
+ if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR))
+ values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE);
+ if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE))
+ values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE);
if (section)
{
diff --git a/gtk/gtkcsscomputedvaluesprivate.h b/gtk/gtkcsscomputedvaluesprivate.h
index 64234ef..239afca 100644
--- a/gtk/gtkcsscomputedvaluesprivate.h
+++ b/gtk/gtkcsscomputedvaluesprivate.h
@@ -43,8 +43,12 @@ struct _GtkCssComputedValues
{
GObject parent;
- GPtrArray *values;
+ GPtrArray *values;
GPtrArray *sections;
+ GtkBitmask *depends_on_parent;
+ GtkBitmask *equals_parent;
+ GtkBitmask *depends_on_color;
+ GtkBitmask *depends_on_font_size;
};
struct _GtkCssComputedValuesClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]