buffer: add scale argument to gegl_sampler_get

parent 41c2625f
......@@ -1104,10 +1104,8 @@ gegl_buffer_sample (GeglBuffer *buffer,
buffer->sampler_format = format;
gegl_sampler_prepare (buffer->sampler);
}
if (scale)
gegl_sampler_set_scale (buffer->sampler, scale);
gegl_sampler_get (buffer->sampler, x, y, dest);
gegl_sampler_get (buffer->sampler, x, y, scale, dest);
}
void
......
......@@ -387,6 +387,7 @@ void gegl_sampler_set_scale (GeglSampler *self,
void gegl_sampler_get (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output);
......
......@@ -39,6 +39,7 @@ enum
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,
......@@ -126,6 +127,7 @@ void
gegl_sampler_cubic_get (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output)
{
GeglSamplerCubic *cubic = (GeglSamplerCubic*)(self);
......
......@@ -46,6 +46,7 @@ static void lanczos_lookup (GeglSamplerLanczos *sampler);
static void gegl_sampler_lanczos_get (GeglSampler *sampler,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output);
static void get_property (GObject *gobject,
guint prop_id,
......@@ -145,6 +146,7 @@ void
gegl_sampler_lanczos_get (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output)
{
GeglSamplerLanczos *lanczos = GEGL_SAMPLER_LANCZOS (self);
......
......@@ -65,6 +65,7 @@ enum
static void gegl_sampler_linear_get (GeglSampler* restrict self,
const gdouble x,
const gdouble y,
GeglMatrix2 *scale,
void* restrict output);
static void set_property (GObject* gobject,
......@@ -105,6 +106,7 @@ static void
gegl_sampler_linear_get (GeglSampler* restrict self,
const gdouble absolute_x,
const gdouble absolute_y,
GeglMatrix2 *scale,
void* restrict output)
{
const gint pixels_per_buffer_row = 64;
......
......@@ -257,6 +257,7 @@ enum
static void gegl_sampler_lohalo_get ( GeglSampler* restrict self,
const gdouble absolute_x,
const gdouble absolute_y,
GeglMatrix2 *scale,
void* restrict output);
......@@ -1306,6 +1307,7 @@ static void
gegl_sampler_lohalo_get ( GeglSampler* restrict self,
const gdouble absolute_x,
const gdouble absolute_y,
GeglMatrix2 *scale,
void* restrict output)
{
/*
......@@ -1957,10 +1959,10 @@ gegl_sampler_lohalo_get ( GeglSampler* restrict self,
* Ellipse reference:
* http://en.wikipedia.org/wiki/Ellipse#Canonical_form
*/
const gdouble a = self->inverse_jacobian?self->inverse_jacobian->coeff[0][0]:1;
const gdouble b = self->inverse_jacobian?self->inverse_jacobian->coeff[0][1]:0;
const gdouble c = self->inverse_jacobian?self->inverse_jacobian->coeff[1][0]:0;
const gdouble d = self->inverse_jacobian?self->inverse_jacobian->coeff[1][1]:1;
const gdouble a = scale?scale->coeff[0][0]:1;
const gdouble b = scale?scale->coeff[0][1]:0;
const gdouble c = scale?scale->coeff[1][0]:0;
const gdouble d = scale?scale->coeff[1][1]:1;
/*
* Computations are done in double precision because "direct"
......
......@@ -35,6 +35,7 @@ enum
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,
......@@ -74,6 +75,7 @@ void
gegl_sampler_nearest_get (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output)
{
gfloat *sampler_bptr;
......
......@@ -42,7 +42,6 @@ enum
PROP_BUFFER,
PROP_FORMAT,
PROP_CONTEXT_RECT,
PROP_SCALE,
PROP_LAST
};
......@@ -100,19 +99,6 @@ gegl_sampler_class_init (GeglSamplerClass *klass)
"Input pad, for image buffer input.",
GEGL_TYPE_BUFFER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
g_object_class_install_property (
object_class,
PROP_SCALE,
g_param_spec_pointer ("scale",
"Scale",
"An approximation of the extent of pixels sampled in source for a pixel. "
"The property can be varied per sampled pixel, avoid setting it if it is "
"constant for the entire buffer; if setting it for every pixel using the "
"C function gegl_sampler_set_scale is more efficient. "
"Mostly the scaling factors for sampling does not need to be set if the "
"transformation is rotating or only scaling up.",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
......@@ -133,6 +119,7 @@ void
gegl_sampler_get (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output)
{
GeglSamplerClass *klass;
......@@ -144,9 +131,9 @@ gegl_sampler_get (GeglSampler *self,
self->x = x;
self->y = y;
klass = GEGL_SAMPLER_GET_CLASS (self);
klass->get (self, x, y, output);
klass = GEGL_SAMPLER_GET_CLASS (self); /*XXX: bottleneck, store the vfunc cached
in the instance instead */
klass->get (self, x, y, scale, output);
}
void
......@@ -505,10 +492,6 @@ get_property (GObject *object,
g_value_set_pointer (value, self->format);
break;
case PROP_SCALE:
g_value_set_pointer (value, self->inverse_jacobian);
break;
default:
break;
}
......@@ -532,10 +515,6 @@ set_property (GObject *object,
self->format = g_value_get_pointer (value);
break;
case PROP_SCALE:
self->inverse_jacobian = g_value_get_pointer (value);
break;
default:
break;
}
......@@ -620,9 +599,3 @@ gegl_buffer_sampler_new (GeglBuffer *buffer,
gegl_sampler_prepare (sampler);
return sampler;
}
void gegl_sampler_set_scale (GeglSampler *self,
GeglMatrix2 *scale)
{
self->inverse_jacobian = scale;
}
......@@ -47,10 +47,6 @@ struct _GeglSampler
GeglRectangle context_rect[GEGL_SAMPLER_MIPMAP_LEVELS];
gpointer sampler_buffer[GEGL_SAMPLER_MIPMAP_LEVELS];
GeglRectangle sampler_rectangle[GEGL_SAMPLER_MIPMAP_LEVELS];
GeglMatrix2 *inverse_jacobian; /* scale - which could be the inverse
inverse jacobian matrix or some other
approximation of the extent of the region
being sampled. */
gdouble x; /* mirrors the currently requested */
gdouble y; /* coordinates in the instance */
};
......@@ -63,6 +59,7 @@ struct _GeglSamplerClass
void (* get) (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output);
void (*set_buffer) (GeglSampler *self,
GeglBuffer *buffer);
......@@ -75,11 +72,10 @@ void gegl_sampler_prepare (GeglSampler *self);
void gegl_sampler_set_buffer (GeglSampler *self,
GeglBuffer *buffer);
void gegl_sampler_set_scale (GeglSampler *self,
GeglMatrix2 *scale);
void gegl_sampler_get (GeglSampler *self,
gdouble x,
gdouble y,
GeglMatrix2 *scale,
void *output);
gfloat * gegl_sampler_get_from_buffer (GeglSampler *sampler,
......
......@@ -680,8 +680,6 @@ affine_generic (GeglBuffer *dest,
inverse_jacobian.coeff[1][1] = inverse.coeff[1][1];
/* set inverse_jacobian for samplers that support it */
sampler->inverse_jacobian = &inverse_jacobian;
u_start = inverse.coeff[0][0] * roi->x + inverse.coeff[0][1]
* roi->y + inverse.coeff[0][2];
v_start = inverse.coeff[1][0] * roi->x + inverse.coeff[1][1]
......@@ -698,7 +696,7 @@ affine_generic (GeglBuffer *dest,
for (x = roi->width; x--;)
{
gegl_sampler_get (sampler, u_float, v_float, dest_ptr);
gegl_sampler_get (sampler, u_float, v_float, &inverse_jacobian, dest_ptr);
dest_ptr+=4;
u_float += inverse.coeff [0][0];
v_float += inverse.coeff [1][0];
......
......@@ -97,7 +97,7 @@ process (GeglOperation *operation,
}
else
{
gegl_sampler_get (sampler, coords[0], coords[1], out);
gegl_sampler_get (sampler, coords[0], coords[1], NULL, out);
}
coords += 2;
......
......@@ -106,7 +106,8 @@ process (GeglOperation *operation,
else
{
gegl_sampler_get (sampler, x+coords[0] * scaling,
y+coords[1] * scaling, out);
y+coords[1] * scaling,
NULL, out);
}
coords += 2;
......
......@@ -158,8 +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_set_scale (sampler, &scale);
gegl_sampler_get (sampler, cx, cy, &dst_buf[(row * roi->width + col) * 4]);
gegl_sampler_get (sampler, cx, cy, &scale, &dst_buf[(row * roi->width + col) * 4]);
} /* for */
} /* for */
......
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