[gegl/gsoc2009-gpu] Modify the gegl_gpu_texture_clear() tests to make sure that the texture is non-empty before clearing
- From: Jerson Michael Perpetua <jperpetua src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl/gsoc2009-gpu] Modify the gegl_gpu_texture_clear() tests to make sure that the texture is non-empty before clearing
- Date: Wed, 19 Aug 2009 22:52:11 +0000 (UTC)
commit 4a97d846546873b1245a6bee29ed9b73507d6926
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date: Thu Aug 20 03:34:11 2009 +0800
Modify the gegl_gpu_texture_clear() tests to make sure that the texture is non-empty before clearing it
Modify the gegl_gpu_texture_clear() tests to make sure that the texture is
non-empty before clearing it. We shouldn't rely on the current undefined
behaviour wherein a newly initialized texture isn't most likely cleared (i.e.
initialized to zeroes).
tests/test-gegl-gpu-texture-clear-subrect.c | 24 +++++++++++++++++++++++-
tests/test-gegl-gpu-texture-clear.c | 25 ++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-gegl-gpu-texture-clear-subrect.c b/tests/test-gegl-gpu-texture-clear-subrect.c
index dc2da5f..22b606a 100644
--- a/tests/test-gegl-gpu-texture-clear-subrect.c
+++ b/tests/test-gegl-gpu-texture-clear-subrect.c
@@ -73,7 +73,29 @@ main (gint argc,
components = g_new (gfloat, 4 * 50 * 50);
{
- gint cnt;
+ gint cnt;
+ gfloat color[4];
+
+ color[0] = g_random_double ();
+ color[1] = g_random_double ();
+ color[2] = g_random_double ();
+ color[3] = g_random_double ();
+
+ for (cnt = 0; cnt < 50 * 50; cnt++)
+ {
+ gint index = cnt * 4;
+
+ components[index ] = color[0];
+ components[index + 1] = color[1];
+ components[index + 2] = color[2];
+ components[index + 3] = color[3];
+ }
+
+ /* set texture to some solid color to make sure that we aren't clearing
+ * an empty texture (note: this assumes that gegl_gpu_texture_set()
+ * works as expected)
+ */
+ gegl_gpu_texture_set (texture, NULL, components, NULL);
/* clear individual subregions */
for (cnt = 0; cnt < ARRAY_SIZE (test_cases); cnt++)
diff --git a/tests/test-gegl-gpu-texture-clear.c b/tests/test-gegl-gpu-texture-clear.c
index 1399a27..6ac92d9 100644
--- a/tests/test-gegl-gpu-texture-clear.c
+++ b/tests/test-gegl-gpu-texture-clear.c
@@ -40,8 +40,31 @@ main (gint argc,
components = g_new (gfloat, 4 * 50 * 50);
{
- gint cnt;
+ gint cnt;
+ gfloat color[4];
+ color[0] = g_random_double ();
+ color[1] = g_random_double ();
+ color[2] = g_random_double ();
+ color[3] = g_random_double ();
+
+ for (cnt = 0; cnt < 50 * 50; cnt++)
+ {
+ gint index = cnt * 4;
+
+ components[index ] = color[0];
+ components[index + 1] = color[1];
+ components[index + 2] = color[2];
+ components[index + 3] = color[3];
+ }
+
+ /* set texture to some solid color to make sure that we aren't clearing
+ * an empty texture (note: this assumes that gegl_gpu_texture_set()
+ * works as expected)
+ */
+ gegl_gpu_texture_set (texture, NULL, components, NULL);
+
+ /* clear whole texture */
gegl_gpu_texture_clear (texture, NULL);
gegl_gpu_texture_get (texture, NULL, components, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]