[gtk/wip/baedert/for-master: 7/8] iconhelper: Try to avoid some save/restore calls
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 7/8] iconhelper: Try to avoid some save/restore calls
- Date: Sat, 6 Jul 2019 11:45:57 +0000 (UTC)
commit 52a85ff5ccaae23b1da6debd3ca183a72ec130e9
Author: Timm Bäder <mail baedert org>
Date: Sat Jul 6 12:57:36 2019 +0200
iconhelper: Try to avoid some save/restore calls
GtkImage already does something similar so we often end up with 0/0
here. Avoid the save()/restore() calls in GtkSnapshot in that case.
gtk/gtkiconhelper.c | 61 ++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 44 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 5698b2bdbc..a7cf18220f 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -227,19 +227,35 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
h = MIN (h, height);
x = (width - w) / 2;
y = (height - h) / 2;
- gtk_snapshot_save (snapshot);
- gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
- gtk_css_style_snapshot_icon_paintable (style,
- snapshot,
- self->paintable,
- w, h,
- self->texture_is_symbolic);
- gtk_snapshot_restore (snapshot);
+
+ if (x != 0 || y != 0)
+ {
+ gtk_snapshot_save (snapshot);
+ gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
+ gtk_css_style_snapshot_icon_paintable (style,
+ snapshot,
+ self->paintable,
+ w, h,
+ self->texture_is_symbolic);
+ gtk_snapshot_restore (snapshot);
+ }
+ else
+ {
+ gtk_css_style_snapshot_icon_paintable (style,
+ snapshot,
+ self->paintable,
+ w, h,
+ self->texture_is_symbolic);
+
+ }
+
}
break;
- case GTK_IMAGE_PAINTABLE:
case GTK_IMAGE_EMPTY:
+ break;
+
+ case GTK_IMAGE_PAINTABLE:
default:
{
double image_ratio = (double) width / height;
@@ -269,14 +285,25 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
x = floor (width - ceil (w)) / 2;
y = floor (height - ceil (h)) / 2;
- gtk_snapshot_save (snapshot);
- gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
- gtk_css_style_snapshot_icon_paintable (style,
- snapshot,
- self->paintable,
- w, h,
- self->texture_is_symbolic);
- gtk_snapshot_restore (snapshot);
+ if (x != 0 || y != 0)
+ {
+ gtk_snapshot_save (snapshot);
+ gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
+ gtk_css_style_snapshot_icon_paintable (style,
+ snapshot,
+ self->paintable,
+ w, h,
+ self->texture_is_symbolic);
+ gtk_snapshot_restore (snapshot);
+ }
+ else
+ {
+ gtk_css_style_snapshot_icon_paintable (style,
+ snapshot,
+ self->paintable,
+ w, h,
+ self->texture_is_symbolic);
+ }
}
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]