From 71e61b13b287091480794bdb7ca2c395d2d6a42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Thu, 29 Sep 2011 13:12:40 +0200 Subject: [PATCH] Made zoomdiff an inline function --- image.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/image.c b/image.c index 4ea9b8d..9e73993 100644 --- a/image.c +++ b/image.c @@ -38,13 +38,17 @@ #include #endif -#define ZOOMDIFF(z1,z2) ((z1) - (z2) > 0.001 || (z1) - (z2) < -0.001) - enum { MIN_GIF_DELAY = 50 }; float zoom_min; float zoom_max; +static inline +bool zoomdiff(float z1, float z2) { + const float mindelta = 0.001; + return (z1 - z2 > mindelta) || (z1 - z2 < mindelta); +} + void img_init(img_t *img, win_t *win) { zoom_min = zoom_levels[0] / 100.0; zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0; @@ -394,7 +398,7 @@ bool img_fit(img_t *img) { z = MAX(z, zoom_min); z = MIN(z, zmax); - if (ZOOMDIFF(z, img->zoom)) { + if (zoomdiff(z, img->zoom)) { img->zoom = z; img->dirty = true; return true; @@ -511,7 +515,7 @@ bool img_zoom(img_t *img, float z) { img->scalemode = SCALE_ZOOM; - if (ZOOMDIFF(z, img->zoom)) { + if (zoomdiff(z, img->zoom)) { img->x = img->win->w / 2 - (img->win->w / 2 - img->x) * z / img->zoom; img->y = img->win->h / 2 - (img->win->h / 2 - img->y) * z / img->zoom; img->zoom = z;