tests: port test suite to new iterator api

parent b849ee4b
#define GEGL_ITERATOR2_API
#include "config.h" #include "config.h"
#include <gegl.h> #include <gegl.h>
#include <gegl-buffer.h> #include <gegl-buffer.h>
...@@ -293,10 +295,10 @@ static void fill_rect (GeglBuffer *buffer, ...@@ -293,10 +295,10 @@ static void fill_rect (GeglBuffer *buffer,
{ {
GeglBufferIterator *gi; GeglBufferIterator *gi;
gi = gegl_buffer_iterator_new (buffer, roi, 0, NULL, gi = gegl_buffer_iterator_new (buffer, roi, 0, NULL,
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE); GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE, 1);
while (gegl_buffer_iterator_next (gi)) while (gegl_buffer_iterator_next (gi))
{ {
gfloat *buf = gi->data[0]; gfloat *buf = gi->items[0].data;
gint i; gint i;
for (i=0; i<gi->length; i++) for (i=0; i<gi->length; i++)
{ {
......
#define GEGL_ITERATOR2_API
TEST () TEST ()
{ {
GeglBuffer *buffer, *buffer2; GeglBuffer *buffer, *buffer2;
...@@ -22,15 +24,15 @@ TEST () ...@@ -22,15 +24,15 @@ TEST ()
fill (buffer2, 1.0); fill (buffer2, 1.0);
iter = gegl_buffer_iterator_new (buffer2, &source, 0, NULL, iter = gegl_buffer_iterator_new (buffer2, &source, 0, NULL,
GEGL_ACCESS_READ, GEGL_ABYSS_NONE); GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 4);
gegl_buffer_iterator_add (iter, buffer, &source, 0, NULL, gegl_buffer_iterator_add (iter, buffer, &source, 0, NULL,
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE); GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (iter)) while (gegl_buffer_iterator_next (iter))
{ {
gfloat *s = iter->data[0]; gfloat *s = iter->items[0].data;
gfloat *d = iter->data[1]; gfloat *d = iter->items[1].data;
gint length = iter->length; gint length = iter->length;
while (length--) while (length--)
......
#define GEGL_ITERATOR2_API
TEST () TEST ()
{ {
GeglBuffer *buffer, *buffer2; GeglBuffer *buffer, *buffer2;
...@@ -19,15 +21,15 @@ TEST () ...@@ -19,15 +21,15 @@ TEST ()
fill (buffer2, 1.0); fill (buffer2, 1.0);
iter = gegl_buffer_iterator_new (buffer2, &source, 0, NULL, iter = gegl_buffer_iterator_new (buffer2, &source, 0, NULL,
GEGL_BUFFER_READ, GEGL_ABYSS_NONE); GEGL_BUFFER_READ, GEGL_ABYSS_NONE, 4);
gegl_buffer_iterator_add (iter, buffer, &source, 0, NULL, gegl_buffer_iterator_add (iter, buffer, &source, 0, NULL,
GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE); GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (iter)) while (gegl_buffer_iterator_next (iter))
{ {
gfloat *s = iter->data[0]; gfloat *s = iter->items[0].data;
gfloat *d = iter->data[1]; gfloat *d = iter->items[1].data;
gint length = iter->length; gint length = iter->length;
while (length--) while (length--)
......
#define GEGL_ITERATOR2_API
TEST () TEST ()
{ {
GeglBuffer *buffer, *buffer2; GeglBuffer *buffer, *buffer2;
...@@ -27,15 +30,15 @@ TEST () ...@@ -27,15 +30,15 @@ TEST ()
fill (buffer2, 1.0); fill (buffer2, 1.0);
iter = gegl_buffer_iterator_new (buffer2, &source, 0, NULL, iter = gegl_buffer_iterator_new (buffer2, &source, 0, NULL,
GEGL_ACCESS_READ, GEGL_ABYSS_NONE); GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 4);
gegl_buffer_iterator_add (iter, buffer, &source, 0, NULL, gegl_buffer_iterator_add (iter, buffer, &source, 0, NULL,
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE); GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
while (gegl_buffer_iterator_next (iter)) while (gegl_buffer_iterator_next (iter))
{ {
gfloat *s = iter->data[0]; gfloat *s = iter->items[0].data;
gfloat *d = iter->data[1]; gfloat *d = iter->items[1].data;
gint length = iter->length; gint length = iter->length;
while (length--) while (length--)
......
...@@ -48,7 +48,7 @@ TEST () ...@@ -48,7 +48,7 @@ TEST ()
out = gegl_buffer_new (&out_extent, babl_format ("Y float")); out = gegl_buffer_new (&out_extent, babl_format ("Y float"));
iter = gegl_buffer_iterator_new (out, &out_extent, 0, NULL, iter = gegl_buffer_iterator_new (out, &out_extent, 0, NULL,
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE); GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE, 8);
gegl_buffer_iterator_add (iter, linear_a, &out_extent, 0, NULL, gegl_buffer_iterator_add (iter, linear_a, &out_extent, 0, NULL,
GEGL_ACCESS_READ, GEGL_ABYSS_BLACK); GEGL_ACCESS_READ, GEGL_ABYSS_BLACK);
...@@ -67,14 +67,18 @@ TEST () ...@@ -67,14 +67,18 @@ TEST ()
gint ix, iy, pos; gint ix, iy, pos;
pos = 0; pos = 0;
for (iy = iter->roi[0].y; iy < iter->roi[0].y + iter->roi[0].height; ++iy) for (iy = iter->items[0].roi.y; iy < iter->items[0].roi.y + iter->items[0].roi.height; ++iy)
for (ix = iter->roi[0].x; ix < iter->roi[0].x + iter->roi[0].width; ++ix) for (ix = iter->items[0].roi.x; ix < iter->items[0].roi.x + iter->items[0].roi.width; ++ix)
{ {
gfloat **fdata = (gfloat **)iter->data; gfloat *fdata0 = (gfloat *)iter->items[0].data;
gfloat *fdata1 = (gfloat *)iter->items[1].data;
fdata[0][pos] = fdata[1][pos] + fdata[2][pos] + fdata[3][pos] + fdata[4][pos]; gfloat *fdata2 = (gfloat *)iter->items[2].data;
if (fdata[0][pos] > 1.0f) gfloat *fdata3 = (gfloat *)iter->items[3].data;
fdata[0][pos] = 1.0f; gfloat *fdata4 = (gfloat *)iter->items[4].data;
fdata0[pos] = fdata1[pos] + fdata2[pos] + fdata3[pos] + fdata4[pos];
if (fdata0[pos] > 1.0f)
fdata0[pos] = 1.0f;
++pos; ++pos;
} }
......
...@@ -24,11 +24,11 @@ TEST () ...@@ -24,11 +24,11 @@ TEST ()
{ {
GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2, GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2,
&dest, 1, babl_format ("Y float"), GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE); &dest, 1, babl_format ("Y float"), GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE, 1);
while (gegl_buffer_iterator_next (iterator)) while (gegl_buffer_iterator_next (iterator))
{ {
int i; int i;
gfloat *d = iterator->data[0]; gfloat *d = iterator->items[0].data;
for (i = 0; i < iterator->length; i++) for (i = 0; i < iterator->length; i++)
d[i] = 0; d[i] = 0;
} }
......
...@@ -13,11 +13,11 @@ TEST () ...@@ -13,11 +13,11 @@ TEST ()
{ {
GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2, GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2,
&dest, 1, babl_format ("Y float"), GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE); &dest, 1, babl_format ("Y float"), GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE, 1);
while (gegl_buffer_iterator_next (iterator)) while (gegl_buffer_iterator_next (iterator))
{ {
int i; int i;
gfloat *d = iterator->data[0]; gfloat *d = iterator->items[0].data;
for (i = 0; i < iterator->length; i++) for (i = 0; i < iterator->length; i++)
d[i] = d[i] + 0.5; d[i] = d[i] + 0.5;
} }
......
...@@ -14,22 +14,22 @@ TEST () ...@@ -14,22 +14,22 @@ TEST ()
{ {
GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2, GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2,
&dest, 1, babl_format ("Y float"), GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE); &dest, 1, babl_format ("Y float"), GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE, 1);
while (gegl_buffer_iterator_next (iterator)) while (gegl_buffer_iterator_next (iterator))
{ {
int i; int i;
gfloat *d = iterator->data[0]; gfloat *d = iterator->items[0].data;
for (i = 0; i < iterator->length; i++) for (i = 0; i < iterator->length; i++)
d[i] = 1.0 * i / iterator->length / 2; d[i] = 1.0 * i / iterator->length / 2;
} }
} }
{ {
GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2, GeglBufferIterator *iterator = gegl_buffer_iterator_new (buffer2,
&dest, 1, babl_format ("Y float"), GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE); &dest, 1, babl_format ("Y float"), GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE, 1);
while (gegl_buffer_iterator_next (iterator)) while (gegl_buffer_iterator_next (iterator))
{ {
int i; int i;
gfloat *d = iterator->data[0]; gfloat *d = iterator->items[0].data;
for (i = 0; i < iterator->length; i++) for (i = 0; i < iterator->length; i++)
d[i] += (1.0 * i / iterator->length/2); d[i] += (1.0 * i / iterator->length/2);
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <https://www.gnu.org/licenses/>. * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
*/ */
#define GEGL_ITERATOR2_API
#include <gegl.h> #include <gegl.h>
typedef struct { typedef struct {
...@@ -105,7 +105,7 @@ test_buffer_change_signal_with_iter(guint access_method, guint expected_signal_c ...@@ -105,7 +105,7 @@ test_buffer_change_signal_with_iter(guint access_method, guint expected_signal_c
GeglRectangle rect = {0, 0, 100, 100}; GeglRectangle rect = {0, 0, 100, 100};
char *tmp = g_malloc(rect.height*rect.width*1*4); char *tmp = g_malloc(rect.height*rect.width*1*4);
GeglBufferIterator *gi = gegl_buffer_iterator_new(test_case->buffer, &rect, 0, GeglBufferIterator *gi = gegl_buffer_iterator_new(test_case->buffer, &rect, 0,
test_case->buffer_format, access_method, GEGL_ABYSS_NONE); test_case->buffer_format, access_method, GEGL_ABYSS_NONE, 1);
gegl_buffer_signal_connect(test_case->buffer, "changed", (GCallback)handle_buffer_changed, test_case); gegl_buffer_signal_connect(test_case->buffer, "changed", (GCallback)handle_buffer_changed, test_case);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* Copyright (C) 2018 Ell * Copyright (C) 2018 Ell
*/ */
#define GEGL_ITERATOR2_API
#include "config.h" #include "config.h"
#include <stddef.h> #include <stddef.h>
...@@ -131,12 +132,12 @@ test_unaligned_fill (FillFunc fill_func) ...@@ -131,12 +132,12 @@ test_unaligned_fill (FillFunc fill_func)
g_object_unref (color); g_object_unref (color);
iter = gegl_buffer_iterator_new (buffer, NULL, 0, format, iter = gegl_buffer_iterator_new (buffer, NULL, 0, format,
GEGL_BUFFER_READ, GEGL_ABYSS_NONE); GEGL_BUFFER_READ, GEGL_ABYSS_NONE, 1);
while (gegl_buffer_iterator_next (iter)) while (gegl_buffer_iterator_next (iter))
{ {
const guchar *src = iter->data[0]; const guchar *src = iter->items[0].data;
const GeglRectangle *roi = &iter->roi[0]; const GeglRectangle *roi = &iter->items[0].roi;
gint x; gint x;
gint y; gint y;
......
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