[gtk+/wip/cssnode3: 30/81] stylecontext: Don't queue animate tick callbacks anymore
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 30/81] stylecontext: Don't queue animate tick callbacks anymore
- Date: Sat, 28 Feb 2015 23:12:14 +0000 (UTC)
commit 69b6e3150ddfa864c0f505e3db17dd3062948257
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 7 19:03:37 2015 +0100
stylecontext: Don't queue animate tick callbacks anymore
Instead, just mark nodes permanently as invalid.
gtk/gtkcssnodeprivate.h | 2 +-
gtk/gtkcsswidgetnode.c | 4 +
gtk/gtkstylecontext.c | 131 ------------------------------------------
gtk/gtkstylecontextprivate.h | 2 -
gtk/gtkwidget.c | 6 --
5 files changed, 5 insertions(+), 140 deletions(-)
---
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 45fe926..e0f60e5 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -49,7 +49,7 @@ struct _GtkCssNode
GtkCssChange pending_changes; /* changes that accumulated since the style was last
computed */
- guint invalid :1; /* set if node or a child is invalid */
+ guint invalid :1; /* node or a child needs to be validated (even if just for
animation) */
};
struct _GtkCssNodeClass
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index a684431..d0ae369 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -156,6 +156,10 @@ gtk_css_widget_node_validate (GtkCssNode *node,
changes = gtk_css_style_get_difference (new_style, style);
+ if (GTK_IS_CSS_ANIMATED_STYLE (new_style) &&
+ !gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (new_style)))
+ gtk_css_node_set_invalid (node, TRUE);
+
gtk_css_node_set_style (node, new_style);
g_object_unref (new_style);
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index afe362e..c6acbcd 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -150,11 +150,9 @@ struct _GtkStyleContextPrivate
GSList *saved_nodes;
GArray *property_cache;
- guint frame_clock_update_id;
GdkFrameClock *frame_clock;
const GtkBitmask *invalidating_context;
- guint animating : 1;
};
enum {
@@ -184,9 +182,6 @@ static void gtk_style_context_impl_get_property (GObject *object,
GParamSpec *pspec);
-static void gtk_style_context_disconnect_update (GtkStyleContext *context);
-static void gtk_style_context_connect_update (GtkStyleContext *context);
-
G_DEFINE_TYPE_WITH_PRIVATE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT)
static void
@@ -350,117 +345,6 @@ gtk_style_context_init (GtkStyleContext *style_context)
}
static void
-gtk_style_context_update (GdkFrameClock *clock,
- GtkStyleContext *context)
-{
- gtk_css_node_invalidate (gtk_style_context_get_root (context), GTK_CSS_CHANGE_ANIMATE);
-}
-
-static gboolean
-gtk_style_context_is_animating (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = context->priv;
-
- return priv->animating;
-}
-
-static void
-gtk_style_context_disconnect_update (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = context->priv;
-
- if (priv->frame_clock && priv->frame_clock_update_id)
- {
- g_signal_handler_disconnect (priv->frame_clock,
- priv->frame_clock_update_id);
- priv->frame_clock_update_id = 0;
- gdk_frame_clock_end_updating (priv->frame_clock);
- }
-}
-
-static void
-gtk_style_context_connect_update (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = context->priv;
-
- if (priv->frame_clock && priv->frame_clock_update_id == 0)
- {
- priv->frame_clock_update_id = g_signal_connect (priv->frame_clock,
- "update",
- G_CALLBACK (gtk_style_context_update),
- context);
- gdk_frame_clock_begin_updating (priv->frame_clock);
- }
-}
-
-static void
-gtk_style_context_stop_animating (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = context->priv;
-
- if (!gtk_style_context_is_animating (context))
- return;
-
- priv->animating = FALSE;
-
- gtk_style_context_disconnect_update (context);
-}
-
-static void
-gtk_style_context_start_animating (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = context->priv;
-
- if (gtk_style_context_is_animating (context))
- return;
-
- priv->animating = TRUE;
-
- gtk_style_context_connect_update (context);
-}
-
-static gboolean
-gtk_style_context_should_animate (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv;
- GtkWidget *widget;
- GtkCssStyle *values;
- gboolean animate;
-
- priv = context->priv;
-
- if (!GTK_IS_CSS_WIDGET_NODE (priv->cssnode))
- return FALSE;
-
- widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode));
- if (widget == NULL)
- return FALSE;
-
- if (!gtk_widget_get_mapped (widget))
- return FALSE;
-
- values = gtk_style_context_lookup_style (context);
- if (!GTK_IS_CSS_ANIMATED_STYLE (values) ||
- gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
- return FALSE;
-
- g_object_get (gtk_widget_get_settings (widget),
- "gtk-enable-animations", &animate,
- NULL);
-
- return animate;
-}
-
-void
-_gtk_style_context_update_animating (GtkStyleContext *context)
-{
- if (gtk_style_context_should_animate (context))
- gtk_style_context_start_animating (context);
- else
- gtk_style_context_stop_animating (context);
-}
-
-static void
gtk_style_context_clear_parent (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv = context->priv;
@@ -480,8 +364,6 @@ gtk_style_context_finalize (GObject *object)
style_context = GTK_STYLE_CONTEXT (object);
priv = style_context->priv;
- gtk_style_context_stop_animating (style_context);
-
gtk_style_context_clear_parent (style_context);
gtk_style_context_set_cascade (style_context, NULL);
@@ -697,8 +579,6 @@ _gtk_style_context_set_widget (GtkStyleContext *context,
gtk_css_widget_node_widget_destroyed (GTK_CSS_WIDGET_NODE (priv->cssnode));
}
- _gtk_style_context_update_animating (context);
-
gtk_css_node_invalidate (gtk_style_context_get_root (context), GTK_CSS_CHANGE_ANY_SELF);
}
@@ -2147,18 +2027,12 @@ gtk_style_context_set_frame_clock (GtkStyleContext *context,
if (priv->frame_clock == frame_clock)
return;
- if (priv->animating)
- gtk_style_context_disconnect_update (context);
-
if (priv->frame_clock)
g_object_unref (priv->frame_clock);
priv->frame_clock = frame_clock;
if (priv->frame_clock)
g_object_ref (priv->frame_clock);
- if (priv->animating)
- gtk_style_context_connect_update (context);
-
g_object_notify (G_OBJECT (context), "paint-clock");
}
@@ -2598,8 +2472,6 @@ void
gtk_style_context_validate (GtkStyleContext *context,
const GtkBitmask *changes)
{
- _gtk_style_context_update_animating (context);
-
if (!_gtk_bitmask_is_empty (changes))
gtk_style_context_do_invalidate (context, changes);
@@ -2635,9 +2507,6 @@ gtk_style_context_invalidate (GtkStyleContext *context)
gtk_css_node_set_style (root, style);
g_object_unref (style);
- if (!gtk_style_context_is_saved (context))
- _gtk_style_context_update_animating (context);
-
changes = _gtk_bitmask_new ();
changes = _gtk_bitmask_invert_range (changes,
0,
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 71ed897..ea16ab8 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -60,8 +60,6 @@ void _gtk_style_context_get_cursor_color (GtkStyleContext
GdkRGBA *primary_color,
GdkRGBA *secondary_color);
-void _gtk_style_context_update_animating (GtkStyleContext *context);
-
void _gtk_style_context_get_icon_extents (GtkStyleContext *context,
GdkRectangle *extents,
gint x,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 77f44c6..bed235a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5056,9 +5056,6 @@ gtk_widget_map (GtkWidget *widget)
if (!gtk_widget_get_has_window (widget))
gdk_window_invalidate_rect (priv->window, &priv->clip, FALSE);
- if (widget->priv->context)
- _gtk_style_context_update_animating (widget->priv->context);
-
gtk_widget_pop_verify_invariants (widget);
}
}
@@ -5087,9 +5084,6 @@ gtk_widget_unmap (GtkWidget *widget)
gdk_window_invalidate_rect (priv->window, &priv->clip, FALSE);
_gtk_tooltip_hide (widget);
- if (widget->priv->context)
- _gtk_style_context_update_animating (widget->priv->context);
-
g_signal_emit (widget, widget_signals[UNMAP], 0);
gtk_widget_pop_verify_invariants (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]