[gegl] gegl_buffer_sample: change API



commit c05cfa06e8d1dbee0859f3e727644c5435cbac8d
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Sun Jul 3 02:49:21 2011 +0100

    gegl_buffer_sample: change API
    
    Made scale be a GeglMatrix2 instead of a gfloat, allowing to specify a more
    correct sampling context. This is an API change, not many things are using the
    GEGL so this should be fine. In GIMP there is one instance that needs updating
    but it resides in #ifdef 0'd code so there should be no API conflict.

 gegl/buffer/gegl-buffer-access.c    |   26 +++++++-------------------
 gegl/buffer/gegl-buffer.h           |   29 +++++++++++------------------
 gegl/gegl-plugin.h                  |   10 +++++-----
 operations/common/mirrors.c         |    2 +-
 operations/workshop/fractal-trace.c |   12 ++++++------
 operations/workshop/noise-spread.c  |    4 ++--
 operations/workshop/plasma.c        |    8 ++++----
 operations/workshop/whirl-pinch.c   |    3 +--
 8 files changed, 37 insertions(+), 57 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 620737c..b051cbc 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1065,13 +1065,13 @@ gegl_buffer_get_abyss (GeglBuffer *buffer)
 }
 
 void
-gegl_buffer_sample2 (GeglBuffer       *buffer,
-                     gdouble           x,
-                     gdouble           y,
-                     GeglMatrix2      *scale,
-                     gpointer          dest,
-                     const Babl       *format,
-                     GeglInterpolation interpolation)
+gegl_buffer_sample (GeglBuffer       *buffer,
+                    gdouble           x,
+                    gdouble           y,
+                    GeglMatrix2      *scale,
+                    gpointer          dest,
+                    const Babl       *format,
+                    GeglInterpolation interpolation)
 {
   GType desired_type;
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
@@ -1111,18 +1111,6 @@ gegl_buffer_sample2 (GeglBuffer       *buffer,
 }
 
 void
-gegl_buffer_sample (GeglBuffer       *buffer,
-                    gdouble           x,
-                    gdouble           y,
-                    gdouble           scale,
-                    gpointer          dest,
-                    const Babl       *format,
-                    GeglInterpolation interpolation)
-{
-  gegl_buffer_sample2 (buffer, x, y, NULL, dest, format, interpolation);
-}
-
-void
 gegl_buffer_sample_cleanup (GeglBuffer *buffer)
 {
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 469189f..daee62e 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -21,7 +21,7 @@
 
 #include <glib-object.h>
 #include <babl/babl.h>
-#include <gegl/gegl-matrix.h>
+#include <gegl-matrix.h>
 
 G_BEGIN_DECLS
 
@@ -322,11 +322,12 @@ typedef enum {
  * @buffer: the GeglBuffer to sample from
  * @x: x coordinate to sample in buffer coordinates
  * @y: y coordinate to sample in buffer coordinates
- * @scale: the scale we're fetching at (<1.0 can lead to decimation)
+ * @scale: a matrix that indicates scaling factors, see
+ * gegl_sampler_compute_scale the same.
  * @dest: buffer capable of storing one pixel in @format.
  * @format: the format to store the sampled color in.
  * @interpolation: the interpolation behavior to use,
- * to be ported from working code. Valid values: GEGL_INTERPOLATION_NEAREST and
+ * to be ported from working code. Valid values: GEGL_INTERPOLATION_NEAREST,
  * GEGL_INTERPOLATION_LINEAR, GEGL_INTERPOLATION_CUBIC,
  * GEGL_INTERPOLATION_LANCZOS and GEGL_INTERPOLATION_LOHALO
  *
@@ -334,21 +335,13 @@ typedef enum {
  * of interpolation. The samplers used cache for a small neighbourhood of the
  * buffer for more efficient access.
  */
-void            gegl_buffer_sample            (GeglBuffer       *buffer,
-                                               gdouble           x,
-                                               gdouble           y,
-                                               gdouble           scale,
-                                               gpointer          dest,
-                                               const Babl       *format,
-                                               GeglInterpolation interpolation);
-void
-gegl_buffer_sample2 (GeglBuffer       *buffer,
-                     gdouble           x,
-                     gdouble           y,
-                     GeglMatrix2      *inverse_jacobian,
-                     gpointer          dest,
-                     const Babl       *format,
-                     GeglInterpolation interpolation);
+void gegl_buffer_sample (GeglBuffer       *buffer,
+                         gdouble           x,
+                         gdouble           y,
+                         GeglMatrix2      *scale,
+                         gpointer          dest,
+                         const Babl       *format,
+                         GeglInterpolation interpolation);
 
 
 /**
diff --git a/gegl/gegl-plugin.h b/gegl/gegl-plugin.h
index 3fec394..92938f9 100644
--- a/gegl/gegl-plugin.h
+++ b/gegl/gegl-plugin.h
@@ -105,15 +105,15 @@ const gchar   * gegl_extension_handler_get_saver   (const gchar         *extensi
  *
  * #undef gegl_unmap      // IMPORTANT undefine map macro
  */
-#define gegl_sampler_compute_scale (matrix, x, y) \
+#define gegl_sampler_compute_scale(matrix, x, y) \
 {                                       \
   float ax, ay, bx, by;                 \
-  gegl_inverse_map(x + 0.5, y, ax, ay); \
-  gegl_inverse_map(x - 0.5, y, bx, by); \
+  gegl_unmap(x + 0.5, y, ax, ay);       \
+  gegl_unmap(x - 0.5, y, bx, by);       \
   matrix.coeff[0][0] = ax - bx;         \
   matrix.coeff[1][0] = ay - by;         \
-  gegl_inverse_map(x, y + 0.5, ax, ay); \
-  gegl_inverse_map(x, y - 0.5, bx, by); \
+  gegl_unmap(x, y + 0.5, ax, ay);       \
+  gegl_unmap(x, y - 0.5, bx, by);       \
   matrix.coeff[0][1] = ax - bx;         \
   matrix.coeff[1][1] = ay - by;         \
 }
diff --git a/operations/common/mirrors.c b/operations/common/mirrors.c
index 5409178..259f90c 100644
--- a/operations/common/mirrors.c
+++ b/operations/common/mirrors.c
@@ -234,7 +234,7 @@ apply_mirror (double               mirror_angle,
 
 
 #ifndef DO_NOT_USE_BUFFER_SAMPLE
-        gegl_buffer_sample (src, cx, cy, 1.0, &dst_buf[(row * roi->width + col) * 4], format,  GEGL_INTERPOLATION_LINEAR);
+        gegl_buffer_sample (src, cx, cy, NULL, &dst_buf[(row * roi->width + col) * 4], format, GEGL_INTERPOLATION_LINEAR);
 #endif
 
 #ifdef DO_NOT_USE_BUFFER_SAMPLE
diff --git a/operations/workshop/fractal-trace.c b/operations/workshop/fractal-trace.c
index e5f3958..d5cdc20 100644
--- a/operations/workshop/fractal-trace.c
+++ b/operations/workshop/fractal-trace.c
@@ -140,7 +140,7 @@ fractaltrace (GeglBuffer          *input,
       switch (fractal_type)
         {
         case FRACTAL_TYPE_JULIA:
-#define gegl_inverse_map(u,v,ud,vd) {\
+#define gegl_unmap(u,v,ud,vd) {\
        gdouble rx, ry;\
        cx = o->X1 + ((u) - picture->x) * scale_x; \
        cy = o->Y1 + ((v) - picture->y) * scale_y; \
@@ -149,12 +149,12 @@ fractaltrace (GeglBuffer          *input,
        vd = (ry - o->Y1) / scale_y + picture->y;\
       }
       gegl_sampler_compute_scale (scale, x, y);
-      gegl_inverse_map(x,y,px,py);
-#undef gegl_inverse_map
+      gegl_unmap(x,y,px,py);
+#undef gegl_unmap
           break;
 
         case FRACTAL_TYPE_MANDELBROT:
-#define gegl_inverse_map(u,v,ud,vd) {\
+#define gegl_unmap(u,v,ud,vd) {\
            gdouble rx, ry;\
            cx = o->X1 + ((u) - picture->x) * scale_x; \
            cy = o->Y1 + ((v) - picture->y) * scale_y; \
@@ -163,8 +163,8 @@ fractaltrace (GeglBuffer          *input,
            vd = (ry - o->Y1) / scale_y + picture->y;\
          }
       gegl_compute_inverse_jacobian (scale, x, y);
-      gegl_inverse_map(x,y,px,py);
-#undef gegl_inverse_map
+      gegl_unmap(x,y,px,py);
+#undef gegl_unmap
           break;
 
         default:
diff --git a/operations/workshop/noise-spread.c b/operations/workshop/noise-spread.c
index fcf4725..c2e12af 100644
--- a/operations/workshop/noise-spread.c
+++ b/operations/workshop/noise-spread.c
@@ -90,9 +90,9 @@ apply_spread (gint                 x_amount,
       calc_sample_coords (x1, y1, x_amount, y_amount, gr, &x, &y);
       /* Only displace the pixel if it's within the bounds of the image. */
       if (x >= 0 && x < img_width && y >= 0 && y < img_height)
-        gegl_buffer_sample (src, x, y, 1.0, &dst_buf[(y1 * roi->width + x1) * 4], format,  GEGL_INTERPOLATION_LINEAR);
+        gegl_buffer_sample (src, x, y, NULL, &dst_buf[(y1 * roi->width + x1) * 4], format,  GEGL_INTERPOLATION_LINEAR);
       else /* Else just copy it */
-        gegl_buffer_sample (src, x1, y1, 1.0, &dst_buf[(y1 * roi->width + x1) * 4], format,  GEGL_INTERPOLATION_LINEAR);
+        gegl_buffer_sample (src, x1, y1, NULL, &dst_buf[(y1 * roi->width + x1) * 4], format,  GEGL_INTERPOLATION_LINEAR);
     } /* for */
   } /* for */
 
diff --git a/operations/workshop/plasma.c b/operations/workshop/plasma.c
index 298cab1..9705a56 100644
--- a/operations/workshop/plasma.c
+++ b/operations/workshop/plasma.c
@@ -218,13 +218,13 @@ do_plasma_big (PlasmaContext *context,
       if (x1 == x2 && y1 == y2)
         return FALSE;
 
-      gegl_buffer_sample (context->output, x1, y1, 1.0, tl, babl_format ("RGBA float"),
+      gegl_buffer_sample (context->output, x1, y1, NULL, tl, babl_format ("RGBA float"),
                           GEGL_INTERPOLATION_NEAREST);
-      gegl_buffer_sample (context->output, x1, y2, 1.0, bl, babl_format ("RGBA float"),
+      gegl_buffer_sample (context->output, x1, y2, NULL, bl, babl_format ("RGBA float"),
                           GEGL_INTERPOLATION_NEAREST);
-      gegl_buffer_sample (context->output, x2, y1, 1.0, tr, babl_format ("RGBA float"),
+      gegl_buffer_sample (context->output, x2, y1, NULL, tr, babl_format ("RGBA float"),
                           GEGL_INTERPOLATION_NEAREST);
-      gegl_buffer_sample (context->output, x2, y2, 1.0, br, babl_format ("RGBA float"),
+      gegl_buffer_sample (context->output, x2, y2, NULL, br, babl_format ("RGBA float"),
                           GEGL_INTERPOLATION_NEAREST);
 
       ran = context->o->turbulence / (2.0 * scale_depth);
diff --git a/operations/workshop/whirl-pinch.c b/operations/workshop/whirl-pinch.c
index 8f3760c..b833e1f 100644
--- a/operations/workshop/whirl-pinch.c
+++ b/operations/workshop/whirl-pinch.c
@@ -142,14 +142,13 @@ apply_whirl_pinch (gdouble whirl, gdouble pinch, gdouble radius,
 
   for (row = 0; row < roi->height; row++) {
     for (col = 0; col < roi->width; col++) {
-
         calc_undistorted_coords (roi->x + col, roi->y + row,
                                  cen_x, cen_y,
                                  scale_x, scale_y,
                                  whirl, pinch, radius,
                                  &cx, &cy);
 
-        gegl_buffer_sample (src, cx, cy, 1.0, &dst_buf[(row * roi->width + col) * 4], format,  GEGL_INTERPOLATION_LINEAR);
+        gegl_buffer_sample (src, cx, cy, NULL, &dst_buf[(row * roi->width + col) * 4], format,  GEGL_INTERPOLATION_LINEAR);
     } /* for */
   } /* for */
 



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