[gtk+] cssvalue: Implement dependency tracking for gradients
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssvalue: Implement dependency tracking for gradients
- Date: Tue, 28 Aug 2012 13:48:07 +0000 (UTC)
commit 3a65fbfc136b95b51a2248ad0b8382ab173c205a
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 27 18:39:46 2012 +0200
cssvalue: Implement dependency tracking for gradients
gtk/gtkcssstylefuncs.c | 5 ++---
gtk/gtkgradient.c | 26 +++++++++++++++++++++-----
gtk/gtkstylepropertiesprivate.h | 5 +++++
3 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index 8478ba3..0320e0a 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -34,6 +34,7 @@
#include "gtkgradient.h"
#include "gtkprivatetypebuiltins.h"
#include "gtkstylecontextprivate.h"
+#include "gtkstylepropertiesprivate.h"
#include "gtksymboliccolorprivate.h"
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
@@ -830,9 +831,7 @@ pattern_value_compute (GtkStyleContext *context,
GValue new_value = G_VALUE_INIT;
cairo_pattern_t *gradient;
- *dependencies = GTK_CSS_DEPENDS_ON_EVERYTHING;
-
- gradient = gtk_gradient_resolve_for_context (g_value_get_boxed (value), context);
+ gradient = _gtk_gradient_resolve_full (g_value_get_boxed (value), context, dependencies);
g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN);
g_value_take_boxed (&new_value, gradient);
diff --git a/gtk/gtkgradient.c b/gtk/gtkgradient.c
index 9743654..ba4e303 100644
--- a/gtk/gtkgradient.c
+++ b/gtk/gtkgradient.c
@@ -281,14 +281,16 @@ gtk_gradient_resolve (GtkGradient *gradient,
}
cairo_pattern_t *
-gtk_gradient_resolve_for_context (GtkGradient *gradient,
- GtkStyleContext *context)
+_gtk_gradient_resolve_full (GtkGradient *gradient,
+ GtkStyleContext *context,
+ GtkCssDependencies *dependencies)
{
cairo_pattern_t *pattern;
guint i;
- g_return_val_if_fail (gradient != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
+ g_return_val_if_fail (gradient != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+ g_return_val_if_fail (*dependencies == 0, NULL);
if (gradient->radius0 == 0 && gradient->radius1 == 0)
pattern = cairo_pattern_create_linear (gradient->x0, gradient->y0,
@@ -303,13 +305,15 @@ gtk_gradient_resolve_for_context (GtkGradient *gradient,
{
ColorStop *stop;
GdkRGBA rgba;
+ GtkCssDependencies stop_deps;
stop = &g_array_index (gradient->stops, ColorStop, i);
/* if color resolving fails, assume transparency */
- if (!_gtk_style_context_resolve_color (context, stop->color, &rgba, NULL))
+ if (!_gtk_style_context_resolve_color (context, stop->color, &rgba, &stop_deps))
rgba.red = rgba.green = rgba.blue = rgba.alpha = 0.0;
+ *dependencies = _gtk_css_dependencies_union (*dependencies, stop_deps);
cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
rgba.red, rgba.green,
rgba.blue, rgba.alpha);
@@ -318,6 +322,18 @@ gtk_gradient_resolve_for_context (GtkGradient *gradient,
return pattern;
}
+cairo_pattern_t *
+gtk_gradient_resolve_for_context (GtkGradient *gradient,
+ GtkStyleContext *context)
+{
+ GtkCssDependencies ignored = 0;
+
+ g_return_val_if_fail (gradient != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+
+ return _gtk_gradient_resolve_full (gradient, context, &ignored);
+}
+
static void
append_number (GString *str,
double d,
diff --git a/gtk/gtkstylepropertiesprivate.h b/gtk/gtkstylepropertiesprivate.h
index c5b742e..d459307 100644
--- a/gtk/gtkstylepropertiesprivate.h
+++ b/gtk/gtkstylepropertiesprivate.h
@@ -33,6 +33,11 @@ void _gtk_style_properties_set_property_by_property (GtkStylePropertie
GtkStateFlags state,
GtkCssValue *value);
+cairo_pattern_t *
+ _gtk_gradient_resolve_full (GtkGradient *gradient,
+ GtkStyleContext *context,
+ GtkCssDependencies *dependencies);
+
G_END_DECLS
#endif /* __GTK_STYLE_PROPERTIES_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]