[gegl/gsoc2011-opencl-2: 17/19] Simple test which runs Brightness-Constrast with OpenCL
- From: Victor Matheus de Araujo Oliveira <vmaolive src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/gsoc2011-opencl-2: 17/19] Simple test which runs Brightness-Constrast with OpenCL
- Date: Mon, 21 Nov 2011 19:00:43 +0000 (UTC)
commit d61a0241193fd458763da720224e53161423227e
Author: Victor Oliveira <victormatheus gmail com>
Date: Fri Nov 18 17:11:51 2011 -0200
Simple test which runs Brightness-Constrast with OpenCL
tests/opencl/Makefile.am | 31 ++++++++++
tests/opencl/test-cl-brightness-contrast.c | 86 ++++++++++++++++++++++++++++
2 files changed, 117 insertions(+), 0 deletions(-)
---
diff --git a/tests/opencl/Makefile.am b/tests/opencl/Makefile.am
new file mode 100644
index 0000000..fc67625
--- /dev/null
+++ b/tests/opencl/Makefile.am
@@ -0,0 +1,31 @@
+# Make the tests run against the build and not the installation
+TESTS_ENVIRONMENT = \
+ GEGL_PATH=$(top_builddir)/operations/common:$(top_builddir)/operations/core:$(top_builddir)/operations/external:$(top_builddir)/operations/affine:$(top_builddir)/operations/generated \
+ ABS_TOP_BUILDDIR=$(top_builddir) \
+ ABS_TOP_SRCDIR=$(top_srcdir)
+
+# The tests
+noinst_PROGRAMS = \
+ test-cl-brightness-contrast
+
+TESTS = $(noinst_PROGRAMS)
+
+# Common CPPFLAGS
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_builddir)/gegl \
+ -I$(top_srcdir)/gegl \
+ -I$(top_builddir)/gegl/buffer \
+ -I$(top_srcdir)/gegl/buffer \
+ -I$(top_builddir)/gegl/property-types \
+ -I$(top_srcdir)/gegl/property-types \
+ -I$(top_builddir)/gegl/operation \
+ -I$(top_srcdir)/gegl/operation \
+ -I$(top_builddir)/gegl/opencl \
+ -I$(top_srcdir)/gegl/opencl
+
+AM_CFLAGS = $(DEP_CFLAGS) $(BABL_CFLAGS)
+
+# Common libs
+LIBS = $(top_builddir)/gegl/libgegl-$(GEGL_API_VERSION).la \
+ $(DEP_LIBS) $(BABL_LIBS)
diff --git a/tests/opencl/test-cl-brightness-contrast.c b/tests/opencl/test-cl-brightness-contrast.c
new file mode 100644
index 0000000..f626b5a
--- /dev/null
+++ b/tests/opencl/test-cl-brightness-contrast.c
@@ -0,0 +1,86 @@
+/* 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);
+
+ 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]