[gegl] buffer: simplify gegl_tile_indice since arg 3 is always 0



commit b500f7b703796e9f2365908a8725fc7af4f9c07b
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Feb 10 21:35:48 2017 +0100

    buffer: simplify gegl_tile_indice since arg 3 is always 0

 gegl/buffer/gegl-buffer-access.c   |   32 ++++++++++++++++----------------
 gegl/buffer/gegl-buffer-iterator.c |   11 +++++------
 gegl/buffer/gegl-buffer-private.h  |    6 +++---
 gegl/buffer/gegl-buffer-save.c     |    4 ++--
 gegl/buffer/gegl-buffer.h          |    7 ++++---
 gegl/buffer/gegl-sampler-nearest.c |    4 ++--
 6 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 1f50399..e78f18c 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -123,8 +123,8 @@ gegl_buffer_get_pixel (GeglBuffer     *buffer,
     gint tile_height = buffer->tile_height;
     gint tiledy      = y + buffer->shift_y;
     gint tiledx      = x + buffer->shift_x;
-    gint indice_x    = gegl_tile_indice (tiledx, tile_width, 0);
-    gint indice_y    = gegl_tile_indice (tiledy, tile_height, 0);
+    gint indice_x    = gegl_tile_indice (tiledx, tile_width);
+    gint indice_y    = gegl_tile_indice (tiledy, tile_height);
 
     GeglTile *tile = buffer->tile_storage->hot_tile;
     const Babl *fish = NULL;
@@ -190,8 +190,8 @@ __gegl_buffer_set_pixel (GeglBuffer     *buffer,
     gint tile_height = buffer->tile_height;
     gint tiledy      = y + buffer->shift_y;
     gint tiledx      = x + buffer->shift_x;
-    gint indice_x    = gegl_tile_indice (tiledx, tile_width, 0);
-    gint indice_y    = gegl_tile_indice (tiledy, tile_height, 0);
+    gint indice_x    = gegl_tile_indice (tiledx, tile_width);
+    gint indice_y    = gegl_tile_indice (tiledy, tile_height);
 
     GeglTile *tile = buffer->tile_storage->hot_tile;
     const Babl *fish = NULL;
@@ -399,8 +399,8 @@ gegl_buffer_iterate_write (GeglBuffer          *buffer,
           else
             pixels = tile_width - offsetx;
 
-          index_x = gegl_tile_indice (tiledx, tile_width, 0);
-          index_y = gegl_tile_indice (tiledy, tile_height, 0);
+          index_x = gegl_tile_indice (tiledx, tile_width);
+          index_y = gegl_tile_indice (tiledy, tile_height);
 
           tile = gegl_buffer_get_tile (buffer, index_x, index_y, level);
 
@@ -598,8 +598,8 @@ gegl_buffer_iterate_read_simple (GeglBuffer          *buffer,
             pixels = tile_width - offsetx;
 
           tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
-                                            gegl_tile_indice (tiledx, tile_width, 0),
-                                            gegl_tile_indice (tiledy, tile_height, 0),
+                                            gegl_tile_indice (tiledx, tile_width),
+                                            gegl_tile_indice (tiledy, tile_height),
                                             level);
 
           if (!tile)
@@ -968,8 +968,8 @@ gegl_buffer_iterate_read_abyss_loop (GeglBuffer          *buffer,
   gint          origin_x;
 
   /* Loop abyss works like iterating over a grid of tiles the size of the abyss */
-  gint loop_chunk_ix = gegl_tile_indice (roi->x - abyss->x, abyss->width, 0);
-  gint loop_chunk_iy = gegl_tile_indice (roi->y - abyss->y, abyss->height, 0);
+  gint loop_chunk_ix = gegl_tile_indice (roi->x - abyss->x, abyss->width);
+  gint loop_chunk_iy = gegl_tile_indice (roi->y - abyss->y, abyss->height);
 
   current_roi.x = loop_chunk_ix * abyss->width  + abyss->x;
   current_roi.y = loop_chunk_iy * abyss->height + abyss->y;
@@ -1686,10 +1686,10 @@ gegl_buffer_copy (GeglBuffer          *src,
                 src_x = dst_x - (dst_rect->x - src_rect->x) + src->shift_x;
                 src_y = dst_y - (dst_rect->y - src_rect->y) + src->shift_y;
 
-                stx = gegl_tile_indice (src_x, tile_width, 0);
-                sty = gegl_tile_indice (src_y, tile_height, 0);
-                dtx = gegl_tile_indice (dst_x, tile_width, 0);
-                dty = gegl_tile_indice (dst_y, tile_height, 0);
+                stx = gegl_tile_indice (src_x, tile_width);
+                sty = gegl_tile_indice (src_y, tile_height);
+                dtx = gegl_tile_indice (dst_x, tile_width);
+                dty = gegl_tile_indice (dst_y, tile_height);
 
                 src_tile = gegl_buffer_get_tile (src, stx, sty, 0);
 
@@ -1857,8 +1857,8 @@ gegl_buffer_clear (GeglBuffer          *dst,
               {
                 gint dtx, dty;
 
-                dtx = gegl_tile_indice (dst_x, tile_width, 0);
-                dty = gegl_tile_indice (dst_y, tile_height, 0);
+                dtx = gegl_tile_indice (dst_x, tile_width);
+                dty = gegl_tile_indice (dst_y, tile_height);
 
                 gegl_tile_source_void ((GeglTileSource*)dst, dtx, dty, 0);
               }
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index feef676..94151a3 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -122,7 +122,6 @@ gegl_buffer_iterator_add (GeglBufferIterator  *iter,
                           GeglAccessMode       access_mode,
                           GeglAbyssPolicy      abyss_policy)
 {
-  GeglRectangle roi2;
   GeglBufferIteratorPriv *priv = iter->priv;
   int                     index;
   SubIterState           *sub;
@@ -229,8 +228,8 @@ retile_subs (GeglBufferIterator *iter,
   int shift_x = priv->origin_tile.x;
   int shift_y = priv->origin_tile.y;
 
-  int tile_x = gegl_tile_indice (x + shift_x, priv->origin_tile.width, 0);
-  int tile_y = gegl_tile_indice (y + shift_y, priv->origin_tile.height, 0);
+  int tile_x = gegl_tile_indice (x + shift_x, priv->origin_tile.width);
+  int tile_y = gegl_tile_indice (y + shift_y, priv->origin_tile.height);
 
   /* Reset tile size */
   real_roi.x = (tile_x * priv->origin_tile.width)  - shift_x;
@@ -322,8 +321,8 @@ get_tile (GeglBufferIterator *iter,
       int tile_width  = buf->tile_width;
       int tile_height = buf->tile_height;
 
-      int tile_x = gegl_tile_indice (iter->roi[index].x + shift_x, tile_width, 0);
-      int tile_y = gegl_tile_indice (iter->roi[index].y + shift_y, tile_height, 0);
+      int tile_x = gegl_tile_indice (iter->roi[index].x + shift_x, tile_width);
+      int tile_y = gegl_tile_indice (iter->roi[index].y + shift_y, tile_height);
 
       sub->current_tile = gegl_buffer_get_tile (buf, tile_x, tile_y, sub->level);
 
@@ -438,7 +437,7 @@ prepare_iteration (GeglBufferIterator *iter)
       /* Format converison needed */
       if (gegl_buffer_get_format (sub->buffer) != sub->format)
         sub->access_mode |= GEGL_ITERATOR_INCOMPATIBLE;
-      /* Incompatable tiles */
+      /* Incompatiable tiles */
       else if ((priv->origin_tile.width  != buf->tile_width) ||
                (priv->origin_tile.height != buf->tile_height) ||
                (abs(origin_offset_x - current_offset_x) % priv->origin_tile.width != 0) ||
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 3cb4264..0bccfdb 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -213,9 +213,9 @@ gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
 /* helper function to compute tile indices and offsets for coordinates
  * based on a tile stride (tile_width or tile_height)
  */
-#define gegl_tile_indice(coordinate,stride,level) \
+#define gegl_tile_indice(coordinate,stride) \
   (((coordinate) >= 0)?\
-      ((coordinate)>>level) / (stride):\
-      (((((coordinate)>>level) + 1) /(stride)) - 1))
+      (coordinate) / (stride):\
+      ((((coordinate) + 1) /(stride)) - 1))
 
 #endif
diff --git a/gegl/buffer/gegl-buffer-save.c b/gegl/buffer/gegl-buffer-save.c
index 16020e0..ce0cbdd 100644
--- a/gegl/buffer/gegl-buffer-save.c
+++ b/gegl/buffer/gegl-buffer-save.c
@@ -263,8 +263,8 @@ gegl_buffer_save (GeglBuffer          *buffer,
                 gint tiledx  = roi->x + bufx;
                 gint offsetx = gegl_tile_offset (tiledx, tile_width);
 
-                gint tx = gegl_tile_indice (tiledx / factor, tile_width, z);
-                gint ty = gegl_tile_indice (tiledy / factor, tile_height, z);
+                gint tx = gegl_tile_indice (tiledx / factor, tile_width);
+                gint ty = gegl_tile_indice (tiledy / factor, tile_height);
 
                 if (gegl_tile_source_exist (GEGL_TILE_SOURCE (buffer), tx, ty, z))
                   {
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 9875d48..a7b9fb1 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -246,6 +246,7 @@ gboolean          gegl_buffer_set_abyss      (GeglBuffer          *buffer,
  * data is converted to the desired BablFormat, if the BablFormat stored and
  * fetched is the same this amounts to a series of memcpy's aligned to demux
  * the tile structure into a linear buffer.
+ *
  */
 void            gegl_buffer_get               (GeglBuffer          *buffer,
                                                const GeglRectangle *rect,
@@ -259,9 +260,9 @@ void            gegl_buffer_get               (GeglBuffer          *buffer,
  * gegl_buffer_set: (skip)
  * @buffer: the buffer to modify.
  * @rect: the coordinates we want to change the data of and the width/height of
- * the linear buffer being set, scale specifies the scaling factor applied to
+ * the linear buffer being set.
  * the data when setting.
- * @scale_level: the scale level being set, 0 = 1:1 = default = base mipmap level,
+ * @mipmap_level: the scale level being set, 0 = 1:1 = default = base mipmap level,
  * 1 = 1:2, 2=1:4, 3=1:8 ..
  * @format: the babl_format the linear buffer @src.
  * @src: linear buffer of image data to be stored in @buffer.
@@ -272,7 +273,7 @@ void            gegl_buffer_get               (GeglBuffer          *buffer,
  */
 void            gegl_buffer_set               (GeglBuffer          *buffer,
                                                const GeglRectangle *rect,
-                                               gint                 scale_level,
+                                               gint                 mipmap_level,
                                                const Babl          *format,
                                                const void          *src,
                                                gint                 rowstride);
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index f17c031..f610951 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -139,8 +139,8 @@ gegl_sampler_get_pixel (GeglSampler    *sampler,
     gint tile_height = buffer->tile_height;
     gint tiledy      = y + buffer->shift_y;
     gint tiledx      = x + buffer->shift_x;
-    gint indice_x    = gegl_tile_indice (tiledx, tile_width, 0);
-    gint indice_y    = gegl_tile_indice (tiledy, tile_height, 0);
+    gint indice_x    = gegl_tile_indice (tiledx, tile_width);
+    gint indice_y    = gegl_tile_indice (tiledy, tile_height);
 
     GeglTile *tile = buffer->tile_storage->hot_tile;
 


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