[gegl/abyss: 1/3] abyss policy: add a repeat_mode parameter in gegl_buffer_sample and gegl_sampler_get. Treatment not



commit 3954486ebb22da5d769e751ed9e098d7a6608207
Author: Michael Murà <batolettre gmail com>
Date:   Sun Sep 11 09:56:29 2011 +0200

    abyss policy: add a repeat_mode parameter in gegl_buffer_sample and gegl_sampler_get. Treatment not implemented yet.

 gegl/buffer/gegl-buffer-access.c      |    2 +-
 gegl/buffer/gegl-buffer.h             |    1 -
 gegl/buffer/gegl-sampler-cubic.c      |   44 +++++++++++++++++---------------
 gegl/buffer/gegl-sampler-linear.c     |    6 +++-
 gegl/buffer/gegl-sampler-lohalo.c     |   38 +++++++++++++++-------------
 gegl/buffer/gegl-sampler-nearest.c    |   38 +++++++++++++++-------------
 gegl/buffer/gegl-sampler.c            |    8 +++---
 gegl/buffer/gegl-sampler.h            |   37 +++++++++++++--------------
 gegl/gegl-plugin.h                    |   15 ++++++-----
 operations/common/map-absolute.c      |    2 +-
 operations/common/map-relative.c      |    3 +-
 operations/common/ripple.c            |    3 +-
 operations/common/waves.c             |    3 +-
 operations/transform/transform-core.c |    4 +-
 operations/workshop/ditto.c           |    3 +-
 operations/workshop/whirl-pinch.c     |    2 +-
 16 files changed, 110 insertions(+), 99 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 6d7e5dd..a189504 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1121,7 +1121,7 @@ gegl_buffer_sample (GeglBuffer       *buffer,
       gegl_sampler_prepare (buffer->sampler);
     }
 
