buffer: rework of sampler api

Added start of a new and simpler constructor to expose in the public API
parent 4530f330
......@@ -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);
}
......@@ -65,5 +65,6 @@ typedef struct _GeglCache GeglCache;
typedef struct _GeglCacheClass GeglCacheClass;
typedef struct _GeglRegion GeglRegion;
typedef struct _GeglSampler GeglSampler;
#endif
......@@ -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:
......
......@@ -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)
{
......
......@@ -34,7 +34,6 @@ G_BEGIN_DECLS
#define GEGL_SAMPLER_MIPMAP_LEVELS 3
typedef struct _GeglSamplerClass GeglSamplerClass;
typedef struct _GeglSampler GeglSampler;
struct _GeglSampler
{
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment