[gtk/wip/baedert/for-master] widget: Avoid doing GtkSnapshot work just to append one node
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] widget: Avoid doing GtkSnapshot work just to append one node
- Date: Sat, 6 Jun 2020 10:17:16 +0000 (UTC)
commit 05c16e1e8367a8f6b61bea08f9c0d782d921823b
Author: Timm Bäder <mail baedert org>
Date: Sat Jun 6 12:09:10 2020 +0200
widget: Avoid doing GtkSnapshot work just to append one node
We already know that a widget will have literally 1 node, not more.
Avoid doing the GtkSnapshot state stack dance and just append a new
transform node instead.
Seems to give me around 400 more icons in the fishbowl
gtk/gtkwidget.c | 60 +++++++++++++++++++++++++++++++++++----------------------
1 file changed, 37 insertions(+), 23 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 91ad52e502..b840726959 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11624,38 +11624,48 @@ gtk_widget_create_render_node (GtkWidget *widget,
return gtk_snapshot_pop_collect (snapshot);
}
-void
-gtk_widget_snapshot (GtkWidget *widget,
- GtkSnapshot *snapshot)
+static void
+gtk_widget_do_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GskRenderNode *render_node;
- if (!_gtk_widget_get_mapped (widget))
+ if (!priv->draw_needed)
return;
+ g_assert (priv->mapped);
+
if (_gtk_widget_get_alloc_needed (widget))
{
g_warning ("Trying to snapshot %s %p without a current allocation", gtk_widget_get_name (widget),
widget);
return;
}
- if (priv->draw_needed)
- {
- GskRenderNode *render_node;
+ gtk_widget_push_paintables (widget);
- gtk_widget_push_paintables (widget);
+ render_node = gtk_widget_create_render_node (widget, snapshot);
+ /* This can happen when nested drawing happens and a widget contains itself
+ * or when we replace a clipped area */
+ g_clear_pointer (&priv->render_node, gsk_render_node_unref);
+ priv->render_node = render_node;
- render_node = gtk_widget_create_render_node (widget, snapshot);
- /* This can happen when nested drawing happens and a widget contains itself
- * or when we replace a clipped area */
- g_clear_pointer (&priv->render_node, gsk_render_node_unref);
- priv->render_node = render_node;
+ priv->draw_needed = FALSE;
- priv->draw_needed = FALSE;
+ gtk_widget_pop_paintables (widget);
+ gtk_widget_update_paintables (widget);
+}
- gtk_widget_pop_paintables (widget);
- gtk_widget_update_paintables (widget);
- }
+void
+gtk_widget_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
+{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+
+ if (!_gtk_widget_get_mapped (widget))
+ return;
+
+ gtk_widget_do_snapshot (widget, snapshot);
if (priv->render_node)
gtk_snapshot_append_node (snapshot, priv->render_node);
@@ -12041,18 +12051,22 @@ gtk_widget_snapshot_child (GtkWidget *widget,
if (!_gtk_widget_get_mapped (child))
return;
+ gtk_widget_do_snapshot (child, snapshot);
+
+ if (!priv->render_node)
+ return;
+
if (priv->transform)
{
- gtk_snapshot_save (snapshot);
- gtk_snapshot_transform (snapshot, priv->transform);
-
- gtk_widget_snapshot (child, snapshot);
+ GskRenderNode *transform_node = gsk_transform_node_new (priv->render_node,
+ priv->transform);
- gtk_snapshot_restore (snapshot);
+ gtk_snapshot_append_node (snapshot, transform_node);
+ gsk_render_node_unref (transform_node);
}
else
{
- gtk_widget_snapshot (child, snapshot);
+ gtk_snapshot_append_node (snapshot, priv->render_node);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]