Made zoomdiff an inline function

This commit is contained in:
Bert Münnich 2011-09-29 13:12:40 +02:00
parent 8dcf682de9
commit 71e61b13b2

12
image.c
View File

@ -38,13 +38,17 @@
#include <gif_lib.h> #include <gif_lib.h>
#endif #endif
#define ZOOMDIFF(z1,z2) ((z1) - (z2) > 0.001 || (z1) - (z2) < -0.001)
enum { MIN_GIF_DELAY = 50 }; enum { MIN_GIF_DELAY = 50 };
float zoom_min; float zoom_min;
float zoom_max; 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) { void img_init(img_t *img, win_t *win) {
zoom_min = zoom_levels[0] / 100.0; zoom_min = zoom_levels[0] / 100.0;
zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 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 = MAX(z, zoom_min);
z = MIN(z, zmax); z = MIN(z, zmax);
if (ZOOMDIFF(z, img->zoom)) { if (zoomdiff(z, img->zoom)) {
img->zoom = z; img->zoom = z;
img->dirty = true; img->dirty = true;
return true; return true;
@ -511,7 +515,7 @@ bool img_zoom(img_t *img, float z) {
img->scalemode = SCALE_ZOOM; 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->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->y = img->win->h / 2 - (img->win->h / 2 - img->y) * z / img->zoom;
img->zoom = z; img->zoom = z;