[gegl] hue-chroma: add opencl support
- From: Thomas Manni <tmanni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] hue-chroma: add opencl support
- Date: Thu, 21 Sep 2017 12:25:09 +0000 (UTC)
commit 246e1faa541e212063b4f629febe97d010683a3d
Author: Thomas Manni <thomas manni free fr>
Date: Thu Sep 21 11:11:38 2017 +0200
hue-chroma: add opencl support
opencl/hue-chroma.cl | 15 +++++++++++++++
opencl/hue-chroma.cl.h | 17 +++++++++++++++++
operations/common/hue-chroma.c | 3 +++
3 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/opencl/hue-chroma.cl b/opencl/hue-chroma.cl
new file mode 100644
index 0000000..07e6261
--- /dev/null
+++ b/opencl/hue-chroma.cl
@@ -0,0 +1,15 @@
+__kernel void gegl_hue_chroma (__global const float4 *in,
+ __global float4 *out,
+ float hue,
+ float chroma,
+ float lightness)
+{
+ int gid = get_global_id(0);
+ float4 in_v = in [gid];
+ float4 out_v;
+ out_v.x = in_v.x + lightness;
+ out_v.y = clamp(in_v.y + chroma, 0.f, 200.f);
+ out_v.z = in_v.z + hue;
+ out_v.w = in_v.w;
+ out[gid] = out_v;
+}
diff --git a/opencl/hue-chroma.cl.h b/opencl/hue-chroma.cl.h
new file mode 100644
index 0000000..95e3cfe
--- /dev/null
+++ b/opencl/hue-chroma.cl.h
@@ -0,0 +1,17 @@
+static const char* hue_chroma_cl_source =
+"__kernel void gegl_hue_chroma (__global const float4 *in, \n"
+" __global float4 *out, \n"
+" float hue, \n"
+" float chroma, \n"
+" float lightness) \n"
+"{ \n"
+" int gid = get_global_id(0); \n"
+" float4 in_v = in [gid]; \n"
+" float4 out_v; \n"
+" out_v.x = in_v.x + lightness; \n"
+" out_v.y = clamp(in_v.y + chroma, 0.f, 200.f); \n"
+" out_v.z = in_v.z + hue; \n"
+" out_v.w = in_v.w; \n"
+" out[gid] = out_v; \n"
+"} \n"
+;
diff --git a/operations/common/hue-chroma.c b/operations/common/hue-chroma.c
index b6712ec..2e06cae 100644
--- a/operations/common/hue-chroma.c
+++ b/operations/common/hue-chroma.c
@@ -91,6 +91,8 @@ process (GeglOperation *op,
return TRUE;
}
+#include "opencl/hue-chroma.cl.h"
+
static void
gegl_op_class_init (GeglOpClass *klass)
{
@@ -107,6 +109,7 @@ gegl_op_class_init (GeglOpClass *klass)
"name", "gegl:hue-chroma",
"title", _("Hue-Chroma"),
"categories", "color",
+ "cl-source", hue_chroma_cl_source,
"description", _("Adjust LCH Hue, Chroma, and Lightness"),
NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]