-  gegl_sampler_get (buffer->sampler, x, y, scale, dest, GEGL_ABYSS_NONE);
+  gegl_sampler_get (buffer->sampler, x, y, scale, dest, repeat_mode);
 }
 
 void
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index c35dfa6..95d9097 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -389,7 +389,6 @@ void              gegl_buffer_sample          (GeglBuffer       *buffer,
 
 
 
-
 /**
  * gegl_buffer_sample_cleanup:
  * @buffer: the GeglBuffer to sample from
diff --git a/gegl/buffer/gegl-sampler-cubic.c b/gegl/buffer/gegl-sampler-cubic.c
index 819e4d6..24a487e 100644
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -37,22 +37,23 @@ enum
 };
 
 static void      gegl_sampler_cubic_finalize (GObject      *gobject);
-static void      gegl_sampler_cubic_get (GeglSampler  *sampler,
-                                         gdouble       x,
-                                         gdouble       y,
-                                         GeglMatrix2  *scale,
-                                         void         *output);
-static void      get_property           (GObject      *gobject,
-                                         guint         prop_id,
-                                         GValue       *value,
-                                         GParamSpec   *pspec);
-static void      set_property           (GObject      *gobject,
-                                         guint         prop_id,
-                                         const GValue *value,
-                                         GParamSpec   *pspec);
-static inline gfloat cubicKernel       (gfloat        x,
-                                        gfloat        b,
-                                        gfloat        c);
+static void      gegl_sampler_cubic_get (GeglSampler     *sampler,
+                                         gdouble          x,
+                                         gdouble          y,
+                                         GeglMatrix2     *scale,
+                                         void            *output,
+                                         GeglAbyssPolicy  repeat_mode);
+static void      get_property           (GObject         *gobject,
+                                         guint            prop_id,
+                                         GValue          *value,
+                                         GParamSpec      *pspec);
+static void      set_property           (GObject         *gobject,
+                                         guint            prop_id,
+                                         const GValue    *value,
+                                         GParamSpec      *pspec);
+static inline gfloat cubicKernel        (gfloat           x,
+                                         gfloat           b,
+                                         gfloat           c);
 
 
 G_DEFINE_TYPE (GeglSamplerCubic, gegl_sampler_cubic, GEGL_TYPE_SAMPLER)
@@ -133,11 +134,12 @@ gegl_sampler_cubic_init (GeglSamplerCubic *self)
 }
 
 void
-gegl_sampler_cubic_get (GeglSampler *self,
-                        gdouble      x,
-                        gdouble      y,
-                        GeglMatrix2 *scale,
-                        void        *output)
+gegl_sampler_cubic_get (GeglSampler     *self,
+                        gdouble          x,
+                        gdouble          y,
+                        GeglMatrix2     *scale,
+                        void            *output,
+                        GeglAbyssPolicy  repeat_mode)
 {
   GeglSamplerCubic *cubic = (GeglSamplerCubic*)(self);
   GeglRectangle     context_rect;
diff --git a/gegl/buffer/gegl-sampler-linear.c b/gegl/buffer/gegl-sampler-linear.c
index 57370bf..465120b 100644
--- a/gegl/buffer/gegl-sampler-linear.c
+++ b/gegl/buffer/gegl-sampler-linear.c
@@ -66,7 +66,8 @@ static void gegl_sampler_linear_get (GeglSampler* restrict self,
                                      const gdouble         x,
                                      const gdouble         y,
                                      GeglMatrix2          *scale,
-                                     void*        restrict output);
+                                     void*        restrict output,
+                                     GeglAbyssPolicy       repeat_mode);
 
 static void set_property (GObject*      gobject,
                           guint         property_id,
@@ -107,7 +108,8 @@ gegl_sampler_linear_get (GeglSampler* restrict self,
                          const gdouble         absolute_x,
                          const gdouble         absolute_y,
                          GeglMatrix2          *scale,
-                         void*        restrict output)
+                         void*        restrict output,
+                         GeglAbyssPolicy       repeat_mode)
 {
   const gint pixels_per_buffer_row = 64;
   const gint channels = 4;
diff --git a/gegl/buffer/gegl-sampler-lohalo.c b/gegl/buffer/gegl-sampler-lohalo.c
index 14fc202..a9d5372 100644
--- a/gegl/buffer/gegl-sampler-lohalo.c
+++ b/gegl/buffer/gegl-sampler-lohalo.c
@@ -254,17 +254,18 @@ enum
 };
 
 
-static void gegl_sampler_lohalo_get (      GeglSampler* restrict self,
-                                     const gdouble               absolute_x,
-                                     const gdouble               absolute_y,
-                                           GeglMatrix2          *scale,
-                                           void*        restrict output);
+static void gegl_sampler_lohalo_get (GeglSampler* restrict  self,
+                                     const gdouble          absolute_x,
+                                     const gdouble          absolute_y,
+                                     GeglMatrix2           *scale,
+                                     void*        restrict  output,
+                                     GeglAbyssPolicy        repeat_mode);
 
 
-static void set_property (      GObject*    gobject,
-                                guint       property_id,
-                          const GValue*     value,
-                                GParamSpec* pspec);
+static void set_property (GObject*      gobject,
+                          guint         property_id,
+                          const GValue* value,
+                          GParamSpec*   pspec);
 
 
 static void get_property (GObject*    gobject,
@@ -1304,11 +1305,12 @@ level_1_ewa_update (const gint              j,
 
 
 static void
-gegl_sampler_lohalo_get (      GeglSampler* restrict self,
-                         const gdouble               absolute_x,
-                         const gdouble               absolute_y,
-                         GeglMatrix2                *scale,
-                               void*        restrict output)
+gegl_sampler_lohalo_get (GeglSampler* restrict  self,
+                         const gdouble          absolute_x,
+                         const gdouble          absolute_y,
+                         GeglMatrix2           *scale,
+                         void*        restrict  output,
+                         GeglAbyssPolicy        repeat_mode)
 {
   /*
    * Needed constants related to the input pixel value pointer
@@ -2432,10 +2434,10 @@ gegl_sampler_lohalo_get (      GeglSampler* restrict self,
 
 
 static void
-set_property (      GObject*    gobject,
-                    guint       property_id,
-              const GValue*     value,
-                    GParamSpec* pspec)
+set_property (GObject*      gobject,
+              guint         property_id,
+              const GValue* value,
+              GParamSpec*   pspec)
 {
   /* G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec); */
 }
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index 46fd9a1..cf54019 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -32,19 +32,20 @@ enum
   PROP_LAST
 };
 
-static void    gegl_sampler_nearest_get (GeglSampler  *self,
-                                         gdouble       x,
-                                         gdouble       y,
-                                         GeglMatrix2  *scale,
-                                         void         *output);
-static void    set_property             (GObject      *gobject,
-                                         guint         prop_id,
-                                         const GValue *value,
-                                         GParamSpec   *pspec);
-static void    get_property             (GObject      *gobject,
-                                         guint         prop_id,
-                                         GValue       *value,
-                                         GParamSpec   *pspec);
+static void    gegl_sampler_nearest_get (GeglSampler    *self,
+                                         gdouble         x,
+                                         gdouble         y,
+                                         GeglMatrix2    *scale,
+                                         void           *output,
+                                         GeglAbyssPolicy repeat_mode);
+static void    set_property             (GObject        *gobject,
+                                         guint           prop_id,
+                                         const GValue   *value,
+                                         GParamSpec     *pspec);
+static void    get_property             (GObject        *gobject,
+                                         guint           prop_id,
+                                         GValue         *value,
+                                         GParamSpec     *pspec);
 
 G_DEFINE_TYPE (GeglSamplerNearest, gegl_sampler_nearest, GEGL_TYPE_SAMPLER)
 
