[gegl] tests: port test suite to new iterator api



commit 0c678671e509ec39ecc01059332476a134622a6e
Author: Øyvind Kolås <pippin gimp org>
Date:   Mon Sep 10 16:24:35 2018 +0200

    tests: port test suite to new iterator api

 tests/buffer/buffer-test.c                  |  6 ++++--
 tests/buffer/tests/buffer_linear_iter.c     |  8 +++++---
 tests/buffer/tests/buffer_linear_iter2.c    |  8 +++++---
 tests/buffer/tests/buffer_multcopy.c        |  9 ++++++---
 tests/buffer/tests/linear_shift.c           | 20 ++++++++++++--------
 tests/buffer/tests/mipmap_iterator.c        |  4 ++--
 tests/buffer/tests/mipmap_iterator2.c       |  4 ++--
 tests/buffer/tests/mipmap_sampler.c         |  8 ++++----
 tests/simple/test-buffer-changes.c          |  4 ++--
 tests/simple/test-buffer-unaligned-access.c |  7 ++++---
 10 files changed, 46 insertions(+), 32 deletions(-)
---
diff --git a/tests/buffer/buffer-test.c b/tests/buffer/buffer-test.c
index 7ad4c7e12..7a395da3e 100644
--- a/tests/buffer/buffer-test.c
+++ b/tests/buffer/buffer-test.c
@@ -1,3 +1,5 @@
+#define GEGL_ITERATOR2_API
+
 #include "config.h"
 #include <gegl.h>
 #include <gegl-buffer.h>
@@ -293,10 +295,10 @@ static void fill_rect (GeglBuffer          *buffer,
 {
   GeglBufferIterator *gi;
   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))
     {
-      gfloat *buf = gi->data[0];
+      gfloat *buf = gi->items[0].data;
       gint    i;
       for (i=0; i<gi->length; i++)
         {
diff --git a/tests/buffer/tests/buffer_linear_iter.c b/tests/buffer/tests/buffer_linear_iter.c
index bd2a2be28..67f119316 100644
--- a/tests/buffer/tests/buffer_linear_iter.c
+++ b/tests/buffer/tests/buffer_linear_iter.c
@@ -1,3 +1,5 @@
+#define GEGL_ITERATOR2_API
+
 TEST ()
 {
   GeglBuffer    *buffer, *buffer2;
@@ -22,15 +24,15 @@ TEST ()
   fill (buffer2, 1.0);
 
   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_ACCESS_WRITE, GEGL_ABYSS_NONE);
 
   while (gegl_buffer_iterator_next (iter))
     {
-      gfloat *s = iter->data[0];
-      gfloat *d = iter->data[1];
+      gfloat *s = iter->items[0].data;
+      gfloat *d = iter->items[1].data;
       gint length = iter->length;
 
       while (length--)
diff --git a/tests/buffer/tests/buffer_linear_iter2.c b/tests/buffer/tests/buffer_linear_iter2.c
index 9ea84e2d9..f98229619 100644
--- a/tests/buffer/tests/buffer_linear_iter2.c
+++ b/tests/buffer/tests/buffer_linear_iter2.c
@@ -1,3 +1,5 @@
+#define GEGL_ITERATOR2_API
+
 TEST ()
 {
   GeglBuffer    *buffer, *buffer2;
@@ -19,15 +21,15 @@ TEST ()
   fill (buffer2, 1.0);
 
   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_WRITE, GEGL_ABYSS_NONE);
 
   while (gegl_buffer_iterator_next (iter))
     {
-      gfloat *s = iter->data[0];
-      gfloat *d = iter->data[1];
+      gfloat *s = iter->items[0].data;
+      gfloat *d = iter->items[1].data;
       gint length = iter->length;
 
       while (length--)
diff --git a/tests/buffer/tests/buffer_multcopy.c b/tests/buffer/tests/buffer_multcopy.c
index 3b5bdfb4e..fb867edd9 100644
--- a/tests/buffer/tests/buffer_multcopy.c
+++ b/tests/buffer/tests/buffer_multcopy.c
@@ -1,3 +1,6 @@
+#define GEGL_ITERATOR2_API
+
+
 TEST ()
 {
   GeglBuffer    *buffer, *buffer2;
@@ -27,15 +30,15 @@ TEST ()
           fill (buffer2, 1.0);
 
           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_ACCESS_WRITE, GEGL_ABYSS_NONE);
 
           while (gegl_buffer_iterator_next (iter))
             {
-              gfloat *s = iter->data[0];
-              gfloat *d = iter->data[1];
+              gfloat *s = iter->items[0].data;
+              gfloat *d = iter->items[1].data;
               gint length = iter->length;
 
               while (length--)
diff --git a/tests/buffer/tests/linear_shift.c b/tests/buffer/tests/linear_shift.c
index 196201437..dbd7a8eaa 100644
--- a/tests/buffer/tests/linear_shift.c
+++ b/tests/buffer/tests/linear_shift.c
@@ -48,7 +48,7 @@ TEST ()
   out = gegl_buffer_new (&out_extent, babl_format ("Y float"));
 
   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_ACCESS_READ, GEGL_ABYSS_BLACK);
@@ -67,14 +67,18 @@ TEST ()
       gint ix, iy, pos;
 
       pos = 0;
-      for (iy = iter->roi[0].y; iy < iter->roi[0].y + iter->roi[0].height; ++iy)
-        for (ix = iter->roi[0].x; ix < iter->roi[0].x + iter->roi[0].width; ++ix)
+      for (iy = iter->items[0].roi.y; iy < iter->items[0].roi.y + iter->items[0].roi.height; ++iy)
+        for (ix = iter->items[0].roi.x; ix < iter->items[0].roi.x + iter->items[0].roi.width; ++ix)
           {
-            gfloat **fdata = (gfloat **)iter->data;
-
-            fdata[0][pos] = fdata[1][pos] + fdata[2][pos] + fdata[3][pos] + fdata[4][pos];
-            if (fdata[0][pos] > 1.0f)
-              fdata[0][pos] = 1.0f;
+            gfloat *fdata0 = (gfloat *)iter->items[0].data;
+            gfloat *fdata1 = (gfloat *)iter->items[1].data;
+            gfloat *fdata2 = (gfloat *)iter->items[2].data;
+            gfloat *fdata3 = (gfloat *)iter->items[3].data;
+            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;
           }
diff --git a/tests/buffer/tests/mipmap_iterator.c b/tests/buffer/tests/mipmap_iterator.c
index 5c1fad873..a00375dd0 100644
--- a/tests/buffer/tests/mipmap_iterator.c
+++ b/tests/buffer/tests/mipmap_iterator.c
@@ -24,11 +24,11 @@ TEST ()
 
   {
     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))
     {
       int i;
-      gfloat *d = iterator->data[0];
+      gfloat *d = iterator->items[0].data;
       for (i = 0; i < iterator->length; i++)
         d[i] = 0;
     }
diff --git a/tests/buffer/tests/mipmap_iterator2.c b/tests/buffer/tests/mipmap_iterator2.c
index d9c527624..dee3044a9 100644
--- a/tests/buffer/tests/mipmap_iterator2.c
+++ b/tests/buffer/tests/mipmap_iterator2.c
@@ -13,11 +13,11 @@ TEST ()
 
   {
     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))
     {
       int i;
-      gfloat *d = iterator->data[0];
+      gfloat *d = iterator->items[0].data;
       for (i = 0; i < iterator->length; i++)
         d[i] = d[i] + 0.5;
     }
diff --git a/tests/buffer/tests/mipmap_sampler.c b/tests/buffer/tests/mipmap_sampler.c
index a006b4ee3..c07e18149 100644
--- a/tests/buffer/tests/mipmap_sampler.c
+++ b/tests/buffer/tests/mipmap_sampler.c
@@ -14,22 +14,22 @@ TEST ()
 
   {
     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))
     {
       int i;
-      gfloat *d = iterator->data[0];
+      gfloat *d = iterator->items[0].data;
       for (i = 0; i < iterator->length; i++)
         d[i] = 1.0 * i / iterator->length / 2;
     }
   }
   {
     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))
     {
       int i;
-      gfloat *d = iterator->data[0];
+      gfloat *d = iterator->items[0].data;
       for (i = 0; i < iterator->length; i++)
         d[i] += (1.0 * i / iterator->length/2);
     }
