Commit 6ba86f8b authored by Daniel Sabo's avatar Daniel Sabo

waves: Don't linearize buffer

parent 64aacbe3
......@@ -87,19 +87,12 @@ process (GeglOperation *operation,
const GeglRectangle *result,
gint level)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gint x = result->x; /* initial x */
gint y = result->y; /* and y coordinates */
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglSampler *sampler = gegl_buffer_sampler_new (input,
babl_format ("RGBA float"),
o->sampler_type);
GeglBufferIterator *iter;
gfloat *dst_buf = g_slice_alloc (result->width * result->height * 4 * sizeof (gfloat));
gfloat *out_pixel = dst_buf;
GeglSampler *sampler = gegl_buffer_sampler_new (input,
babl_format ("RGBA float"),
o->sampler_type);
gint n_pixels = result->width * result->height;
GeglAbyssPolicy abyss = o->clamp ? GEGL_ABYSS_CLAMP : GEGL_ABYSS_NONE;
gdouble scalex;
......@@ -121,49 +114,47 @@ process (GeglOperation *operation,
scaley = 1.0;
}
while (n_pixels--)
iter = gegl_buffer_iterator_new (output, result, 0, babl_format ("RGBA float"),
GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (iter))
{
gdouble radius;
gdouble shift;
gdouble dx;
gdouble dy;
gdouble ux;
gdouble uy;
dx = (x - o->x) * scalex;
dy = (y - o->y) * scaley;
radius = sqrt (dx * dx + dy * dy);
shift = o->amplitude * sin (2.0 * G_PI * radius / o->period +
2.0 * G_PI * o->phi);
ux = dx / radius;
uy = dy / radius;
gegl_sampler_get (sampler,
x + (shift + ux) / scalex,
y + (shift + uy) / scaley,
NULL,
out_pixel,
abyss);
out_pixel += 4;
/* update x and y coordinates */
x++;
if (x >= result->x + result->width)
{
x = result->x;
y++;
}
gint x = result->x;
gint y = result->y;
gfloat *out_pixel = iter->data[0];
for (y = iter->roi[0].y; y < iter->roi[0].y + iter->roi[0].height; ++y)
for (x = iter->roi[0].x; x < iter->roi[0].x + iter->roi[0].width; ++x)
{
gdouble radius;
gdouble shift;
gdouble dx;
gdouble dy;
gdouble ux;
gdouble uy;
dx = (x - o->x) * scalex;
dy = (y - o->y) * scaley;
radius = sqrt (dx * dx + dy * dy);
shift = o->amplitude * sin (2.0 * G_PI * radius / o->period +
2.0 * G_PI * o->phi);
ux = dx / radius;
uy = dy / radius;
gegl_sampler_get (sampler,
x + (shift + ux) / scalex,
y + (shift + uy) / scaley,
NULL,
out_pixel,
abyss);
out_pixel += 4;
}
}
gegl_buffer_set (output, result, 0, babl_format ("RGBA float"),
dst_buf, GEGL_AUTO_ROWSTRIDE);
g_slice_free1 (result->width * result->height * 4 * sizeof (gfloat), dst_buf);
g_object_unref (sampler);
return TRUE;
......
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