[gtk+/wip/cssnode3: 26/102] cssnode: Only recreate styles when needed
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 26/102] cssnode: Only recreate styles when needed
- Date: Wed, 11 Mar 2015 00:18:35 +0000 (UTC)
commit 87347a1b15dbee85c9e24b8de8599aad09194ee0
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 b331f26..db68349 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)
void
@@ -222,11 +227,31 @@ gtk_css_node_create_style (GtkCssNode *cssnode)
return style;
}
+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]