gegl r2748 - in trunk: . gegl/buffer



Author: ok
Date: Fri Nov 14 18:18:49 2008
New Revision: 2748
URL: http://svn.gnome.org/viewvc/gegl?rev=2748&view=rev

Log:
* gegl/buffer/gegl-tile.[ch]: made gegl_tile_offset, gegl_tile_indice
and gegl_tile_get_data macros.


Modified:
   trunk/ChangeLog
   trunk/gegl/buffer/gegl-tile.c
   trunk/gegl/buffer/gegl-tile.h

Modified: trunk/gegl/buffer/gegl-tile.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile.c	(original)
+++ trunk/gegl/buffer/gegl-tile.c	Fri Nov 14 18:18:49 2008
@@ -380,12 +380,6 @@
   b->data = tmp;
 }
 
-unsigned char *
-gegl_tile_get_data (GeglTile *tile)
-{
-  return tile->data;
-}
-
 gboolean gegl_tile_store (GeglTile *tile)
 {
   if (gegl_tile_is_stored (tile))
@@ -399,32 +393,6 @@
                                     tile);
 }
 
-/* compute the tile indice of a coordinate
- * the stride is the width/height of tiles along the axis of coordinate
- */
-gint
-gegl_tile_indice (gint coordinate,
-                  gint stride)
-{
-  if (coordinate >= 0)
-    return coordinate / stride;
-  return (((coordinate + 1) / stride) - 1);
-}
 
-/* computes the positive integer remainder (also for negative dividends)
- */
-#define REMAINDER(dividend, divisor) \
-                   (((dividend) < 0) ? \
-                    (divisor) - 1 - ((-((dividend) + 1)) % (divisor)) : \
-                    (dividend) % (divisor))
 
 
-/* compute the offset into the containing tile a coordinate has,
- * the stride is the width/height of tiles along the axis of coordinate
- */
-gint
-gegl_tile_offset (gint coordinate,
-                  gint stride)
-{
-  return REMAINDER (coordinate, stride);
-}

Modified: trunk/gegl/buffer/gegl-tile.h
==============================================================================
--- trunk/gegl/buffer/gegl-tile.h	(original)
+++ trunk/gegl/buffer/gegl-tile.h	Fri Nov 14 18:18:49 2008
@@ -86,7 +86,8 @@
 void         gegl_tile_lock       (GeglTile *tile);
 /* get a pointer to the linear buffer of the tile.
  */
-guchar     * gegl_tile_get_data   (GeglTile *tile);
+#define gegl_tile_get_data(tile)  ((guchar*)((tile)->data))
+
 /* unlock the tile notifying the tile that we're done manipulating
  * the data.
  */
@@ -99,14 +100,22 @@
 void         gegl_tile_void       (GeglTile *tile);
 GeglTile    *gegl_tile_dup        (GeglTile *tile);
 
+/* computes the positive integer remainder (also for negative dividends)
+ */
+#define GEGL_REMAINDER(dividend, divisor) \
+                   (((dividend) < 0) ? \
+                    (divisor) - 1 - ((-((dividend) + 1)) % (divisor)) : \
+                    (dividend) % (divisor))
+
+#define gegl_tile_offset(coordinate, stride) GEGL_REMAINDER((coordinate), (stride))
 
-/* helper functions to compute tile indices and offsets for coordinates
+/* helper function to compute tile indices and offsets for coordinates
  * based on a tile stride (tile_width or tile_height)
  */
-gint         gegl_tile_indice     (gint      coordinate,
-                                   gint      stride);
-gint         gegl_tile_offset     (gint      coordinate,
-                                   gint      stride);
+#define gegl_tile_indice(coordinate,stride) \
+  (((coordinate) >= 0)?\
+      (coordinate) / (stride):\
+      ((((coordinate) + 1) /(stride)) - 1))
 
 /* utility low-level functions used by undo system */
 void         gegl_tile_swp        (GeglTile *a,



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