[gtk] Avoid a few state changes
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Avoid a few state changes
- Date: Tue, 7 Jan 2020 16:38:48 +0000 (UTC)
commit 6a9bc5daef85d0f9153e6cd0355a7fd2c733a232
Author: Timm Bäder <mail baedert org>
Date: Tue Dec 17 17:15:17 2019 +0100
Avoid a few state changes
We can't optimize the save/restore calls away in the snapshot code, so
do it from the caller side.
gtk/gtkimage.c | 15 +++++++++++----
gtk/gtkwidget.c | 15 +++++++++++----
2 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 751ae9de23..8a415750e9 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1136,10 +1136,17 @@ gtk_image_snapshot (GtkWidget *widget,
else
y = CLAMP (baseline - h * gtk_image_get_baseline_align (image), 0, height - ceil (h));
- gtk_snapshot_save (snapshot);
- gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
- gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
- gtk_snapshot_restore (snapshot);
+ if (x != 0 || y != 0)
+ {
+ gtk_snapshot_save (snapshot);
+ gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
+ gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
+ gtk_snapshot_restore (snapshot);
+ }
+ else
+ {
+ gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
+ }
}
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8119b06fd4..2a67391479 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13085,12 +13085,19 @@ gtk_widget_snapshot_child (GtkWidget *widget,
if (GTK_IS_NATIVE (child))
return;
- gtk_snapshot_save (snapshot);
- gtk_snapshot_transform (snapshot, priv->transform);
+ if (priv->transform)
+ {
+ gtk_snapshot_save (snapshot);
+ gtk_snapshot_transform (snapshot, priv->transform);
- gtk_widget_snapshot (child, snapshot);
+ gtk_widget_snapshot (child, snapshot);
- gtk_snapshot_restore (snapshot);
+ gtk_snapshot_restore (snapshot);
+ }
+ else
+ {
+ gtk_widget_snapshot (child, snapshot);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]