[gegl/gsoc2011-opencl: 19/19] Simple test to verify OpenCL use with gegl_graph



commit 07749d46da4c7d6d34c0f108e888f83c00c0ca17
Author: Victor Oliveira <victormatheus gmail com>
Date:   Thu Aug 18 13:29:38 2011 -0300

    Simple test to verify OpenCL use with gegl_graph

 tests/opencl/Makefile.am                           |    3 +-
 .../test-gegl-buffer-cl-brightness-contrast-2.c    |   87 ++++++++++++++++++++
 2 files changed, 89 insertions(+), 1 deletions(-)
---
diff --git a/tests/opencl/Makefile.am b/tests/opencl/Makefile.am
index 66a08a0..76dd5cb 100644
--- a/tests/opencl/Makefile.am
+++ b/tests/opencl/Makefile.am
@@ -19,7 +19,8 @@ noinst_PROGRAMS = \
 	test-gegl-buffer-cl-write \
 	test-gegl-buffer-cl-read \
 	test-gegl-buffer-cl-read-write \
-	test-gegl-buffer-cl-brightness-contrast
+	test-gegl-buffer-cl-brightness-contrast \
+	test-gegl-buffer-cl-brightness-contrast-2
 
 TESTS = $(noinst_PROGRAMS)
 
diff --git a/tests/opencl/test-gegl-buffer-cl-brightness-contrast-2.c b/tests/opencl/test-gegl-buffer-cl-brightness-contrast-2.c
new file mode 100644
index 0000000..4f0fc78
--- /dev/null
+++ b/tests/opencl/test-gegl-buffer-cl-brightness-contrast-2.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 2011 Victor M. de Araujo Oliveira <victormatheus gmail com>
+ */
+
+#include <string.h>
+#include <assert.h>
+#include <babl/babl.h>
+#include <sys/time.h>
+
+#include "gegl.h"
+#include "gegl-types.h"
+#include "gegl-utils.h"
+#include "gegl-cl-init.h"
+#include "gegl-cl-texture.h"
+
+#define SUCCESS 0
+#define FAILURE (-1)
+
+gint
+main (gint    argc,
+      gchar **argv)
+{
+  gint retval = SUCCESS;
+
+  gfloat brightness = 2.0f;
+  gfloat contrast   = 0.5f;
+
+  GeglBuffer *buffer;
+
+  char image_name[1000] = "GEGL.png";
+  if (argc > 1)
+    strcpy(image_name, argv[1]);
+
+  gegl_init (&argc, &argv);
+  gegl_cl_init (NULL);
+
+  g_printf("\nload\n");
+
+  /* load */
+  {
+    GeglNode *gegl, *sink,  *load;
+
+    gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer,
+                                           "format",  babl_format ("RGBA float"), NULL,
+                       load = gegl_node ("gegl:load", "path", image_name, NULL)));
+
+    gegl_node_process (sink);
+    g_object_unref (gegl);
+  }
+
+  g_printf("\nprocess\n");
+
+  /* process */
+  {
+    GeglNode *gegl, *sink, *bc,  *load;
+
+    gegl = gegl_graph(sink  = gegl_node ("gegl:png-save", "path", "out.png", NULL,
+                        bc  = gegl_node ("gegl:brightness-contrast",
+                                         "brightness", brightness,
+                                         "contrast", contrast, NULL,
+                       load = gegl_node ("gegl:buffer-source", "buffer", buffer, NULL))));
+
+    gegl_node_process (sink);
+    g_object_unref (gegl);
+  }
+
+  gegl_buffer_destroy (buffer);
+  g_object_run_dispose ((GObject*)buffer);
+
+  gegl_exit ();
+
+  return retval;
+}



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