[gegl/pippin/wip/mipmap-prerenders: 2/4] add level parameter to gegl_iterator_api



commit ebbd09d72e4b6799df9ac79683f4579242c00974
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Sun Jun 5 03:15:12 2011 +0100

    add level parameter to gegl_iterator_api

 gegl/buffer/gegl-buffer-access.c                |    4 ++--
 gegl/buffer/gegl-buffer-iterator.c              |   21 +++++++++++++--------
 gegl/buffer/gegl-buffer-iterator.h              |    8 +++++++-
 gegl/operation/gegl-operation-point-composer.c  |    2 +-
 gegl/operation/gegl-operation-point-composer3.c |    2 +-
 gegl/operation/gegl-operation-point-filter.c    |    2 +-
 gegl/operation/gegl-operation-point-render.c    |    2 +-
 gegl/operation/gegl-operation.h                 |    3 +++
 operations/affine/affine.c                      |   22 ++++++++++++++--------
 operations/common/map-absolute.c                |    2 +-
 operations/common/map-relative.c                |    2 +-
 11 files changed, 45 insertions(+), 25 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index fa37f37..b7f7cde 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1154,7 +1154,7 @@ gegl_buffer_copy (GeglBuffer          *src,
       dest_rect_r.width = src_rect->width;
       dest_rect_r.height = src_rect->height;
 
-      i = gegl_buffer_iterator_new (dst, &dest_rect_r, dst->format, GEGL_BUFFER_WRITE);
+      i = gegl_buffer_iterator_new (dst, &dest_rect_r, dst->format, GEGL_BUFFER_WRITE, 0); /* XXX: is level 0 right? */
       read = gegl_buffer_iterator_add (i, src, src_rect, src->format, GEGL_BUFFER_READ);
       while (gegl_buffer_iterator_next (i))
         babl_process (fish, i->data[read], i->data[0], i->length);
@@ -1183,7 +1183,7 @@ gegl_buffer_clear (GeglBuffer          *dst,
   /* FIXME: this can be even further optimized by special casing it so
    * that fully voided tiles are dropped.
    */
-  i = gegl_buffer_iterator_new (dst, dst_rect, dst->format, GEGL_BUFFER_WRITE);
+  i = gegl_buffer_iterator_new (dst, dst_rect, dst->format, GEGL_BUFFER_WRITE, 0); /* XXX: should level be settable */
   while (gegl_buffer_iterator_next (i))
     {
       memset (((guchar*)(i->data[0])), 0, i->length * pxsize);
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index e0f8681..5a5a8eb 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -52,7 +52,7 @@ typedef struct GeglBufferTileIterator
   GeglRectangle  roi2;     /* the rectangular subregion of data
                             * in the buffer represented by this scan.
                             */
-
+  gint           level;
 } GeglBufferTileIterator;
 
 #define GEGL_BUFFER_SCAN_COMPATIBLE   128   /* should be integrated into enum */
@@ -82,7 +82,8 @@ typedef struct GeglBufferIterators
 static void      gegl_buffer_tile_iterator_init (GeglBufferTileIterator *i,
                                                  GeglBuffer             *buffer,
                                                  GeglRectangle           roi,
-                                                 gboolean                write);
+                                                 gboolean                write,
+                                                 gint                    level);
 static gboolean  gegl_buffer_tile_iterator_next (GeglBufferTileIterator *i);
 
 /*
@@ -114,7 +115,8 @@ static gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
 static void gegl_buffer_tile_iterator_init (GeglBufferTileIterator *i,
                                             GeglBuffer             *buffer,
                                             GeglRectangle           roi,
-                                            gboolean                write)
+                                            gboolean                write,
+                                            gint                    level)
 {
   g_assert (i);
   memset (i, 0, sizeof (GeglBufferTileIterator));
@@ -123,6 +125,7 @@ static void gegl_buffer_tile_iterator_init (GeglBufferTileIterator *i,
     g_error ("eeek");
   i->buffer = buffer;
   i->roi = roi;
+  i->level = level;
   i->next_row    = 0;
   i->next_col = 0;
   i->tile = NULL;
@@ -275,7 +278,7 @@ gegl_buffer_iterator_add (GeglBufferIterator  *iterator,
   if (self==0) /* The first buffer which is always scan aligned */
     {
       i->flags[self] |= GEGL_BUFFER_SCAN_COMPATIBLE;
-      gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0) );
+      gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0), iterator->level);
     }
   else
     {
@@ -287,7 +290,7 @@ gegl_buffer_iterator_add (GeglBufferIterator  *iterator,
                                        i->buffer[self], i->rect[self].x, i->rect[self].y))
         {
           i->flags[self] |= GEGL_BUFFER_SCAN_COMPATIBLE;
-          gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0));
+          gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0), iterator->level);
         }
     }
 
