[gegl] buffer: factor out level to scale computation



commit 92c0b7833a656c699a04e65b36960da5bf1fe518
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Feb 2 15:04:03 2017 +0100

    buffer: factor out level to scale computation

 gegl/buffer/gegl-buffer-iterator.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 00e4e53..4a99892 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -305,7 +305,7 @@ increment_rects (GeglBufferIterator *iter)
 
 static void
 get_tile (GeglBufferIterator *iter,
-          int        index)
+          int                 index)
 {
   GeglBufferIteratorPriv *priv = iter->priv;
   SubIterState           *sub  = &priv->sub_iter[index];
@@ -349,6 +349,12 @@ get_tile (GeglBufferIterator *iter,
   iter->data[index] = gegl_tile_get_data (sub->current_tile);
 }
 
+static inline double
+level_to_scale (int level)
+{
+  return level?1.0/(1<<level):1.0;
+}
+
 static void
 get_indirect (GeglBufferIterator *iter,
               int        index)
@@ -360,7 +366,7 @@ get_indirect (GeglBufferIterator *iter,
 
   if (sub->access_mode & GEGL_ACCESS_READ)
     {
-      gegl_buffer_get_unlocked (sub->buffer, sub->level?1.0/(1<<sub->level):1.0, &sub->real_roi, 
sub->format, sub->real_data,
+      gegl_buffer_get_unlocked (sub->buffer, level_to_scale (sub->level), &sub->real_roi, sub->format, 
sub->real_data,
                                 GEGL_AUTO_ROWSTRIDE, sub->abyss_policy);
     }
 


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