[gtk+/wip/cssnode3: 26/46] cssnode: Only recreate styles when needed
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 26/46] cssnode: Only recreate styles when needed
- Date: Tue, 10 Feb 2015 01:57:17 +0000 (UTC)
commit 19f6e4f0c7c7773488e19fa8759e9f2c4b28d6d9
Author: Benjamin Otte <otte redhat com>
Date: Thu Feb 5 06:49:59 2015 +0100
cssnode: Only recreate styles when needed
gtk/gtkcssnode.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 54cecad..90c8f83 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -19,10 +19,15 @@
#include "gtkcssnodeprivate.h"
+#include "gtkcssanimatedstyleprivate.h"
#include "gtkcsstransientnodeprivate.h"
#include "gtkdebug.h"
#include "gtksettingsprivate.h"
+/* When these change we do a full restyling. Otherwise we try to figure out
+ * if we need to change things. */
+#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | GTK_CSS_CHANGE_SOURCE)
+
G_DEFINE_TYPE (GtkCssNode, gtk_css_node, G_TYPE_OBJECT)
static void
@@ -50,11 +55,31 @@ gtk_css_node_finalize (GObject *object)
G_OBJECT_CLASS (gtk_css_node_parent_class)->finalize (object);
}
+static gboolean
+gtk_css_style_needs_recreation (GtkCssStyle *style,
+ GtkCssChange change)
+{
+ /* Try to avoid invalidating if we can */
+ if (change & GTK_CSS_RADICAL_CHANGE)
+ return TRUE;
+
+ if (GTK_IS_CSS_ANIMATED_STYLE (style))
+ style = GTK_CSS_ANIMATED_STYLE (style)->style;
+
+ if (gtk_css_static_style_get_change (GTK_CSS_STATIC_STYLE (style)) & change)
+ return TRUE;
+ else
+ return FALSE;
+}
+
static GtkCssStyle *
gtk_css_node_real_update_style (GtkCssNode *cssnode,
GtkCssChange pending_change,
GtkCssStyle *old_style)
{
+ if (!gtk_css_style_needs_recreation (old_style, pending_change))
+ return g_object_ref (old_style);
+
return gtk_css_node_create_style (cssnode);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]