[gegl] sampler: add level argument to api calls



commit bf997009eedb6abd5d658714f89a461778372b97
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Jul 3 02:13:17 2014 +0200

    sampler: add level argument to api calls

 gegl/buffer/gegl-buffer.h               |   17 ++++++++
 gegl/buffer/gegl-sampler.c              |   67 ++++++++++++++++++++++++++-----
 gegl/buffer/gegl-sampler.h              |    1 +
 operations/common/c2g.c                 |    8 ++-
 operations/common/cartoon.c             |   10 +++--
 operations/common/cubism.c              |    2 +-
 operations/common/fractal-trace.c       |   15 ++++---
 operations/common/lens-distortion.c     |    8 ++-
 operations/common/map-absolute.c        |    2 +-
 operations/common/map-relative.c        |    2 +-
 operations/common/mirrors.c             |    8 ++-
 operations/common/noise-pick.c          |    3 +-
 operations/common/noise-slur.c          |    3 +-
 operations/common/noise-spread.c        |    2 +-
 operations/common/panorama-projection.c |    3 +-
 operations/common/plasma.c              |   33 ++++++++-------
 operations/common/polar-coordinates.c   |    5 +-
 operations/common/ripple.c              |    5 +-
 operations/common/stress.c              |    7 ++-
 operations/common/waves.c               |    5 +-
 operations/common/whirl-pinch.c         |   10 +++--
 operations/transform/transform-core.c   |   21 ++++++----
 perf/test-samplers.c                    |    2 +-
 23 files changed, 164 insertions(+), 75 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 1d9ff47..838124c 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -409,6 +409,17 @@ GeglBuffer *    gegl_buffer_dup               (GeglBuffer       *buffer);
  * of interpolation. The samplers used cache for a small neighbourhood of the
  * buffer for more efficient access.
  */