diff --git a/tests/simple/test-buffer-changes.c b/tests/simple/test-buffer-changes.c
index d878406dc..d33191bde 100644
--- a/tests/simple/test-buffer-changes.c
+++ b/tests/simple/test-buffer-changes.c
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
  */
-
+#define GEGL_ITERATOR2_API
 #include <gegl.h>
 
 typedef struct {
@@ -105,7 +105,7 @@ test_buffer_change_signal_with_iter(guint access_method, guint expected_signal_c
     GeglRectangle rect = {0, 0, 100, 100};
     char *tmp = g_malloc(rect.height*rect.width*1*4);
     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);
 
diff --git a/tests/simple/test-buffer-unaligned-access.c b/tests/simple/test-buffer-unaligned-access.c
index f7836f2d9..ebdf0c232 100644
--- a/tests/simple/test-buffer-unaligned-access.c
+++ b/tests/simple/test-buffer-unaligned-access.c
@@ -16,6 +16,7 @@
  * Copyright (C) 2018 Ell
  */
 
+#define GEGL_ITERATOR2_API
 #include "config.h"
 
 #include <stddef.h>
@@ -131,12 +132,12 @@ test_unaligned_fill (FillFunc fill_func)
   g_object_unref (color);
 
   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))
     {
-      const guchar        *src = iter->data[0];
-      const GeglRectangle *roi = &iter->roi[0];
+      const guchar        *src = iter->items[0].data;
+      const GeglRectangle *roi = &iter->items[0].roi;
       gint                 x;
       gint                 y;
 


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