[gegl/gsoc2009-gpu] Make all values hardcoded values macro-defineable in all automated test-suites



commit aa5578cc371ab595d8a80e4123191b16914e24d2
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date:   Thu Aug 20 06:31:35 2009 +0800

    Make all values hardcoded values macro-defineable in all automated test-suites

 tests/test-gegl-gpu-texture-clear-subrect.c        |   44 ++++++++++---
 tests/test-gegl-gpu-texture-clear.c                |   14 +++-
 tests/test-gegl-gpu-texture-copy-subrect.c         |   65 +++++++++++++-----
 tests/test-gegl-gpu-texture-copy.c                 |   35 ++++++----
 tests/test-gegl-gpu-texture-set-subrect.c          |   70 ++++++++++++++-----
 tests/test-gegl-gpu-texture-set.c                  |   31 +++++----
 tests/test-gegl-tile-cow-consistency.c             |   19 ++++--
 tests/test-gegl-tile-cow.c                         |    8 ++-
 ...t-gegl-tile-lock-mode-gpu-write-then-gpu-read.c |   31 ++++++---
 .../test-gegl-tile-lock-mode-gpu-write-then-read.c |   26 +++++---
 .../test-gegl-tile-lock-mode-write-then-gpu-read.c |   34 +++++++---
 tests/test-gegl-tile-lock-mode-write-then-read.c   |   33 ++++++---
 12 files changed, 288 insertions(+), 122 deletions(-)
---
diff --git a/tests/test-gegl-gpu-texture-clear-subrect.c b/tests/test-gegl-gpu-texture-clear-subrect.c
index ab54378..9c0375a 100644
--- a/tests/test-gegl-gpu-texture-clear-subrect.c
+++ b/tests/test-gegl-gpu-texture-clear-subrect.c
@@ -27,6 +27,12 @@
 
 #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define TEST_STRIP_WIDTH  10
