[gegl/samplers-api-rework] buffer: rework of sampler api



commit e3663b3b91b731fbc7b0cf3caeb6cc6148026f41
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Sun Jul 3 03:39:35 2011 +0100

    buffer: rework of sampler api
    
    Added start of a new and simpler constructor to expose in the public API

 gegl/buffer/gegl-buffer-access.c |   15 ---------------
 gegl/buffer/gegl-buffer-types.h  |    1 +
 gegl/buffer/gegl-buffer.h        |   18 ++++++++++++++----
 gegl/buffer/gegl-sampler.c       |   21 ++++++++++++++++++++-
 gegl/buffer/gegl-sampler.h       |    1 -
 operations/affine/affine.c       |   29 +----------------------------
 6 files changed, 36 insertions(+), 49 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index b051cbc..f5c18fd 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1202,18 +1202,3 @@ gegl_buffer_dup (GeglBuffer *buffer)
   return new_buffer;
 }
 
-void
-gegl_buffer_sampler (GeglBuffer       *buffer,
-                    gdouble           x,
-                    gdouble           y,
-                    gdouble           scale,
-                    gpointer          dest,
-                    const Babl       *format,
-                    gpointer          sampler2)
-{
-  GeglSampler *sampler = sampler2;
-  g_return_if_fail (GEGL_IS_BUFFER (buffer));
-  g_return_if_fail (GEGL_IS_SAMPLER (sampler));
-
-  gegl_sampler_get (sampler, x, y, dest);
-}
diff --git a/gegl/buffer/gegl-buffer-types.h b/gegl/buffer/gegl-buffer-types.h
index fedfbf4..94a5b95 100644
--- a/gegl/buffer/gegl-buffer-types.h
+++ b/gegl/buffer/gegl-buffer-types.h
@@ -65,5 +65,6 @@ typedef struct _GeglCache                 GeglCache;
 typedef struct _GeglCacheClass            GeglCacheClass;
 
 typedef struct _GeglRegion                GeglRegion;
+typedef struct _GeglSampler               GeglSampler;
 
 #endif
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index daee62e..14423a1 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -28,7 +28,8 @@ G_BEGIN_DECLS
 #define GEGL_TYPE_BUFFER (gegl_buffer_get_type ())
 #define GEGL_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_BUFFER, GeglBuffer))
 #ifndef __GEGL_BUFFER_TYPES_H__
-typedef struct _GeglBuffer     GeglBuffer;
+typedef struct _GeglBuffer   GeglBuffer;
+typedef struct _GeglSampler  GeglSampler;
 #endif
 
 /***
@@ -344,6 +345,8 @@ void gegl_buffer_sample (GeglBuffer       *buffer,
                          GeglInterpolation interpolation);
 
 
+
+
 /**
  * gegl_buffer_sample_cleanup:
  * @buffer: the GeglBuffer to sample from
@@ -356,15 +359,22 @@ void gegl_buffer_sample (GeglBuffer       *buffer,
 void            gegl_buffer_sample_cleanup    (GeglBuffer *buffer);
 
 /**
- * gegl_buffer_interpolation_from_string:
+ * gegl_interpolation_from_string:
  * @string: the string to look up
  *
  * Looks up the GeglInterpolation corresponding to a string, if no matching
  * interpolation is found returns GEGL_INTERPOLATION_NEAREST.
  */
-GeglInterpolation gegl_buffer_interpolation_from_string (const gchar *string);
-
+GeglInterpolation gegl_interpolation_from_string (const gchar *string);
 
+/**
+ * gegl_sampler_from_interpolation:
+ * @string: the string to look up
+ *
+ * Looks up the GeglInterpolation corresponding to a string, if no matching
+ * interpolation is found returns GEGL_INTERPOLATION_NEAREST.
+ */
+GeglSampler *gegl_sampler_from_interpolation (GeglInterpolation interpolation);
 
 /**
  * gegl_buffer_linear_new:
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index ce0c2ad..e41de0d 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -556,7 +556,7 @@ set_buffer (GeglSampler *self, GeglBuffer *buffer)
 }
 
 GeglInterpolation
-gegl_buffer_interpolation_from_string (const gchar *string)
+gegl_interpolation_from_string (const gchar *string)
 {
   if (g_str_equal (string, "nearest") ||
       g_str_equal (string, "none"))
@@ -596,6 +596,25 @@ gegl_sampler_type_from_interpolation (GeglInterpolation interpolation)
     }
 }
 
+GeglSampler *
+gegl_sampler_from_interpolation (GeglInterpolation interpolation)
+{
+  Babl                 *format = babl_format ("RaGaBaA float");
+  GeglSampler          *sampler;
+  GType                 desired_type;
+  desired_type = gegl_sampler_type_from_interpolation (interpolation);
+  if (interpolation == GEGL_INTERPOLATION_LANCZOS)
+      sampler = g_object_new (desired_type,
+                              "format", format,
+                              "lanczos_width",  4,
+                              NULL);
+  else
+      sampler = g_object_new (desired_type,
+                              "format", format,
+                              NULL);
+  return sampler;
+}
+
 void  gegl_sampler_set_scale (GeglSampler *self,
                               GeglMatrix2 *scale)
 {
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index 65e2189..fed7982 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -34,7 +34,6 @@ G_BEGIN_DECLS
 #define GEGL_SAMPLER_MIPMAP_LEVELS   3
 
 typedef struct _GeglSamplerClass GeglSamplerClass;
-typedef struct _GeglSampler    GeglSampler;
 
 struct _GeglSampler
 {
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index ccd84ab..015706f 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -139,38 +139,11 @@ op_affine_get_type (void)
   return g_define_type_id;
 }
 
-
-GType
-gegl_sampler_type_from_interpolation (GeglInterpolation interpolation);
-
 /* ************************* */
 static GeglSampler *
 op_affine_sampler (OpAffine *self)
 {
-  Babl                 *format;
-  GeglSampler          *sampler;
-  GType                 desired_type;
-  GeglInterpolation     interpolation;
-
-  format = babl_format ("RaGaBaA float");
-
-  interpolation = gegl_buffer_interpolation_from_string (self->filter);
-  desired_type = gegl_sampler_type_from_interpolation (interpolation);
-
-  if (interpolation == GEGL_INTERPOLATION_LANCZOS)
-    {
-      sampler = g_object_new (desired_type,
-                              "format", format,
-                              "lanczos_width",  self->lanczos_width,
-                              NULL);
-    }
-  else
-    {
-      sampler = g_object_new (desired_type,
-                              "format", format,
-                              NULL);
-    }
-  return sampler;
+  return gegl_sampler_from_interpolation (gegl_interpolation_from_string (self->filter));
 }
 /* XXX: keep a pool of samplers */
 



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