@@ -72,11 +73,12 @@ gegl_sampler_nearest_init (GeglSamplerNearest *self)
 }
 
 void
-gegl_sampler_nearest_get (GeglSampler *self,
-                          gdouble      x,
-                          gdouble      y,
-                          GeglMatrix2 *scale,
-                          void        *output)
+gegl_sampler_nearest_get (GeglSampler    *self,
+                          gdouble         x,
+                          gdouble         y,
+                          GeglMatrix2    *scale,
+                          void           *output,
+                          GeglAbyssPolicy repeat_mode)
 {
   gfloat             *sampler_bptr;
   sampler_bptr = gegl_sampler_get_from_buffer (self, (gint)x, (gint)y);
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 2146f01..5596aff 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -57,10 +57,10 @@ static void get_property (GObject    *gobject,
                           GValue     *value,
                           GParamSpec *pspec);
 
-static void set_property (      GObject      *gobject,
-                                guint         property_id,
+static void set_property (GObject      *gobject,
+                          guint         property_id,
                           const GValue *value,
-                                GParamSpec   *pspec);
+                          GParamSpec   *pspec);
 
 static void set_buffer (GeglSampler  *self,
                         GeglBuffer   *buffer);
@@ -122,7 +122,7 @@ gegl_sampler_get (GeglSampler   *self,
                   void          *output,
                   GeglAbyssPolicy repeat_mode)
 {
-  self->get (self, x, y, scale, output);
+  self->get (self, x, y, scale, output, repeat_mode);
 }
 
 void
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 3cd8bab..0746945 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -38,11 +38,12 @@ typedef struct _GeglSamplerClass GeglSamplerClass;
 struct _GeglSampler
 {
   GObject       parent_instance;
-  void (* get) (GeglSampler *self,
-                gdouble      x,
-                gdouble      y,
-                GeglMatrix2 *scale,
-                void        *output);
+  void (* get) (GeglSampler     *self,
+                gdouble          x,
+                gdouble          y,
+                GeglMatrix2     *scale,
+                void            *output,
+                GeglAbyssPolicy  repeat_mode);
   /* we cache the getter in the instance, (being able to return the
      function pointer itself and cache it outside the calling loop
      would be even quicker.
@@ -66,16 +67,15 @@ struct _GeglSamplerClass
 {
   GObjectClass  parent_class;
 
-  void (* prepare)   (GeglSampler *self);
-  void (* get)       (GeglSampler *self,
-                      gdouble      x,
-                      gdouble      y,
-                      GeglMatrix2 *scale,
-                      void        *output);
- void  (*set_buffer) (GeglSampler  *self,
-                      GeglBuffer   *buffer);
-
- gpointer       padding[8]; /* eat from the padding if adding to the struct */
+  void (* prepare)   (GeglSampler     *self);
+  void (* get)       (GeglSampler     *self,
+                      gdouble          x,
+                      gdouble          y,
+                      GeglMatrix2     *scale,
+                      void            *output,
+                      GeglAbyssPolicy  repeat_mode);
+ void  (*set_buffer) (GeglSampler     *self,
+                      GeglBuffer      *buffer);
 };
 
 GType gegl_sampler_get_type    (void) G_GNUC_CONST;
@@ -99,10 +99,9 @@ gfloat * gegl_sampler_get_from_mipmap (GeglSampler *sampler,
                                        gint         x,
                                        gint         y,
                                        gint         level);
-gfloat *
-gegl_sampler_get_ptr (GeglSampler         *sampler,
-                      gint                 x,
-                      gint                 y);
+gfloat * gegl_sampler_get_ptr         (GeglSampler *sampler,
+                                       gint         x,
+                                       gint         y);
 
 G_END_DECLS
 
diff --git a/gegl/gegl-plugin.h b/gegl/gegl-plugin.h
index c545e73..2eb5282 100644
--- a/gegl/gegl-plugin.h
+++ b/gegl/gegl-plugin.h
@@ -127,16 +127,17 @@ const gchar   * gegl_extension_handler_get_saver   (const gchar         *extensi
 typedef struct
 {
   GObject       parent_instance;
-  void (* get) (GeglSampler *self,
-                gdouble      x,
-                gdouble      y,
-                GeglMatrix2 *scale,
-                void        *output);
+  void (* get) (GeglSampler    *self,
+                gdouble         x,
+                gdouble         y,
+                GeglMatrix2    *scale,
+                void           *output,
+                GeglAbyssPolicy repeat_mode);
 } SamplerMock;
 
 
-#define gegl_sampler_get(sampler,x,y,scale,dest) \
-  ((SamplerMock*)(sampler))->get((sampler),(x),(y),(scale),(dest))
+#define gegl_sampler_get(sampler,x,y,scale,dest,repeat) \
+  ((SamplerMock*)(sampler))->get((sampler),(x),(y),(scale),(dest),(repeat))
 
 #include <glib-object.h>
 #include <babl/babl.h>
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index 6d90c6a..a6811b4 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -101,7 +101,7 @@ process (GeglOperation       *operation,
                 }
               else
                 {
-                  gegl_sampler_get (sampler, coords[0], coords[1], NULL, out);
+                  gegl_sampler_get (sampler, coords[0], coords[1], NULL, out, GEGL_ABYSS_NONE);
                 }
 
               coords += 2;
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index 3a4eb24..f910a52 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -109,7 +109,8 @@ process (GeglOperation       *operation,
                 {
                   gegl_sampler_get (sampler, x+coords[0] * scaling,
                                              y+coords[1] * scaling,
-                                             NULL, out);
+                                             NULL, out,
+                                             GEGL_ABYSS_NONE);
                 }
 
               coords += 2;
diff --git a/operations/common/ripple.c b/operations/common/ripple.c
index 30d6d53..d8b986f 100644
--- a/operations/common/ripple.c
+++ b/operations/common/ripple.c
@@ -124,7 +124,8 @@ process (GeglOperation       *operation,
                         coordsx,
                         coordsy,
                         NULL,
-                        out_pixel);
+                        out_pixel,
+                        GEGL_ABYSS_NONE);
 
       out_pixel += 4;
 
diff --git a/operations/common/waves.c b/operations/common/waves.c
index 895aea1..4e7252a 100644
--- a/operations/common/waves.c
+++ b/operations/common/waves.c
@@ -124,7 +124,8 @@ process (GeglOperation       *operation,
                         coordsx,
                         coordsy,
                         NULL,
-                        out_pixel);
+                        out_pixel,
+                        GEGL_ABYSS_NONE);
 
       out_pixel += 4;
 
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index 6cbd562..01a5afc 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -710,7 +710,7 @@ affine_affine (GeglBuffer  *dest,
 
           for (x = roi->width; x--;)
             {
-              gegl_sampler_get (sampler, u_float/w_float, v_float/w_float, &inverse_jacobian, dest_ptr);
+              gegl_sampler_get (sampler, u_float/w_float, v_float/w_float, &inverse_jacobian, dest_ptr, GEGL_ABYSS_NONE);
               dest_ptr+=4;
               u_float += inverse.coeff [0][0];
               v_float += inverse.coeff [1][0];
@@ -794,7 +794,7 @@ affine_generic (GeglBuffer  *dest,
               inverse_jacobian.coeff[1][0] = (inverse.coeff[1][0] - inverse.coeff[2][0] * v) * w_recip;
               inverse_jacobian.coeff[1][1] = (inverse.coeff[1][1] - inverse.coeff[2][1] * v) * w_recip;
 
-              gegl_sampler_get (sampler, u, v, &inverse_jacobian, dest_ptr);
+              gegl_sampler_get (sampler, u, v, &inverse_jacobian, dest_ptr, GEGL_ABYSS_NONE);
               dest_ptr+=4;
 
               u_float += inverse.coeff [0][0];
diff --git a/operations/workshop/ditto.c b/operations/workshop/ditto.c
index 9a19df9..736ece4 100644
--- a/operations/workshop/ditto.c
+++ b/operations/workshop/ditto.c
@@ -71,7 +71,8 @@ process (GeglOperation       *operation,
                         x,
                         y,
                         NULL,
-                        out_pixel);
+                        out_pixel,
+                        GEGL_REPEAT_MODE_ZERO);
 
       out_pixel += 4;
 
diff --git a/operations/workshop/whirl-pinch.c b/operations/workshop/whirl-pinch.c
index 0a901eb..bb763db 100644
--- a/operations/workshop/whirl-pinch.c
+++ b/operations/workshop/whirl-pinch.c
@@ -158,7 +158,7 @@ apply_whirl_pinch (gdouble whirl, gdouble pinch, gdouble radius,
         gegl_sampler_compute_scale (scale, roi->x + col, roi->y + row);
         gegl_unmap (roi->x + col, roi->y + row, cx, cy);
 
-        gegl_sampler_get (sampler, cx, cy, &scale, &dst_buf[(row * roi->width + col) * 4]);
+        gegl_sampler_get (sampler, cx, cy, &scale, &dst_buf[(row * roi->width + col) * 4], GEGL_REPEAT_MODE_ZERO);
     } /* for */
   } /* for */
 



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