+#define TEST_STRIP_HEIGHT 10
+
 typedef struct GeglGpuTextureClearSubrectTestCase
 {
   gchar        *name;
@@ -44,23 +50,40 @@ main (gint    argc,
     {
       {
         "top-left corner",
-        { 0,  0, 10, 10}
+        { 0,  0, TEST_STRIP_WIDTH, TEST_STRIP_HEIGHT}
       },
       {
         "top-right corner",
-        {40,  0, 10, 10}
+        {
+          TEXTURE_WIDTH - TEST_STRIP_WIDTH,
+          0,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "bottom-left corner",
-        { 0, 40, 10, 10}
+        {
+          0,
+          TEXTURE_HEIGHT - TEST_STRIP_HEIGHT,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "bottom-right corner",
-        {40, 40, 10, 10}
+        {
+          TEXTURE_WIDTH - TEST_STRIP_WIDTH,
+          TEXTURE_HEIGHT - TEST_STRIP_HEIGHT,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "center",
-        {20, 20, 10, 10}
+        {
+          (TEXTURE_WIDTH - TEST_STRIP_WIDTH) / 2,
+          (TEXTURE_HEIGHT - TEST_STRIP_HEIGHT) / 2,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT
+        }
       }
     };
 
@@ -69,8 +92,11 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  texture    = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
-  components = g_new (gfloat, 50 * 50 * 4);
+  texture = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                  TEXTURE_HEIGHT,
+                                  babl_format ("RGBA float"));
+
+  components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint   cnt;
@@ -81,7 +107,7 @@ main (gint    argc,
       color[2] = g_random_double ();
       color[3] = g_random_double ();
 
-      for (cnt = 0; cnt < 50 * 50; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT; cnt++)
         {
           gint index = cnt * 4;
 
@@ -114,7 +140,7 @@ main (gint    argc,
           for (y = test_cases[cnt].roi.y; y <= last_y; y++)
             for (x = test_cases[cnt].roi.x; x <= last_x; x++)
               {
-                gfloat *pixel = &components[((y * 50) + x) * 4];
+                gfloat *pixel = &components[((y * TEXTURE_WIDTH) + x) * 4];
 
                 if (   !GEGL_FLOAT_IS_ZERO (pixel[0])
                     || !GEGL_FLOAT_IS_ZERO (pixel[1])
diff --git a/tests/test-gegl-gpu-texture-clear.c b/tests/test-gegl-gpu-texture-clear.c
index b115f7b..c853187 100644
--- a/tests/test-gegl-gpu-texture-clear.c
+++ b/tests/test-gegl-gpu-texture-clear.c
@@ -25,6 +25,9 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -36,8 +39,11 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  texture    = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
-  components = g_new (gfloat, 50 * 50 * 4);
+  texture = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                  TEXTURE_HEIGHT,
+                                  babl_format ("RGBA float"));
+
+  components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint   cnt;
@@ -48,7 +54,7 @@ main (gint    argc,
       color[2] = g_random_double ();
       color[3] = g_random_double ();
 
-      for (cnt = 0; cnt < 50 * 50; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT; cnt++)
         {
           gint index = cnt * 4;
 
@@ -68,7 +74,7 @@ main (gint    argc,
       gegl_gpu_texture_clear (texture, NULL);
       gegl_gpu_texture_get   (texture, NULL, components, NULL);
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_IS_ZERO (components[cnt]))
           {
             g_printerr ("The gegl_gpu_texture_clear() test failed. "
diff --git a/tests/test-gegl-gpu-texture-copy-subrect.c b/tests/test-gegl-gpu-texture-copy-subrect.c
index 8ba60e6..3763807 100644
--- a/tests/test-gegl-gpu-texture-copy-subrect.c
+++ b/tests/test-gegl-gpu-texture-copy-subrect.c
@@ -28,6 +28,14 @@
 
 #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define TEST_STRIP_WIDTH  10
+#define TEST_STRIP_HEIGHT 10
+
+#define RANDOM_PIXEL_COUNT 1000
+
 typedef struct GeglGpuTextureCopySubrectTestCase
 {
   gchar        *name;
@@ -45,23 +53,40 @@ main (gint    argc,
     {
       {
         "top-left corner",
-        { 0,  0, 10, 10}
+        { 0,  0, TEST_STRIP_WIDTH, TEST_STRIP_HEIGHT}
       },
       {
         "top-right corner",
-        {40,  0, 10, 10}
+        {
+          TEXTURE_WIDTH - TEST_STRIP_WIDTH,
+          0,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "bottom-left corner",
-        { 0, 40, 10, 10}
+        {
+          0,
+          TEXTURE_HEIGHT - TEST_STRIP_HEIGHT,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "bottom-right corner",
-        {40, 40, 10, 10}
+        {
+          TEXTURE_WIDTH - TEST_STRIP_WIDTH,
+          TEXTURE_HEIGHT - TEST_STRIP_HEIGHT,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "center",
-        {20, 20, 10, 10}
+        {
+          (TEXTURE_WIDTH - TEST_STRIP_WIDTH) / 2,
+          (TEXTURE_HEIGHT - TEST_STRIP_HEIGHT) / 2,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT
+        }
       }
     };
 
@@ -73,26 +98,30 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  texture1 = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
-  texture2 = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+  texture1 = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                   TEXTURE_HEIGHT,
+                                   babl_format ("RGBA float"));
+  texture2 = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                   TEXTURE_HEIGHT,
+                                   babl_format ("RGBA float"));
 
-  components1 = g_new0 (gfloat, 50 * 50 * 4);
-  components2 = g_new0 (gfloat, 50 * 50 * 4);
+  components1 = g_new0 (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
+  components2 = g_new0 (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint cnt;
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components1[((y * 50) + x) * 4];
+          gfloat *pixel = &components1[((y * TEXTURE_WIDTH) + x) * 4];
 
-          pixel[0] = g_random_double();
-          pixel[1] = g_random_double();
-          pixel[2] = g_random_double();
-          pixel[3] = g_random_double();
+          pixel[0] = g_random_double ();
+          pixel[1] = g_random_double ();
+          pixel[2] = g_random_double ();
+          pixel[3] = g_random_double ();
         }
 
       /* set the texture to a random image (note: this test assumes that
@@ -124,7 +153,7 @@ main (gint    argc,
           for (y = test_cases[cnt].roi.y; y <= last_y; y++)
             for (x = test_cases[cnt].roi.x; x <= last_x; x++)
               {
-                gint index = ((y * 50) + x) * 4;
+                gint index = ((y * TEXTURE_WIDTH) + x) * 4;
 
                 gfloat *pixel1 = &components1[index];
                 gfloat *pixel2 = &components2[index];
diff --git a/tests/test-gegl-gpu-texture-copy.c b/tests/test-gegl-gpu-texture-copy.c
index 77c7e47..f1bf54d 100644
--- a/tests/test-gegl-gpu-texture-copy.c
+++ b/tests/test-gegl-gpu-texture-copy.c
@@ -25,6 +25,11 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define RANDOM_PIXEL_COUNT 1000
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -39,26 +44,30 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  texture1 = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
-  texture2 = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+  texture1 = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                   TEXTURE_HEIGHT,
+                                   babl_format ("RGBA float"));
+  texture2 = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                   TEXTURE_HEIGHT,
+                                   babl_format ("RGBA float"));
 
-  components1 = g_new (gfloat, 50 * 50 * 4);
-  components2 = g_new (gfloat, 50 * 50 * 4);
+  components1 = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
+  components2 = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint cnt;
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components1[((y * 50) + x) * 4];
+          gfloat *pixel = &components1[((y * TEXTURE_WIDTH) + x) * 4];
 
-          pixel[0] = g_random_double();
-          pixel[1] = g_random_double();
-          pixel[2] = g_random_double();
-          pixel[3] = g_random_double();
+          pixel[0] = g_random_double ();
+          pixel[1] = g_random_double ();
+          pixel[2] = g_random_double ();
+          pixel[3] = g_random_double ();
         }
 
       /* set the texture to a random image (note: this test assumes that
@@ -71,7 +80,7 @@ main (gint    argc,
       gegl_gpu_texture_get  (texture2, NULL, components2, NULL);
 
       /* compare the two textures */
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (components1[cnt], components2[cnt]))
           {
             g_printerr ("The gegl_gpu_texture_copy() test failed. "
diff --git a/tests/test-gegl-gpu-texture-set-subrect.c b/tests/test-gegl-gpu-texture-set-subrect.c
index 96c6e5d..f93ba44 100644
--- a/tests/test-gegl-gpu-texture-set-subrect.c
+++ b/tests/test-gegl-gpu-texture-set-subrect.c
@@ -28,6 +28,14 @@
 
 #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define TEST_STRIP_WIDTH  10
+#define TEST_STRIP_HEIGHT 10
+
+#define RANDOM_PIXEL_COUNT 400
+
 typedef struct GeglGpuTextureSetSubrectTestCase
 {
   gchar        *name;
@@ -45,23 +53,40 @@ main (gint    argc,
     {
       {
         "top-left corner",
-        { 0,  0, 10, 10}
+        { 0,  0, TEST_STRIP_WIDTH, TEST_STRIP_HEIGHT}
       },
       {
         "top-right corner",
-        {40,  0, 10, 10}
+        {
+          TEXTURE_WIDTH - TEST_STRIP_WIDTH,
+          0,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "bottom-left corner",
-        { 0, 40, 10, 10}
+        {
+          0,
+          TEXTURE_HEIGHT - TEST_STRIP_HEIGHT,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "bottom-right corner",
-        {40, 40, 10, 10}
+        {
+          TEXTURE_WIDTH - TEST_STRIP_WIDTH,
+          TEXTURE_HEIGHT - TEST_STRIP_HEIGHT,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT}
       },
       {
         "center",
-        {20, 20, 10, 10}
+        {
+          (TEXTURE_WIDTH - TEST_STRIP_WIDTH) / 2,
+          (TEXTURE_HEIGHT - TEST_STRIP_HEIGHT) / 2,
+          TEST_STRIP_WIDTH,
+          TEST_STRIP_HEIGHT
+        }
       }
     };
 
@@ -72,10 +97,12 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  texture = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+  texture = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                  TEXTURE_HEIGHT,
+                                  babl_format ("RGBA float"));
 
-  components1 = g_new (gfloat, 10 * 10 * 4);
-  components2 = g_new (gfloat, 10 * 10 * 4);
+  components1 = g_new0 (gfloat, TEST_STRIP_WIDTH * TEST_STRIP_HEIGHT * 4);
+  components2 = g_new0 (gfloat, TEST_STRIP_WIDTH * TEST_STRIP_HEIGHT * 4);
 
     {
       gint i;
@@ -84,20 +111,25 @@ main (gint    argc,
         {
           gint j;
 
-          memset (components1, 0, sizeof (gfloat) * 10 * 10 * 4);
-          memset (components2, 0, sizeof (gfloat) * 10 * 10 * 4);
+          memset (components1, 0, sizeof (gfloat)
+                                    * TEST_STRIP_WIDTH
+                                    * TEST_STRIP_HEIGHT * 4);
+
+          memset (components2, 0, sizeof (gfloat)
+                                    * TEST_STRIP_WIDTH
+                                    * TEST_STRIP_HEIGHT * 4);
 
-          for (j = 0; j < 400; j++)
+          for (j = 0; j < RANDOM_PIXEL_COUNT; j++)
             {
-              gint x = g_random_int_range (0, 10);
-              gint y = g_random_int_range (0, 10);
+              gint x = g_random_int_range (0, TEST_STRIP_WIDTH);
+              gint y = g_random_int_range (0, TEST_STRIP_HEIGHT);
 
-              gfloat *pixel = &components1[((y * 10) + x) * 4];
+              gfloat *pixel = &components1[((y * TEST_STRIP_WIDTH) + x) * 4];
 
-              pixel[0] = g_random_double();
-              pixel[1] = g_random_double();
-              pixel[2] = g_random_double();
-              pixel[3] = g_random_double();
+              pixel[0] = g_random_double ();
+              pixel[1] = g_random_double ();
+              pixel[2] = g_random_double ();
+              pixel[3] = g_random_double ();
             }
 
           /* set the texture subregion to a random image */
@@ -116,7 +148,7 @@ main (gint    argc,
                                 NULL);
 
           /* test subregion */
-          for (j = 0; j < 10 * 10 * 4; j++)
+          for (j = 0; j < TEST_STRIP_WIDTH * TEST_STRIP_HEIGHT * 4; j++)
             if (!GEGL_FLOAT_EQUAL (components1[j], components2[j]))
               {
                 g_printerr ("The gegl_gpu_texture_set() (%s) test failed. "
diff --git a/tests/test-gegl-gpu-texture-set.c b/tests/test-gegl-gpu-texture-set.c
index 2ac9869..36edefd 100644
--- a/tests/test-gegl-gpu-texture-set.c
+++ b/tests/test-gegl-gpu-texture-set.c
@@ -26,6 +26,11 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define RANDOM_PIXEL_COUNT 1000
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -39,25 +44,27 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  texture = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+  texture = gegl_gpu_texture_new (TEXTURE_WIDTH,
+                                  TEXTURE_HEIGHT,
+                                  babl_format ("RGBA float"));
 
-  components1 = g_new0 (gfloat, 50 * 50 * 4);
-  components2 = g_new0 (gfloat, 50 * 50 * 4);
+  components1 = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
+  components2 = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint cnt;
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components1[((y * 50) + x) * 4];
+          gfloat *pixel = &components1[((y * TEXTURE_WIDTH) + x) * 4];
 
-          pixel[0] = g_random_double();
-          pixel[1] = g_random_double();
-          pixel[2] = g_random_double();
-          pixel[3] = g_random_double();
+          pixel[0] = g_random_double ();
+          pixel[1] = g_random_double ();
+          pixel[2] = g_random_double ();
+          pixel[3] = g_random_double ();
         }
 
       /* set the texture to a random image */
@@ -68,7 +75,7 @@ main (gint    argc,
        */
       gegl_gpu_texture_get (texture, NULL, components2, NULL);
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (components1[cnt], components2[cnt]))
           {
             g_printerr ("The gegl_gpu_texture_set() test failed. Aborting.\n");
diff --git a/tests/test-gegl-tile-cow-consistency.c b/tests/test-gegl-tile-cow-consistency.c
index d067284..3a0da67 100644
--- a/tests/test-gegl-tile-cow-consistency.c
+++ b/tests/test-gegl-tile-cow-consistency.c
@@ -28,6 +28,9 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -41,11 +44,17 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  tile = gegl_tile_new (50, 50, babl_format ("RGBA float"));
+  tile = gegl_tile_new (TEXTURE_WIDTH,
+                        TEXTURE_HEIGHT,
+                        babl_format ("RGBA float"));
 
-  /* clear tile data (not GPU data) and leave the tile unsynchronized */
   gegl_tile_lock (tile, GEGL_TILE_LOCK_WRITE);
-  memset (gegl_tile_get_data (tile), 0x00, sizeof (gfloat) * 50 * 50 * 4);
+
+  /* clear tile data (not GPU data) and leave the tile unsynchronized */
+  memset (gegl_tile_get_data (tile), 0x00, sizeof (gfloat)
+                                             * TEXTURE_WIDTH
+                                             * TEXTURE_HEIGHT * 4);
+
   gegl_tile_unlock (tile);
 
   tile2 = gegl_tile_dup (tile);
@@ -59,13 +68,13 @@ main (gint    argc,
        */
       gfloat *components  = (gpointer) gegl_tile_get_data (tile2);
 
-      gpu_components = g_new (gfloat, 50 * 50 * 4);
+      gpu_components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
       gegl_gpu_texture_get (gegl_tile_get_gpu_data (tile2),
                             NULL,
                             gpu_components,
                             babl_format ("RGBA float"));
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (components[cnt], gpu_components[cnt]))
           {
             g_printerr ("Test on gegl_tile_dup() GPU data/data consistency "
diff --git a/tests/test-gegl-tile-cow.c b/tests/test-gegl-tile-cow.c
index 7cf8427..b419d7b 100644
--- a/tests/test-gegl-tile-cow.c
+++ b/tests/test-gegl-tile-cow.c
@@ -27,6 +27,9 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -38,7 +41,10 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  tile  = gegl_tile_new (50, 50, babl_format ("RGBA float"));
+  tile  = gegl_tile_new (TEXTURE_WIDTH,
+                         TEXTURE_HEIGHT,
+                         babl_format ("RGBA float"));
+
   tile2 = gegl_tile_dup (tile);
 
   if (gegl_tile_get_data (tile) != gegl_tile_get_data (tile2))
diff --git a/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c b/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c
index 5e08cbf..075776c 100644
--- a/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c
+++ b/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c
@@ -28,6 +28,11 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define RANDOM_PIXEL_COUNT 1000
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -39,27 +44,33 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  tile       = gegl_tile_new (50, 50, babl_format ("RGBA float"));
-  components = g_new (gfloat, 50 * 50 * 4);
+  tile = gegl_tile_new (TEXTURE_WIDTH,
+                        TEXTURE_HEIGHT,
+                        babl_format ("RGBA float"));
+
+  components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint    cnt;
-      gfloat *tile_components = g_new (gfloat, 50 * 50 * 4);
+      gfloat *tile_components = g_new (gfloat,
+                                       TEXTURE_WIDTH
+                                         * TEXTURE_HEIGHT
+                                         * 4);
 
-      memset (tile->data, 0, 50 * 50 * 4);
+      memset (tile->data, 0, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
       gegl_gpu_texture_clear (tile->gpu_data, NULL);
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components[((y * 50) + x) * 4];
+          gfloat *pixel = &components[((y * TEXTURE_WIDTH) + x) * 4];
 
           pixel[0] = g_random_double ();
           pixel[1] = g_random_double ();
           pixel[2] = g_random_double ();
-          pixel[3] = 1.0;
+          pixel[3] = g_random_double ();
         }
 
       gegl_tile_lock (tile, GEGL_TILE_LOCK_GPU_WRITE);
@@ -80,7 +91,7 @@ main (gint    argc,
                             tile_components,
                             babl_format ("RGBA float"));
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile GPU texture inconsistent with original GPU "
diff --git a/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c b/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c
index 533dcee..577f589 100644
--- a/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c
+++ b/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c
@@ -28,6 +28,11 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define RANDOM_PIXEL_COUNT 1000
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -39,27 +44,30 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  tile       = gegl_tile_new (50, 50, babl_format ("RGBA float"));
-  components = g_new (gfloat, 50 * 50 * 4);
+  tile = gegl_tile_new (TEXTURE_WIDTH,
+                        TEXTURE_HEIGHT,
+                        babl_format ("RGBA float"));
+
+  components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint    cnt;
       gfloat *tile_components;
 
-      memset (tile->data, 0, 50 * 50 * 4);
+      memset (tile->data, 0, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
       gegl_gpu_texture_clear (tile->gpu_data, NULL);
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components[((y * 50) + x) * 4];
+          gfloat *pixel = &components[((y * TEXTURE_WIDTH) + x) * 4];
 
           pixel[0] = g_random_double ();
           pixel[1] = g_random_double ();
           pixel[2] = g_random_double ();
-          pixel[3] = 1.0;
+          pixel[3] = g_random_double ();
         }
 
       gegl_tile_lock (tile, GEGL_TILE_LOCK_GPU_WRITE);
@@ -76,7 +84,7 @@ main (gint    argc,
       gegl_tile_lock (tile, GEGL_TILE_LOCK_READ);
       tile_components = (gpointer) gegl_tile_get_data (tile);
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile data inconsistent with original GPU texture. "
diff --git a/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c b/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c
index d7c7a5a..3f21aed 100644
--- a/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c
+++ b/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c
@@ -28,6 +28,11 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define RANDOM_PIXEL_COUNT 1000
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -39,27 +44,34 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  tile       = gegl_tile_new (50, 50, babl_format ("RGBA float"));
-  components = g_new (gfloat, 4 * 50 * 50);
+  tile = gegl_tile_new (TEXTURE_WIDTH,
+                        TEXTURE_HEIGHT,
+                        babl_format ("RGBA float"));
+
+  components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint    cnt;
-      gfloat *tile_components = g_new (gfloat, 50 * 50 * 4);
 
-      memset (tile->data, 0, 50 * 50 * 4);
+      gfloat *tile_components = g_new (gfloat,
+                                       TEXTURE_WIDTH
+                                         * TEXTURE_HEIGHT
+                                         * 4);
+
+      memset (tile->data, 0, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
       gegl_gpu_texture_clear (tile->gpu_data, NULL);
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components[((y * 50) + x) * 4];
+          gfloat *pixel = &components[((y * TEXTURE_WIDTH) + x) * 4];
 
           pixel[0] = g_random_double ();
           pixel[1] = g_random_double ();
           pixel[2] = g_random_double ();
-          pixel[3] = 1.0;
+          pixel[3] = g_random_double ();
         }
 
       gegl_tile_lock (tile, GEGL_TILE_LOCK_WRITE);
@@ -67,7 +79,7 @@ main (gint    argc,
       /* set tile to a random image */
       memcpy (gegl_tile_get_data (tile),
               components,
-              sizeof (gfloat) * 50 * 50 * 4);
+              sizeof (gfloat) * TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
       gegl_tile_unlock (tile);
 
@@ -79,7 +91,7 @@ main (gint    argc,
                             tile_components,
                             babl_format ("RGBA float"));
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile GPU texture inconsistent with original image "
diff --git a/tests/test-gegl-tile-lock-mode-write-then-read.c b/tests/test-gegl-tile-lock-mode-write-then-read.c
index 9090e32..4879ef2 100644
--- a/tests/test-gegl-tile-lock-mode-write-then-read.c
+++ b/tests/test-gegl-tile-lock-mode-write-then-read.c
@@ -28,6 +28,11 @@
 #define SUCCESS 0
 #define FAILURE (-1)
 
+#define TEXTURE_WIDTH  50
+#define TEXTURE_HEIGHT 50
+
+#define RANDOM_PIXEL_COUNT 1000
+
 gint
 main (gint    argc,
       gchar **argv)
@@ -39,27 +44,33 @@ main (gint    argc,
 
   gegl_init (&argc, &argv);
 
-  tile       = gegl_tile_new (50, 50, babl_format ("RGBA float"));
-  components = g_new (gfloat, 50 * 50 * 4);
+  tile = gegl_tile_new (TEXTURE_WIDTH,
+                        TEXTURE_HEIGHT,
+                        babl_format ("RGBA float"));
+
+  components = g_new (gfloat, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
     {
       gint    cnt;
-      gfloat *tile_components;
+      gfloat *tile_components = g_new (gfloat,
+                                       TEXTURE_WIDTH
+                                         * TEXTURE_HEIGHT
+                                         * 4);
 
-      memset (tile->data, 0, 50 * 50 * 4);
+      memset (tile->data, 0, TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
       gegl_gpu_texture_clear (tile->gpu_data, NULL);
 
-      for (cnt = 0; cnt < 1000; cnt++)
+      for (cnt = 0; cnt < RANDOM_PIXEL_COUNT; cnt++)
         {
-          gint x = g_random_int_range (0, 50);
-          gint y = g_random_int_range (0, 50);
+          gint x = g_random_int_range (0, TEXTURE_WIDTH);
+          gint y = g_random_int_range (0, TEXTURE_HEIGHT);
 
-          gfloat *pixel = &components[((y * 50) + x) * 4];
+          gfloat *pixel = &components[((y * TEXTURE_WIDTH) + x) * 4];
 
           pixel[0] = g_random_double ();
           pixel[1] = g_random_double ();
           pixel[2] = g_random_double ();
-          pixel[3] = 1.0;
+          pixel[3] = g_random_double ();
         }
 
       gegl_tile_lock (tile, GEGL_TILE_LOCK_WRITE);
@@ -67,7 +78,7 @@ main (gint    argc,
       /* set tile to a random image */
       memcpy (gegl_tile_get_data (tile),
               components,
-              sizeof (gfloat) * 50 * 50 * 4);
+              sizeof (gfloat) * TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);
 
       gegl_tile_unlock (tile);
 
@@ -75,7 +86,7 @@ main (gint    argc,
       gegl_tile_lock (tile, GEGL_TILE_LOCK_READ);
       tile_components = (gpointer) gegl_tile_get_data (tile);
 
-      for (cnt = 0; cnt < 50 * 50 * 4; cnt++)
+      for (cnt = 0; cnt < TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; cnt++)
         if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile data inconsistent with original image data. "



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