[gegl/gsoc2009-gpu] Add a new set of automatic test-suites for GeglGpuTexture
- From: Jerson Michael Perpetua <jperpetua src gnome org>
- To: svn-commits-list gnome org
- Subject: [gegl/gsoc2009-gpu] Add a new set of automatic test-suites for GeglGpuTexture
- Date: Mon, 13 Jul 2009 08:03:38 +0000 (UTC)
commit ddbf35d37f09d61b34981a3c25b9e88732c531d5
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date: Mon Jul 13 16:02:55 2009 +0800
Add a new set of automatic test-suites for GeglGpuTexture
tests/Makefile.am | 9 ++-
tests/test-gegl-gpu-texture-clear-subrect.c | 118 ++++++++++++++++++++++
tests/test-gegl-gpu-texture-clear.c | 65 ++++++++++++
tests/test-gegl-gpu-texture-copy-subrect.c | 140 +++++++++++++++++++++++++++
tests/test-gegl-gpu-texture-copy.c | 91 +++++++++++++++++
tests/test-gegl-gpu-texture-dup.c | 87 +++++++++++++++++
tests/test-gegl-gpu-texture-set-subrect.c | 126 ++++++++++++++++++++++++
tests/test-gegl-gpu-texture-set.c | 73 ++++++++++++++
8 files changed, 708 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4358dcb..2abac64 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,14 @@ TESTS_ENVIRONMENT = \
TESTS = \
test-proxynop-processing \
test-color-op \
- test-gegl-rectangle
+ test-gegl-rectangle \
+ test-gegl-gpu-texture-clear \
+ test-gegl-gpu-texture-clear-subrect \
+ test-gegl-gpu-texture-set \
+ test-gegl-gpu-texture-set-subrect \
+ test-gegl-gpu-texture-copy \
+ test-gegl-gpu-texture-copy-subrect \
+ test-gegl-gpu-texture-dup
noinst_PROGRAMS = $(TESTS)
# Common CPPFLAGS
diff --git a/tests/test-gegl-gpu-texture-clear-subrect.c b/tests/test-gegl-gpu-texture-clear-subrect.c
new file mode 100644
index 0000000..c79680f
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-clear-subrect.c
@@ -0,0 +1,118 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
+
+typedef struct GeglGpuTextureClearSubrectTestCase
+{
+ gchar *name;
+ GeglRectangle roi;
+
+} GeglGpuTextureClearSubrectTestCase;
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTextureClearSubrectTestCase test_cases[5] =
+ {
+ {
+ "top-left corner",
+ { 0, 0, 10, 10}
+ },
+ {
+ "top-right corner",
+ {40, 0, 10, 10}
+ },
+ {
+ "bottom-left corner",
+ { 0, 40, 10, 10}
+ },
+ {
+ "bottom-right corner",
+ {40, 40, 10, 10}
+ },
+ {
+ "center",
+ {20, 20, 10, 10}
+ }
+ };
+
+ GeglGpuTexture *texture;
+ gfloat *components;
+
+ gegl_init (&argc, &argv);
+
+ texture = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+ components = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+
+ /* clear individual subregions */
+ for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
+ gegl_gpu_texture_clear (texture, &test_cases[cnt].roi);
+
+ gegl_gpu_texture_get (texture, NULL, components, NULL);
+
+ /* test subregions */
+ for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
+ {
+ gint x, y;
+
+ gint last_x = test_cases[cnt].roi.x + test_cases[cnt].roi.width - 1;
+ gint last_y = test_cases[cnt].roi.y + test_cases[cnt].roi.height - 1;
+
+ 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 * 4 * 50) + (x * 4)];
+
+ if (pixel[0] != 0.0
+ || pixel[1] != 0.0
+ || pixel[2] != 0.0
+ || pixel[3] != 0.0)
+ {
+ g_printerr ("The gegl_gpu_texture_clear() (%s) test "
+ "failed. Aborting.\n", test_cases[cnt].name);
+
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+ }
+ }
+
+abort:
+ g_free (components);
+ gegl_gpu_texture_free (texture);
+
+ gegl_exit ();
+
+ return retval;
+}
diff --git a/tests/test-gegl-gpu-texture-clear.c b/tests/test-gegl-gpu-texture-clear.c
new file mode 100644
index 0000000..8da5ad5
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-clear.c
@@ -0,0 +1,65 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTexture *texture;
+ gfloat *components;
+
+ gegl_init (&argc, &argv);
+
+ texture = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+ components = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+
+ gegl_gpu_texture_clear (texture, NULL);
+ gegl_gpu_texture_get (texture, NULL, components, NULL);
+
+ for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
+ if (components[cnt] != 0.0)
+ {
+ g_printerr ("The gegl_gpu_texture_clear() test failed. "
+ "Aborting.\n");
+
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+
+abort:
+ g_free (components);
+ gegl_gpu_texture_free (texture);
+
+ gegl_exit ();
+
+ return retval;
+}
diff --git a/tests/test-gegl-gpu-texture-copy-subrect.c b/tests/test-gegl-gpu-texture-copy-subrect.c
new file mode 100644
index 0000000..d9b1a42
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-copy-subrect.c
@@ -0,0 +1,140 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <string.h>
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
+
+typedef struct GeglGpuTextureCopySubrectTestCase
+{
+ gchar *name;
+ GeglRectangle roi;
+
+} GeglGpuTextureCopySubrectTestCase;
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTextureCopySubrectTestCase test_cases[5] =
+ {
+ {
+ "top-left corner",
+ { 0, 0, 10, 10}
+ },
+ {
+ "top-right corner",
+ {40, 0, 10, 10}
+ },
+ {
+ "bottom-left corner",
+ { 0, 40, 10, 10}
+ },
+ {
+ "bottom-right corner",
+ {40, 40, 10, 10}
+ },
+ {
+ "center",
+ {20, 20, 10, 10}
+ }
+ };
+
+ GeglGpuTexture *texture1;
+ GeglGpuTexture *texture2;
+
+ gfloat *components;
+
+ 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"));
+
+ components = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+
+ /* initialize first texture to some solid color */
+ for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
+ components[cnt] = 1.0;
+
+ gegl_gpu_texture_set (texture1, NULL, components, NULL);
+
+ /* clear second texture and copy individual subregions from the
+ * first texture to the second texture
+ */
+ gegl_gpu_texture_clear (texture2, NULL);
+
+ for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
+ gegl_gpu_texture_copy (texture1,
+ &test_cases[cnt].roi,
+ texture2,
+ test_cases[cnt].roi.x,
+ test_cases[cnt].roi.y);
+
+ memset (components, 0, sizeof (gfloat) * 4 * 50 * 50);
+ gegl_gpu_texture_get (texture2, NULL, components, NULL);
+
+ /* test individual subregions */
+ for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
+ {
+ gint x, y;
+
+ gint last_x = test_cases[cnt].roi.x + test_cases[cnt].roi.width - 1;
+ gint last_y = test_cases[cnt].roi.y + test_cases[cnt].roi.height - 1;
+
+ 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 * 4 * 50) + (x * 4)];
+
+ if (pixel[0] != 1.0
+ || pixel[1] != 1.0
+ || pixel[2] != 1.0
+ || pixel[3] != 1.0)
+ {
+ g_printerr ("The gegl_gpu_texture_copy() (%s) test failed. "
+ "Aborting.\n", test_cases[cnt].name);
+
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+ }
+ }
+
+abort:
+ g_free (components);
+
+ gegl_gpu_texture_free (texture2);
+ gegl_gpu_texture_free (texture1);
+
+ gegl_exit ();
+
+ return retval;
+}
diff --git a/tests/test-gegl-gpu-texture-copy.c b/tests/test-gegl-gpu-texture-copy.c
new file mode 100644
index 0000000..799f04d
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-copy.c
@@ -0,0 +1,91 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTexture *texture1;
+ GeglGpuTexture *texture2;
+
+ gfloat *components1;
+ gfloat *components2;
+
+ 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"));
+
+ components1 = g_new (gfloat, 4 * 50 * 50);
+ components2 = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+
+ /* generate random image */
+ for (cnt = 0; cnt < 1000; cnt++)
+ {
+ gint x = g_random_int_range (0, 50);
+ gint y = g_random_int_range (0, 50);
+ gfloat *pixel = &components1[(y * 50) + (x * 4)];
+
+ pixel[0] = 1.0;
+ pixel[1] = 1.0;
+ pixel[2] = 1.0;
+ pixel[3] = 1.0;
+ }
+
+ gegl_gpu_texture_set (texture1, NULL, components1, NULL);
+
+ /* copy first texture to second texture */
+ gegl_gpu_texture_copy (texture1, NULL, texture2, 0, 0);
+ gegl_gpu_texture_get (texture2, NULL, components2, NULL);
+
+ /* compare the two images */
+ for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
+ if (components1[cnt] != components2[cnt])
+ {
+ g_printerr ("The gegl_gpu_texture_copy() test failed. "
+ "Aborting.\n");
+
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+
+abort:
+ g_free (components2);
+ g_free (components1);
+
+ gegl_gpu_texture_free (texture2);
+ gegl_gpu_texture_free (texture1);
+
+ gegl_exit ();
+
+ return retval;
+}
diff --git a/tests/test-gegl-gpu-texture-dup.c b/tests/test-gegl-gpu-texture-dup.c
new file mode 100644
index 0000000..041e39e
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-dup.c
@@ -0,0 +1,87 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTexture *texture1;
+ GeglGpuTexture *texture2;
+
+ gfloat *components1;
+ gfloat *components2;
+
+ gegl_init (&argc, &argv);
+
+ texture1 = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+
+ components1 = g_new (gfloat, 4 * 50 * 50);
+ components2 = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+
+ /* generate random image */
+ for (cnt = 0; cnt < 1000; cnt++)
+ {
+ gint x = g_random_int_range (0, 50);
+ gint y = g_random_int_range (0, 50);
+ gfloat *pixel = &components1[(y * 50) + (x * 4)];
+
+ pixel[0] = 1.0;
+ pixel[1] = 1.0;
+ pixel[2] = 1.0;
+ pixel[3] = 1.0;
+ }
+
+ /* duplicate texture */
+ gegl_gpu_texture_set (texture1, NULL, components1, NULL);
+ texture2 = gegl_gpu_texture_dup (texture1);
+ gegl_gpu_texture_get (texture2, NULL, components2, NULL);
+
+ /* compare the two images */
+ for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
+ if (components1[cnt] != components2[cnt])
+ {
+ g_printerr ("The gegl_gpu_texture_dup() test failed. Aborting.\n");
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+
+abort:
+ g_free (components2);
+ g_free (components1);
+
+ gegl_gpu_texture_free (texture2);
+ gegl_gpu_texture_free (texture1);
+
+ gegl_exit ();
+
+ return retval;
+}
diff --git a/tests/test-gegl-gpu-texture-set-subrect.c b/tests/test-gegl-gpu-texture-set-subrect.c
new file mode 100644
index 0000000..218ef9c
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-set-subrect.c
@@ -0,0 +1,126 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
+
+typedef struct GeglGpuTextureSetSubrectTestCase
+{
+ gchar *name;
+ GeglRectangle roi;
+
+} GeglGpuTextureSetSubrectTestCase;
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTextureSetSubrectTestCase test_cases[5] =
+ {
+ {
+ "top-left corner",
+ { 0, 0, 10, 10}
+ },
+ {
+ "top-right corner",
+ {40, 0, 10, 10}
+ },
+ {
+ "bottom-left corner",
+ { 0, 40, 10, 10}
+ },
+ {
+ "bottom-right corner",
+ {40, 40, 10, 10}
+ },
+ {
+ "center",
+ {20, 20, 10, 10}
+ }
+ };
+
+ GeglGpuTexture *texture;
+ gfloat *components;
+
+ gegl_init (&argc, &argv);
+
+ texture = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+ components = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+ gfloat *region = g_new (gfloat, 4 * 10 * 10);
+
+ /* set individual subregions to a solid color */
+ for (cnt = 0; cnt < 4 * 10 * 10; cnt++)
+ region[cnt] = 1.0;
+
+ gegl_gpu_texture_clear (texture, NULL);
+
+ for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
+ gegl_gpu_texture_set (texture, &test_cases[cnt].roi, region, NULL);
+
+ gegl_gpu_texture_get (texture, NULL, components, NULL);
+
+ /* test individual subregions */
+ for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
+ {
+ gint x, y;
+
+ gint last_x = test_cases[cnt].roi.x + test_cases[cnt].roi.width - 1;
+ gint last_y = test_cases[cnt].roi.y + test_cases[cnt].roi.height - 1;
+
+ 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 * 4 * 50) + (x * 4)];
+
+ if (pixel[0] != 1.0
+ || pixel[1] != 1.0
+ || pixel[2] != 1.0
+ || pixel[3] != 1.0)
+ {
+ g_printerr ("The gegl_gpu_texture_set() (%s) test failed. "
+ "Aborting.\n", test_cases[cnt].name);
+
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+ }
+
+ g_free (region);
+ }
+
+abort:
+ g_free (components);
+ gegl_gpu_texture_free (texture);
+
+ gegl_exit ();
+
+ return retval;
+}
diff --git a/tests/test-gegl-gpu-texture-set.c b/tests/test-gegl-gpu-texture-set.c
new file mode 100644
index 0000000..1548ab0
--- /dev/null
+++ b/tests/test-gegl-gpu-texture-set.c
@@ -0,0 +1,73 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <string.h>
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-gpu-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gint retval = SUCCESS;
+
+ GeglGpuTexture *texture;
+ gfloat *components;
+
+ gegl_init (&argc, &argv);
+
+ texture = gegl_gpu_texture_new (50, 50, babl_format ("RGBA float"));
+ components = g_new (gfloat, 4 * 50 * 50);
+
+ {
+ gint cnt;
+
+ /* set texture to some solid color */
+ for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
+ components[cnt] = 1.0;
+
+ gegl_gpu_texture_clear (texture, NULL);
+ gegl_gpu_texture_set (texture, NULL, components, NULL);
+
+ /* we zero to make sure that we aren't testing this array's old values */
+ memset (components, 0, sizeof (gfloat) * 4 * 50 * 50);
+
+ gegl_gpu_texture_get (texture, NULL, components, NULL);
+
+ for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
+ if (components[cnt] != 1.0)
+ {
+ g_printerr ("The gegl_gpu_texture_set() test failed. Aborting.\n");
+ retval = FAILURE;
+ goto abort;
+ }
+ }
+
+abort:
+ g_free (components);
+ gegl_gpu_texture_free (texture);
+
+ gegl_exit ();
+
+ return retval;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]