@@ -301,7 +304,7 @@ gegl_buffer_iterator_add (GeglBufferIterator  *iterator,
 }
 
 /* FIXME: we are currently leaking this buf pool, it should be
- * freeing it when gegl is uninitialized
+ * freed when gegl is uninitialized
  */
 
 typedef struct BufInfo {
@@ -404,7 +407,7 @@ gboolean gegl_buffer_iterator_next     (GeglBufferIterator *iterator)
                   i->flags[no] & GEGL_BUFFER_FORMAT_COMPATIBLE &&
                   i->roi[no].width == i->i[no].buffer->tile_storage->tile_width && (i->flags[no] & GEGL_BUFFER_FORMAT_COMPATIBLE))
                 {
-                   /* direct access */
+                   /* direct access, don't need to do anything */
 #if DEBUG_DIRECT
                    direct_write += i->roi[no].width * i->roi[no].height;
 #endif
@@ -535,9 +538,11 @@ gboolean gegl_buffer_iterator_next     (GeglBufferIterator *iterator)
 GeglBufferIterator *gegl_buffer_iterator_new (GeglBuffer          *buffer,
                                               const GeglRectangle *roi,
                                               const Babl          *format,
-                                              guint                flags)
+                                              guint                flags,
+                                              gint                 level)
 {
   GeglBufferIterator *i = (gpointer)g_slice_new0 (GeglBufferIterators);
+  i->level = level;
   gegl_buffer_iterator_add (i, buffer, roi, format, flags);
   return i;
 }
diff --git a/gegl/buffer/gegl-buffer-iterator.h b/gegl/buffer/gegl-buffer-iterator.h
index 68b2619..b374f56 100644
--- a/gegl/buffer/gegl-buffer-iterator.h
+++ b/gegl/buffer/gegl-buffer-iterator.h
@@ -33,6 +33,7 @@ typedef struct GeglBufferIterator
   gint          length;
   gpointer      data[GEGL_BUFFER_MAX_ITERATORS];
   GeglRectangle roi[GEGL_BUFFER_MAX_ITERATORS];
+  gint          level;
 } GeglBufferIterator;
 
 
@@ -42,6 +43,8 @@ typedef struct GeglBufferIterator
  * @roi: the rectangle to iterate over
  * @format: the format we want to process this buffers data in, pass 0 to use the buffers format.
  * @flags: whether we need reading or writing to this buffer one of GEGL_BUFFER_READ, GEGL_BUFFER_WRITE and GEGL_BUFFER_READWRITE.
+ * @level: the level at which we are iterating, the roi will indicate the
+ * extent at 1:1, x,y,width and height are/(2^level)
  *
  * Create a new buffer iterator, this buffer will be iterated through
  * in linear chunks, some chunks might be full tiles the coordinates, see
@@ -54,7 +57,10 @@ typedef struct GeglBufferIterator
 GeglBufferIterator * gegl_buffer_iterator_new  (GeglBuffer          *buffer,
                                                 const GeglRectangle *roi,
                                                 const Babl          *format,
-                                                guint                flags);
+                                                guint                flags,
+                                                gint                 level);   /* XXX: or encode it in flags? */
+/* should maybe be reporting the roi in process, as base image roi when level != 0 */
+
 
 /**
  * gegl_buffer_iterator_add:
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index a037b7c..0d70231 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -147,7 +147,7 @@ gegl_operation_point_composer_process (GeglOperation       *operation,
 
   if ((result->width > 0) && (result->height > 0))
     {
-      GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+      GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
       gint read = /*output == input ? 0 :*/ gegl_buffer_iterator_add (i, input,  result, in_format, GEGL_BUFFER_READ);
       /* using separate read and write iterators for in-place ideally a single
        * readwrite indice would be sufficient
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index f79d2cd..0101419 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -158,7 +158,7 @@ gegl_operation_point_composer3_process (GeglOperation       *operation,
 
   if ((result->width > 0) && (result->height > 0))
     {
-      GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+      GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
       gint read  = gegl_buffer_iterator_add (i, input,  result, in_format, GEGL_BUFFER_READ);
 
       if (aux)
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 45aec1f..1b2354f 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -86,7 +86,7 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
     {
 
       {
-        GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+        GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
         gint read = /*output == input ? 0 :*/ gegl_buffer_iterator_add (i, input,  result, in_format, GEGL_BUFFER_READ);
         /* using separate read and write iterators for in-place ideally a single
          * readwrite indice would be sufficient
diff --git a/gegl/operation/gegl-operation-point-render.c b/gegl/operation/gegl-operation-point-render.c
index f822e3b..a98aa1f 100644
--- a/gegl/operation/gegl-operation-point-render.c
+++ b/gegl/operation/gegl-operation-point-render.c
@@ -97,7 +97,7 @@ gegl_operation_point_render_process (GeglOperation       *operation,
 
   if ((result->width > 0) && (result->height > 0))
     {
-      GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+      GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
 
       while (gegl_buffer_iterator_next (i))
           point_render_class->process (operation, i->data[0], i->length, &i->roi[0], level);
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index c2245eb..45b8ed3 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -64,6 +64,9 @@ struct _GeglOperation
 
 #define MAX_PROCESSOR 4
 
+/* the level at which is being operated is stored in the context,
+*/
+
 void gegl_operation_class_add_processor (GeglOperationClass *cclass,
                                          GCallback           process,
                                          const gchar        *string);
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index b70fe12..ffffd50 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -90,11 +90,13 @@ static gboolean      gegl_affine_matrix3_allow_fast_reflect_y      (GeglMatrix3
 static void          gegl_affine_fast_reflect_x            (GeglBuffer           *dest,
                                                             GeglBuffer           *src,
                                                             const GeglRectangle  *dest_rect,
-                                                            const GeglRectangle  *src_rect);
+                                                            const GeglRectangle  *src_rect,
+                                                            gint                  level);
 static void          gegl_affine_fast_reflect_y            (GeglBuffer           *dest,
                                                             GeglBuffer           *src,
                                                             const GeglRectangle  *dest_rect,
-                                                            const GeglRectangle  *src_rect);
+                                                            const GeglRectangle  *src_rect,
+                                                            gint                  level);
 
 
 /* ************************* */