+
+void              gegl_buffer_sample_at_level (GeglBuffer       *buffer,
+                                               gdouble           x,
+                                               gdouble           y,
+                                               GeglMatrix2      *scale,
+                                               gpointer          dest,
+                                               const Babl       *format,
+                                               gint              level,
+                                               GeglSamplerType   sampler_type,
+                                               GeglAbyssPolicy   repeat_mode);
+
 void              gegl_buffer_sample          (GeglBuffer       *buffer,
                                                gdouble           x,
                                                gdouble           y,
@@ -460,6 +471,12 @@ GeglSampler *    gegl_buffer_sampler_new      (GeglBuffer       *buffer,
                                                const Babl       *format,
                                                GeglSamplerType   sampler_type);
 
+GeglSampler *    gegl_buffer_sampler_new_at_level (GeglBuffer       *buffer,
+                                               const Babl       *format,
+                                               GeglSamplerType   sampler_type,
+                                               gint              level);
+
+
 /**
  * gegl_sampler_get:
  * @sampler: a GeglSampler gotten from gegl_buffer_sampler_new
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index fd4120b..5276c9e 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -42,6 +42,7 @@ enum
   PROP_0,
   PROP_BUFFER,
   PROP_FORMAT,
+  PROP_LEVEL,
   PROP_CONTEXT_RECT,
   PROP_LAST
 };
@@ -99,6 +100,15 @@ gegl_sampler_class_init (GeglSamplerClass *klass)
                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
   g_object_class_install_property (
+                 object_class,
+                 PROP_LEVEL,
+                 g_param_spec_int ("level",
+                                   "level",
+                                   "mimmap level to sample from",
+                                   0, 100, 0,
+                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (
                    object_class,
                    PROP_BUFFER,
                    g_param_spec_object ("buffer",
@@ -391,6 +401,10 @@ get_property (GObject    *object,
         g_value_set_pointer (value, (void*)self->format);
         break;
 
+      case PROP_LEVEL:
+        g_value_set_int (value, self->lvel);
+        break;
+
       default:
         break;
     }
@@ -414,6 +428,10 @@ set_property (GObject      *object,
         self->format = g_value_get_pointer (value);
         break;
 
+      case PROP_LEVEL:
+        self->lvel = g_value_get_int  (value);
+        break;
+
       default:
         break;
     }
@@ -469,14 +487,15 @@ gegl_sampler_gtype_from_enum (GeglSamplerType sampler_type)
 }
 
 void
-gegl_buffer_sample (GeglBuffer       *buffer,
-                    gdouble           x,
-                    gdouble           y,
-                    GeglMatrix2      *scale,
-                    gpointer          dest,
-                    const Babl       *format,
-                    GeglSamplerType   sampler_type,
-                    GeglAbyssPolicy   repeat_mode)
+gegl_buffer_sample_at_level (GeglBuffer       *buffer,
+                             gdouble           x,
+                             gdouble           y,
+                             GeglMatrix2      *scale,
+                             gpointer          dest,
+                             const Babl       *format,
+                             gint              level,
+                             GeglSamplerType   sampler_type,
+                             GeglAbyssPolicy   repeat_mode)
 {
   GType desired_type;
   /*
@@ -519,6 +538,7 @@ gegl_buffer_sample (GeglBuffer       *buffer,
       buffer->sampler = g_object_new (desired_type,
                                       "buffer", buffer,
                                       "format", format,
+                                      "level", level,
                                       NULL);
       buffer->sampler_format = format;
       gegl_sampler_prepare (buffer->sampler);
@@ -528,10 +548,25 @@ gegl_buffer_sample (GeglBuffer       *buffer,
   g_mutex_unlock (&mutex);
 }
 
+
+void
+gegl_buffer_sample (GeglBuffer       *buffer,
+                    gdouble           x,
+                    gdouble           y,
+                    GeglMatrix2      *scale,
+                    gpointer          dest,
+                    const Babl       *format,
+                    GeglSamplerType   sampler_type,
+                    GeglAbyssPolicy   repeat_mode)
+{
+  gegl_buffer_sample_at_level (buffer, x, y, scale, dest, format, 0, sampler_type, repeat_mode);
+}
+
 GeglSampler *
-gegl_buffer_sampler_new (GeglBuffer      *buffer,
-                         const Babl      *format,
-                         GeglSamplerType  sampler_type)
+gegl_buffer_sampler_new_at_level (GeglBuffer      *buffer,
+                                  const Babl      *format,
+                                  GeglSamplerType  sampler_type,
+                                  gint             level)
 {
   GeglSampler *sampler;
   GType        desired_type;
@@ -544,6 +579,7 @@ gegl_buffer_sampler_new (GeglBuffer      *buffer,
   sampler = g_object_new (desired_type,
                           "buffer", buffer,
                           "format", format,
+                          "level", level,
                           NULL);
 
   gegl_sampler_prepare (sampler);
@@ -551,6 +587,15 @@ gegl_buffer_sampler_new (GeglBuffer      *buffer,
   return sampler;
 }
 
+GeglSampler *
+gegl_buffer_sampler_new (GeglBuffer      *buffer,
+                         const Babl      *format,
+                         GeglSamplerType  sampler_type)
+{
+  return gegl_buffer_sampler_new_at_level (buffer, format, sampler_type, 0);
+}
+
+
 const GeglRectangle*
 gegl_sampler_get_context_rect (GeglSampler *sampler)
 {
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 114b138..afb1844 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -68,6 +68,7 @@ struct _GeglSampler
 
   /*< private >*/
   GeglBuffer    *buffer;
+  gint           lvel;
   const Babl    *format;
   const Babl    *interpolate_format;
   const Babl    *fish;
diff --git a/operations/common/c2g.c b/operations/common/c2g.c
index 9881d6d..74e9b5c 100644
--- a/operations/common/c2g.c
+++ b/operations/common/c2g.c
@@ -67,7 +67,8 @@ static void c2g (GeglBuffer          *src,
                  gint                 radius,
                  gint                 samples,
                  gint                 iterations,
-                 gdouble              rgamma)
+                 gdouble              rgamma,
+                 gint                 level)
 {
   const Babl *format = babl_format ("RGBA float");
 
@@ -75,7 +76,7 @@ static void c2g (GeglBuffer          *src,
   {
     GeglBufferIterator *i = gegl_buffer_iterator_new (dst, dst_rect, 0, babl_format("YA float"),
                                                       GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
-    GeglSampler *sampler = gegl_buffer_sampler_new (src, format, GEGL_SAMPLER_NEAREST);
+    GeglSampler *sampler = gegl_buffer_sampler_new_at_level (src, format, GEGL_SAMPLER_NEAREST, level);
 
     while (gegl_buffer_iterator_next (i))
     {
@@ -330,7 +331,8 @@ process (GeglOperation       *operation,
        o->radius,
        o->samples,
        o->iterations,
-       /*o->rgamma*/RGAMMA);
+       /*o->rgamma*/RGAMMA,
+       level);
 
   return  TRUE;
 }
diff --git a/operations/common/cartoon.c b/operations/common/cartoon.c
index 7f1d25c..d831cff 100644
--- a/operations/common/cartoon.c
+++ b/operations/common/cartoon.c
@@ -227,13 +227,15 @@ process (GeglOperation       *operation,
 
   grey_blur_buffer (input, o->mask_radius, &dest1, &dest2);
 
-  sampler1 = gegl_buffer_sampler_new (dest1,
+  sampler1 = gegl_buffer_sampler_new_at_level (dest1,
                                       babl_format ("Y' float"),
-                                      GEGL_SAMPLER_LINEAR);
+                                      GEGL_SAMPLER_LINEAR,
+                                      level);
 
-  sampler2 = gegl_buffer_sampler_new (dest2,
+  sampler2 = gegl_buffer_sampler_new_at_level (dest2,
                                       babl_format ("Y' float"),
-                                      GEGL_SAMPLER_LINEAR);
+                                      GEGL_SAMPLER_LINEAR,
+                                      level);
 
   ramp = compute_ramp (sampler1, sampler2, result, o->pct_black);
 
diff --git a/operations/common/cubism.c b/operations/common/cubism.c
index 42cbc17..bbff130 100644
--- a/operations/common/cubism.c
+++ b/operations/common/cubism.c
@@ -533,7 +533,7 @@ process (GeglOperation       *operation,
       ix = CLAMP (x, boundary.x, boundary.x + boundary.width - 1);
       iy = CLAMP (y, boundary.y, boundary.y + boundary.height - 1);
 
-      gegl_buffer_sample (input, ix, iy, NULL, color, format,
+      gegl_buffer_sample_at_level (input, ix, iy, NULL, color, format, level,
                           GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
 
       fill_poly_color (&poly, &extended, &boundary, dst_buf, color);
diff --git a/operations/common/fractal-trace.c b/operations/common/fractal-trace.c
index 51d4452..7719aef 100644
--- a/operations/common/fractal-trace.c
+++ b/operations/common/fractal-trace.c
@@ -114,13 +114,15 @@ julia (gdouble  x,
 
 static void
 fractaltrace (GeglBuffer            *input,
+              GeglSampler           *sampler,
               const GeglRectangle   *picture,
               gfloat                *dst_buf,
               const GeglRectangle   *roi,
-              GeglProperties            *o,
+              GeglProperties        *o,
               gint                   y,
-              GeglFractalTraceType  fractal_type,
-              const Babl           *format)
+              GeglFractalTraceType   fractal_type,
+              const Babl            *format,
+              gint                   level)
 {
   GeglMatrix2  scale;        /* a matrix indicating scaling factors around the
                                 current center pixel.
@@ -129,7 +131,6 @@ fractaltrace (GeglBuffer            *input,
   gdouble      scale_x, scale_y;
   gdouble      bailout2;
   gfloat       dest[4];
-  GeglSampler *sampler = gegl_buffer_sampler_new (input, format, GEGL_SAMPLER_NOHALO);
 
   scale_x = (o->X2 - o->X1) / picture->width;
   scale_y = (o->Y2 - o->Y1) / picture->height;
@@ -183,7 +184,6 @@ fractaltrace (GeglBuffer            *input,
       for (i = 0; i < 4; i++)
         dst_buf[offset++] = dest[i];
     }
-  g_object_unref (sampler);
 }
 
 static gboolean
@@ -196,6 +196,7 @@ process (GeglOperation       *operation,
   GeglProperties    *o = GEGL_PROPERTIES (operation);
   GeglRectangle  boundary;
   const Babl    *format;
+  GeglSampler   *sampler;
   gfloat        *dst_buf;
   gint           y;
 
@@ -203,11 +204,13 @@ process (GeglOperation       *operation,
 
   format = babl_format ("RGBA float");
   dst_buf = g_new0 (gfloat, result->width * result->height * 4);
+  sampler = gegl_buffer_sampler_new_at_level (input, format, GEGL_SAMPLER_NOHALO, level);
 
   for (y = result->y; y < result->y + result->height; y++)
-    fractaltrace (input, &boundary, dst_buf, result, o, y, o->fractal, format);
+    fractaltrace (input, sampler, &boundary, dst_buf, result, o, y, o->fractal, format, level);
 
   gegl_buffer_set (output, result, 0, format, dst_buf, GEGL_AUTO_ROWSTRIDE);
+  g_object_unref (sampler);
 
   g_free (dst_buf);
 
diff --git a/operations/common/lens-distortion.c b/operations/common/lens-distortion.c
index 229df4a..b4d014a 100644
--- a/operations/common/lens-distortion.c
+++ b/operations/common/lens-distortion.c
@@ -331,7 +331,8 @@ lens_distort_func (gfloat              *src_buf,
                    gint                 xx,
                    gint                 yy,
                    GeglBuffer          *input,
-                   gfloat              *background)
+                   gfloat              *background,
+                   gint                 level)
 {
   gdouble sx, sy, mag;
   gdouble brighten;
@@ -379,8 +380,9 @@ lens_distort_func (gfloat              *src_buf,
                 }
               else
                 {
-                  gegl_buffer_sample (input, x, y, NULL, temp,
+                  gegl_buffer_sample_at_level (input, x, y, NULL, temp,
                                       babl_format ("RGBA float"),
+                                      level,
                                       GEGL_SAMPLER_LINEAR,
                                       GEGL_ABYSS_CLAMP);
                 }
@@ -448,7 +450,7 @@ process (GeglOperation       *operation,
           for (x = chunked_result.x; x < chunked_result.x + chunked_result.width; x++)
             {
               lens_distort_func (src_buf, dst_buf, &area, &chunked_result, &boundary,
-                                 &lens, x, y, input, background);
+                                 &lens, x, y, input, background, level);
             }
 
         gegl_buffer_set (output, &chunked_result, 0, babl_format ("RGBA float"),
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index 2028d2d..5b4a43b 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -70,7 +70,7 @@ process (GeglOperation       *operation,
   format_io = babl_format ("RGBA float");
   format_coords = babl_format_n (babl_type ("float"), 2);
 
-  sampler = gegl_buffer_sampler_new (input, format_io, o->sampler_type);
+  sampler = gegl_buffer_sampler_new_at_level (input, format_io, level, o->sampler_type);
 
   if (aux != NULL)
     {
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index 37cc9fd..d4dd75f 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -75,7 +75,7 @@ process (GeglOperation       *operation,
   format_io = babl_format ("RGBA float");
   format_coords = babl_format_n (babl_type ("float"), 2);
 
-  sampler = gegl_buffer_sampler_new (input, format_io, o->sampler_type);
+  sampler = gegl_buffer_sampler_new_at_level (input, format_io, o->sampler_type, level);
 
   if (aux != NULL)
     {
diff --git a/operations/common/mirrors.c b/operations/common/mirrors.c
index 42081ed..271d465 100644
--- a/operations/common/mirrors.c
+++ b/operations/common/mirrors.c
@@ -156,7 +156,8 @@ apply_mirror (double               mirror_angle,
               GeglRectangle       *in_boundary,
               GeglBuffer          *dst,
               GeglRectangle       *boundary,
-              const GeglRectangle *roi)
+              const GeglRectangle *roi,
+              gint                 level)
 {
   gfloat *dst_buf;
   gint    row, col;
@@ -265,7 +266,7 @@ apply_mirror (double               mirror_angle,
 
 
 #ifndef DO_NOT_USE_BUFFER_SAMPLE
-        gegl_buffer_sample (src, cx, cy, NULL, &dst_buf[(row * roi->width + col) * 4], format, 
GEGL_SAMPLER_LINEAR, GEGL_ABYSS_NONE);
+        gegl_buffer_sample_at_level (src, cx, cy, NULL, &dst_buf[(row * roi->width + col) * 4], format, 
level, GEGL_SAMPLER_LINEAR, GEGL_ABYSS_NONE);
 #endif
 
 #ifdef DO_NOT_USE_BUFFER_SAMPLE
@@ -404,7 +405,8 @@ process (GeglOperation       *operation,
                 &eff_boundary,
                 output,
                 &boundary,
-                result);
+                result,
+                level);
   return TRUE;
 }
 
diff --git a/operations/common/noise-pick.c b/operations/common/noise-pick.c
index 2ecd643..2f8ec92 100644
--- a/operations/common/noise-pick.c
+++ b/operations/common/noise-pick.c
@@ -114,7 +114,8 @@ process (GeglOperation       *operation,
                   }
               }
 
-            gegl_buffer_sample (input, pos_x, pos_y, NULL, data, format,
+            gegl_buffer_sample_at_level (input, pos_x, pos_y, NULL, data, format,
+                                level,
                                 GEGL_SAMPLER_NEAREST, GEGL_ABYSS_CLAMP);
             data += bpp;
           }
diff --git a/operations/common/noise-slur.c b/operations/common/noise-slur.c
index c9b4816..2cf3a18 100644
--- a/operations/common/noise-slur.c
+++ b/operations/common/noise-slur.c
@@ -126,7 +126,8 @@ process (GeglOperation       *operation,
                   }
               }
 
-            gegl_buffer_sample (input, pos_x, pos_y, NULL, data, format,
+            gegl_buffer_sample_at_level (input, pos_x, pos_y, NULL, data, format,
+                                level,
                                 GEGL_SAMPLER_NEAREST, GEGL_ABYSS_CLAMP);
             data += bpp;
           }
diff --git a/operations/common/noise-spread.c b/operations/common/noise-spread.c
index dcea31f..9c532e1 100644
--- a/operations/common/noise-spread.c
+++ b/operations/common/noise-spread.c
@@ -128,7 +128,7 @@ process (GeglOperation       *operation,
 
             calc_sample_coords (i, j, amount_x, amount_y, o->rand, &x, &y);
 
-            gegl_buffer_sample (input, x, y, NULL, data, format,
+            gegl_buffer_sample_at_level (input, x, y, NULL, data, format, level,
                                 GEGL_SAMPLER_NEAREST, GEGL_ABYSS_CLAMP);
             data += bpp;
           }
diff --git a/operations/common/panorama-projection.c b/operations/common/panorama-projection.c
index 9e5f95c..a206985 100644
--- a/operations/common/panorama-projection.c
+++ b/operations/common/panorama-projection.c
@@ -367,7 +367,8 @@ process (GeglOperation       *operation,
   prepare_transform2 (&transform, operation);
 
   format_io = babl_format ("RaGaBaA float");
-  sampler = gegl_buffer_sampler_new (input, format_io, o->sampler_type);
+  sampler = gegl_buffer_sampler_new_at_level (input, format_io, o->sampler_type,
+                                     level);
 
   if (o->sampler_type == GEGL_SAMPLER_NOHALO ||
       o->sampler_type == GEGL_SAMPLER_LOHALO)
diff --git a/operations/common/plasma.c b/operations/common/plasma.c
index b713799..033a464 100644
--- a/operations/common/plasma.c
+++ b/operations/common/plasma.c
@@ -171,7 +171,8 @@ do_plasma (PlasmaContext *context,
            gint           x2,
            gint           y2,
            gint           plasma_depth,
-           gint           recursion_depth)
+           gint           recursion_depth,
+           gint           level)
 {
   gfloat tl[3], ml[3], bl[3], mt[3], mm[3], mb[3], tr[3], mr[3], br[3];
   gfloat tmp[3];
@@ -198,7 +199,7 @@ do_plasma (PlasmaContext *context,
       context->buffer_y = y1;
       context->buffer_width = x2 - x1 + 1;
 
-      ret = do_plasma (context, x1, y1, x2, y2, plasma_depth, recursion_depth);
+      ret = do_plasma (context, x1, y1, x2, y2, plasma_depth, recursion_depth, level);
 
       context->using_buffer = FALSE;
 
@@ -248,17 +249,17 @@ do_plasma (PlasmaContext *context,
       if (x1 == x2 && y1 == y2)
         return FALSE;
 
-      gegl_buffer_sample (context->output, x1, y1, NULL, tl,
-                          babl_format ("R'G'B' float"),
+      gegl_buffer_sample_at_level (context->output, x1, y1, NULL, tl,
+                          babl_format ("R'G'B' float"), level,
                           GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
-      gegl_buffer_sample (context->output, x1, y2, NULL, bl,
-                          babl_format ("R'G'B' float"),
+      gegl_buffer_sample_at_level (context->output, x1, y2, NULL, bl,
+                          babl_format ("R'G'B' float"), level,
                           GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
-      gegl_buffer_sample (context->output, x2, y1, NULL, tr,
-                          babl_format ("R'G'B' float"),
+      gegl_buffer_sample_at_level (context->output, x2, y1, NULL, tr,
+                          babl_format ("R'G'B' float"), level,
                           GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
-      gegl_buffer_sample (context->output, x2, y2, NULL, br,
-                          babl_format ("R'G'B' float"),
+      gegl_buffer_sample_at_level (context->output, x2, y2, NULL, br,
+                          babl_format ("R'G'B' float"), level,
                           GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
 
       ran = context->o->turbulence / (2.0 * recursion_depth);
@@ -316,14 +317,14 @@ do_plasma (PlasmaContext *context,
   if (x1 < x2 || y1 < y2)
     {
       /* Top left. */
-      do_plasma (context, x1, y1, xm, ym, plasma_depth - 1, recursion_depth + 1);
+      do_plasma (context, x1, y1, xm, ym, plasma_depth - 1, recursion_depth + 1, level);
       /* Bottom left. */
-      do_plasma (context, x1, ym, xm, y2, plasma_depth - 1, recursion_depth + 1);
+      do_plasma (context, x1, ym, xm, y2, plasma_depth - 1, recursion_depth + 1, level);
       /* Top right. */
-      do_plasma (context, xm, y1, x2, ym, plasma_depth - 1, recursion_depth + 1);
+      do_plasma (context, xm, y1, x2, ym, plasma_depth - 1, recursion_depth + 1, level);
       /* Bottom right. */
       return do_plasma (context, xm, ym, x2, y2,
-                        plasma_depth - 1, recursion_depth + 1);
+                        plasma_depth - 1, recursion_depth + 1, level);
     }
 
   return TRUE;
@@ -360,13 +361,13 @@ process (GeglOperation       *operation,
 
   context->gr = g_rand_new_with_seed (context->o->seed);
 
-  do_plasma (context, result->x, result->y, x-1, y-1, -1, 0);
+  do_plasma (context, result->x, result->y, x-1, y-1, -1, 0, level);
 
   /*
    * Now we recurse through the images, going deeper each time
    */
   depth = 1;
-  while (!do_plasma (context, result->x, result->y, x-1, y-1, depth, 0))
+  while (!do_plasma (context, result->x, result->y, x-1, y-1, depth, 0, level))
     depth++;
 
   gegl_buffer_sample_cleanup (context->output);
diff --git a/operations/common/polar-coordinates.c b/operations/common/polar-coordinates.c
index 345bade..c5aab4b 100644
--- a/operations/common/polar-coordinates.c
+++ b/operations/common/polar-coordinates.c
@@ -323,8 +323,9 @@ process (GeglOperation       *operation,
   GeglProperties          *o            = GEGL_PROPERTIES (operation);
   GeglRectangle            boundary     = get_effective_area (operation);
   const Babl              *format       = babl_format ("RGBA float");
-  GeglSampler             *sampler      = gegl_buffer_sampler_new (
-                                    input, format, GEGL_SAMPLER_NOHALO);
+  GeglSampler             *sampler      = gegl_buffer_sampler_new_at_level (
+                                    input, format, GEGL_SAMPLER_NOHALO,
+                                    level);
 
   gint      x,y;
   gfloat   *src_buf, *dst_buf;
diff --git a/operations/common/ripple.c b/operations/common/ripple.c
index d9b2698..f2fa87b 100644
--- a/operations/common/ripple.c
+++ b/operations/common/ripple.c
@@ -91,9 +91,10 @@ process (GeglOperation       *operation,
          gint                 level)
 {
   GeglProperties         *o       = GEGL_PROPERTIES (operation);
-  GeglSampler        *sampler = gegl_buffer_sampler_new (input,
+  GeglSampler        *sampler = gegl_buffer_sampler_new_at_level (input,
                                                          babl_format ("RGBA float"),
-                                                         o->sampler_type);
+                                                         o->sampler_type,
+                                                         level);
   GeglBufferIterator *iter;
 
   GeglAbyssPolicy abyss = o->tileable ? GEGL_ABYSS_LOOP : GEGL_ABYSS_NONE;
diff --git a/operations/common/stress.c b/operations/common/stress.c
index 46ed707..81d8807 100644
--- a/operations/common/stress.c
+++ b/operations/common/stress.c
@@ -71,7 +71,8 @@ static void stress (GeglBuffer          *src,
                     gint                 radius,
                     gint                 samples,
                     gint                 iterations,
-                    gdouble              rgamma)
+                    gdouble              rgamma,
+                    gint                 level)
 {
   const Babl *format = babl_format ("RGBA float");
 
@@ -79,7 +80,7 @@ static void stress (GeglBuffer          *src,
   {
     GeglBufferIterator *i = gegl_buffer_iterator_new (dst, dst_rect, 0, babl_format("RaGaBaA float"),
                                                       GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
-    GeglSampler *sampler = gegl_buffer_sampler_new (src, format, GEGL_SAMPLER_NEAREST);
+    GeglSampler *sampler = gegl_buffer_sampler_new_at_level (src, format, GEGL_SAMPLER_NEAREST, level);
 
     while (gegl_buffer_iterator_next (i))
     {
@@ -170,7 +171,7 @@ process (GeglOperation       *operation,
           o->radius,
           o->samples,
           o->iterations,
-          RGAMMA /*o->rgamma,*/);
+          RGAMMA /*o->rgamma,*/, level);
 
   return  TRUE;
 }
diff --git a/operations/common/waves.c b/operations/common/waves.c
index 65e5d86..69c671a 100644
--- a/operations/common/waves.c
+++ b/operations/common/waves.c
@@ -86,9 +86,10 @@ process (GeglOperation       *operation,
          gint                 level)
 {
   GeglProperties     *o       = GEGL_PROPERTIES (operation);
-  GeglSampler        *sampler = gegl_buffer_sampler_new (input,
+  GeglSampler        *sampler = gegl_buffer_sampler_new_at_level (input,
                                                          babl_format ("RGBA float"),
-                                                         o->sampler_type);
+                                                         o->sampler_type,
+                                                         level);
   GeglRectangle      *in_extent = gegl_operation_source_get_bounding_box (operation, "input");
   GeglBufferIterator *iter;
 
diff --git a/operations/common/whirl-pinch.c b/operations/common/whirl-pinch.c
index eec8df0..2d0d996 100644
--- a/operations/common/whirl-pinch.c
+++ b/operations/common/whirl-pinch.c
@@ -144,7 +144,8 @@ apply_whirl_pinch (gdouble              whirl,
                    GeglRectangle       *in_boundary,
                    GeglBuffer          *dst,
                    GeglRectangle       *boundary,
-                   const GeglRectangle *roi)
+                   const GeglRectangle *roi,
+                   gint                 level)
 {
   gfloat *dst_buf;
   gint row, col;
@@ -159,8 +160,8 @@ apply_whirl_pinch (gdouble              whirl,
 
   scale_x = 1.0;
   scale_y = (gdouble) in_boundary->width / in_boundary->height;
-  sampler = gegl_buffer_sampler_new (src, babl_format ("RaGaBaA float"),
-                                     GEGL_SAMPLER_NOHALO);
+  sampler = gegl_buffer_sampler_new_at_level (src, babl_format ("RaGaBaA float"),
+                                     GEGL_SAMPLER_NOHALO, level);
 
   for (row = 0; row < roi->height; row++) {
     for (col = 0; col < roi->width; col++) {
@@ -248,7 +249,8 @@ process (GeglOperation       *operation,
                      &boundary,
                      output,
                      &boundary,
-                     result);
+                     result,
+                     level);
   return TRUE;
 }
 
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index 9ac0f07..113b89d 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -557,9 +557,10 @@ gegl_transform_get_required_for_output (GeglOperation       *op,
       gegl_matrix3_is_identity (&inverse))
     return requested_rect;
 
-  sampler = gegl_buffer_sampler_new (NULL,
+  sampler = gegl_buffer_sampler_new_at_level (NULL,
                                      babl_format("RaGaBaA float"),
-                                     transform->sampler);
+                                     transform->sampler,
+                                     0); //XXX: need level?
   context_rect = *gegl_sampler_get_context_rect (sampler);
   g_object_unref (sampler);
 
@@ -636,9 +637,10 @@ gegl_transform_get_invalidated_by_change (GeglOperation       *op,
    * allow for round off error (for "safety")?
    */
 
-  sampler = gegl_buffer_sampler_new (NULL,
+  sampler = gegl_buffer_sampler_new_at_level (NULL,
                                      babl_format("RaGaBaA float"),
-                                     transform->sampler);
+                                     transform->sampler,
+                                     0); // XXX: need level?
   context_rect = *gegl_sampler_get_context_rect (sampler);
   g_object_unref (sampler);
 
@@ -743,14 +745,16 @@ transform_affine (GeglOperation *operation,
                   GeglMatrix3 *matrix,
                   gint         level)
 {
+  //gint factor = 1 << level;
   OpTransform *transform = (OpTransform *) operation;
   const Babl  *format = babl_format ("RaGaBaA float");
   GeglMatrix3  inverse;
   GeglMatrix2  inverse_jacobian;
   gint         dest_pixels;
-  GeglSampler *sampler = gegl_buffer_sampler_new (src,
+  GeglSampler *sampler = gegl_buffer_sampler_new_at_level (src,
                                          babl_format("RaGaBaA float"),
-                                         transform->sampler);
+                                         transform->sampler,
+                                         level);
   GeglSamplerGetFun sampler_get_fun = gegl_sampler_get_fun (sampler);
 
 
@@ -959,9 +963,10 @@ transform_generic (GeglOperation *operation,
   const GeglRectangle *dest_extent;
   GeglMatrix3          inverse;
   gint                 dest_pixels;
-  GeglSampler *sampler = gegl_buffer_sampler_new (src,
+  GeglSampler *sampler = gegl_buffer_sampler_new_at_level (src,
                                          babl_format("RaGaBaA float"),
-                                         transform->sampler);
+                                         transform->sampler,
+                                         level);
   GeglSamplerGetFun sampler_get_fun = gegl_sampler_get_fun (sampler);
 
   g_object_get (dest, "pixels", &dest_pixels, NULL);
diff --git a/perf/test-samplers.c b/perf/test-samplers.c
index 08bfddc..dc98da0 100644
--- a/perf/test-samplers.c
+++ b/perf/test-samplers.c
@@ -87,7 +87,7 @@ main (gint    argc,
   {
     int j;
     float px[4] = {0.2, 0.4, 0.1, 0.5};
-    GeglSampler *sampler = gegl_buffer_sampler_new (buffer, format, 
+    GeglSampler *sampler = gegl_buffer_sampler_new (buffer, format,
                                                     GEGL_SAMPLER_NEAREST);
 
     for (j = 0; j < SAMPLES; j ++)


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