[gegl] Move FAST_PSEUDO_FLOOR macro definition to gegl-buffer-private.h



commit e9673d8ed2376c7449fa72490a1b11002b615ab1
Author: Nicolas Robidoux <nrobidoux git gnome org>
Date:   Sun Nov 18 15:40:17 2012 -0500

    Move FAST_PSEUDO_FLOOR macro definition to gegl-buffer-private.h

 gegl/buffer/gegl-buffer-private.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 45445a9..439f28c 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -209,6 +209,27 @@ gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
                     (divisor) - 1 - ((-((dividend) + 1)) % (divisor)) : \
                     (dividend) % (divisor))
 
+/*
+ * FAST_PSEUDO_FLOOR is a floor replacement which has been found to be
+ * faster. It returns the floor of its argument unless the argument is
+ * a negative integer, in which case it returns one less than the
+ * floor. For example:
+ *
+ * FAST_PSEUDO_FLOOR(0.5) = 0
+ *
+ * FAST_PSEUDO_FLOOR(0.) = 0
+ *
+ * FAST_PSEUDO_FLOOR(-.5) = -1
+ *
+ * as expected, but
+ *
+ * FAST_PSEUDO_FLOOR(-1.) = -2
+ *
+ * The discontinuities of FAST_PSEUDO_FLOOR are on the right of
+ * negative numbers instead of on the left as is the case for floor.
+ */
+#define GEGL_FAST_PSEUDO_FLOOR(x) ( (gint) (x) - (gint) ( (gdouble) (x) < 0. ) )
+
 #define gegl_tile_offset(coordinate, stride) GEGL_REMAINDER((coordinate), (stride))
 
 /* helper function to compute tile indices and offsets for coordinates



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]