@@ -638,7 +640,8 @@ static void
 affine_generic (GeglBuffer  *dest,
                 GeglBuffer  *src,
                 GeglMatrix3 *matrix,
-                GeglSampler *sampler)
+                GeglSampler *sampler,
+                gint         level)
 {
   GeglBufferIterator *i;
   const GeglRectangle *dest_extent;
@@ -666,7 +669,7 @@ affine_generic (GeglBuffer  *dest,
   dest_extent = gegl_buffer_get_extent (dest);
 
 
-  i = gegl_buffer_iterator_new (dest, dest_extent, format, GEGL_BUFFER_WRITE);
+  i = gegl_buffer_iterator_new (dest, dest_extent, format, GEGL_BUFFER_WRITE, level);
   while (gegl_buffer_iterator_next (i))
     {
       GeglRectangle *roi = &i->roi[0];
@@ -744,7 +747,8 @@ static void
 gegl_affine_fast_reflect_x (GeglBuffer              *dest,
                             GeglBuffer              *src,
                             const GeglRectangle     *dest_rect,
-                            const GeglRectangle     *src_rect)
+                            const GeglRectangle     *src_rect,
+                            gint                     level)
 {
   const Babl              *format = gegl_buffer_get_format (src);
   const gint               px_size = babl_format_get_bytes_per_pixel (format),
@@ -780,7 +784,8 @@ static void
 gegl_affine_fast_reflect_y (GeglBuffer              *dest,
                             GeglBuffer              *src,
                             const GeglRectangle     *dest_rect,
-                            const GeglRectangle     *src_rect)
+                            const GeglRectangle     *src_rect,
+                            gint                     level)
 {
   const Babl              *format = gegl_buffer_get_format (src);
   const gint               px_size = babl_format_get_bytes_per_pixel (format),
@@ -896,7 +901,7 @@ gegl_affine_process (GeglOperation        *operation,
       src_rect.width -= context_rect.width;
       src_rect.height -= context_rect.height;
 
-      gegl_affine_fast_reflect_x (output, input, result, &src_rect);
+      gegl_affine_fast_reflect_x (output, input, result, &src_rect, context->level);
 
       if (input != NULL)
         g_object_unref (input);
@@ -926,7 +931,7 @@ gegl_affine_process (GeglOperation        *operation,
       src_rect.width -= context_rect.width;
       src_rect.height -= context_rect.height;
 
-      gegl_affine_fast_reflect_y (output, input, result, &src_rect);
+      gegl_affine_fast_reflect_y (output, input, result, &src_rect, context->level);
 
       if (input != NULL)
         g_object_unref (input);
@@ -942,6 +947,7 @@ gegl_affine_process (GeglOperation        *operation,
       sampler = gegl_buffer_sampler_new (input, babl_format("RaGaBaA float"),
           gegl_sampler_type_from_string (affine->filter));
       affine_generic (output, input, &matrix, sampler);
+
       g_object_unref (sampler);
 
       if (input != NULL)
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index 6d151c2..865c1af 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -70,7 +70,7 @@ process (GeglOperation       *operation,
 
   if (aux != NULL)
     {
-      it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE);
+      it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE, level);
       index_out = 0;
 
       index_coords = gegl_buffer_iterator_add (it, aux, result, format_coords, GEGL_BUFFER_READ);
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index 4d90d0b..a3a65e5 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -76,7 +76,7 @@ process (GeglOperation       *operation,
 
   if (aux != NULL)
     {
-      it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE);
+      it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE, level);
       index_out = 0;
 
       index_coords = gegl_buffer_iterator_add (it, aux, result, format_coords, GEGL_BUFFER_READ);



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