From dbb6e0ba03d3e049e0c33ab784740e2b4123663d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Wed, 22 Jul 2015 12:39:16 +0300 Subject: daemon: refactor scale_factor calculation Avoid problematic comparison between two floats, remove two unneeded variables and in general reduce the amount of work in that function --- src/daemon/daemon.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 3eac838..9011588 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -1123,25 +1123,13 @@ static GdkPixbuf* _notify_daemon_scale_pixbuf(GdkPixbuf *pixbuf, gboolean no_str { int pw; int ph; - float scale_factor_x = 1.0; - float scale_factor_y = 1.0; float scale_factor = 1.0; pw = gdk_pixbuf_get_width (pixbuf); ph = gdk_pixbuf_get_height (pixbuf); /* Determine which dimension requires the smallest scale. */ - scale_factor_x = (float) IMAGE_SIZE / (float) pw; - scale_factor_y = (float) IMAGE_SIZE / (float) ph; - - if (scale_factor_x > scale_factor_y) - { - scale_factor = scale_factor_y; - } - else - { - scale_factor = scale_factor_x; - } + scale_factor = (float) IMAGE_SIZE / (float) MAX(pw, ph); /* always scale down, allow to disable scaling up */ if (scale_factor < 1.0 || !no_stretch_hint) -- cgit v1.2.1