[gnome-photos/wip/rishi/thumbnailer: 4/7] utils: Short-circuit exactly sized, square GdkPixbufs when centering
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 4/7] utils: Short-circuit exactly sized, square GdkPixbufs when centering
- Date: Tue, 21 Feb 2017 16:14:56 +0000 (UTC)
commit bdf5e9f3c69526b42e84ca164f42681c79340167
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Feb 21 12:09:37 2017 +0100
utils: Short-circuit exactly sized, square GdkPixbufs when centering
https://bugzilla.gnome.org/show_bug.cgi?id=740417
src/photos-utils.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index c268c1b..e1365c4 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -134,13 +134,19 @@ photos_utils_center_pixbuf (GdkPixbuf *pixbuf, gint size)
gint height;
gint width;
- ret_val = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size);
- gdk_pixbuf_fill (ret_val, 0x00000000);
-
height = gdk_pixbuf_get_height (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
+ if (height == size && width == size)
+ {
+ ret_val = g_object_ref (pixbuf);
+ goto out;
+ }
+
+ ret_val = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size);
+ gdk_pixbuf_fill (ret_val, 0x00000000);
gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, ret_val, (size - width) / 2, (size - height) / 2);
+ out:
return ret_val;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]