[gimp/goat-invasion: 236/418] app: add gimp_gegl_create_apply_buffer_node()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 236/418] app: add gimp_gegl_create_apply_buffer_node()
- Date: Wed, 4 Apr 2012 10:45:37 +0000 (UTC)
commit b5ba3629ad159d1493fb5244a56d480d242cb7d3
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 24 14:54:36 2012 +0100
app: add gimp_gegl_create_apply_buffer_node()
which creates a graph that applies paint, and factor out
gimp_gegl_add_buffer_source() which adds a buffer source with optional
offset to a graph.
app/gegl/gimp-gegl-nodes.c | 149 +++++++++++++++++++++++++++++++++++++++-----
app/gegl/gimp-gegl-nodes.h | 27 +++++++--
2 files changed, 156 insertions(+), 20 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index bbae641..da6ec01 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -90,32 +90,151 @@ gimp_gegl_create_apply_opacity_node (GeglBuffer *mask,
"operation", "gegl:opacity",
"value", opacity,
NULL);
- mask_source = gegl_node_new_child (node,
- "operation", "gegl:buffer-source",
- "buffer", mask,
- NULL);
+
+ mask_source = gimp_gegl_add_buffer_source (node, mask,
+ -mask_offset_x,
+ -mask_offset_y);
gegl_node_connect_to (input, "output",
opacity_node, "input");
+ gegl_node_connect_to (mask_source, "output",
+ opacity_node, "aux");
+ gegl_node_connect_to (opacity_node, "output",
+ output, "input");
+
+ return node;
+}
+
+GeglNode *
+gimp_gegl_create_apply_buffer_node (GeglBuffer *buffer,
+ gint buffer_offset_x,
+ gint buffer_offset_y,
+ gint src_offset_x,
+ gint src_offset_y,
+ gint dest_offset_x,
+ gint dest_offset_y,
+ GeglBuffer *mask,
+ gint mask_offset_x,
+ gint mask_offset_y,
+ gdouble opacity,
+ GimpLayerModeEffects mode)
+
+{
+ GeglNode *node;
+ GeglNode *input;
+ GeglNode *output;
+ GeglNode *buffer_source;
+ GeglNode *mask_source;
+ GeglNode *opacity_node;
+ GeglNode *mode_node;
- if (mask_offset_x != 0 || mask_offset_y != 0)
+ g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
+ g_return_val_if_fail (mask == NULL || GEGL_IS_BUFFER (mask), NULL);
+
+ node = gegl_node_new ();
+
+ buffer_source = gimp_gegl_add_buffer_source (node, buffer,
+ buffer_offset_x,
+ buffer_offset_y);
+
+ input = gegl_node_get_input_proxy (node, "input");
+
+ if (src_offset_x != 0 || src_offset_y != 0)
{
- GeglNode *translate = gegl_node_new_child (node,
- "operation", "gegl:translate",
- "x", (gdouble) -mask_offset_x,
- "y", (gdouble) -mask_offset_y,
- NULL);
+ GeglNode *translate =
+ gegl_node_new_child (node,
+ "operation", "gegl:translate",
+ "x", (gdouble) src_offset_x,
+ "y", (gdouble) src_offset_y,
+ NULL);
- gegl_node_connect_to (mask_source, "output",
- translate, "input");
+ gegl_node_connect_to (input, "output",
+ translate, "input");
- mask_source = translate;
+ input = translate;
}
- gegl_node_connect_to (mask_source, "output",
- opacity_node, "aux");
+ output = gegl_node_get_output_proxy (node, "output");
+
+ if (dest_offset_x != 0 || dest_offset_y != 0)
+ {
+ GeglNode *translate =
+ gegl_node_new_child (node,
+ "operation", "gegl:translate",
+ "x", (gdouble) dest_offset_x,
+ "y", (gdouble) dest_offset_y,
+ NULL);
+
+ gegl_node_connect_to (translate, "output",
+ output, "input");
+
+ output = translate;
+ }
+
+ if (mask)
+ mask_source = gimp_gegl_add_buffer_source (node, mask,
+ mask_offset_x,
+ mask_offset_y);
+ else
+ mask_source = NULL;
+
+ opacity_node = gegl_node_new_child (node,
+ "operation", "gegl:opacity",
+ "value", opacity,
+ NULL);
+
+ gegl_node_connect_to (buffer_source, "output",
+ opacity_node, "input");
+
+ if (mask_source)
+ gegl_node_connect_to (mask_source, "output",
+ opacity_node, "aux");
+
+ mode_node = gegl_node_new_child (node,
+ "operation",
+ gimp_layer_mode_to_gegl_operation (mode),
+ NULL);
+
gegl_node_connect_to (opacity_node, "output",
+ mode_node, "aux");
+ gegl_node_connect_to (input, "output",
+ mode_node, "input");
+ gegl_node_connect_to (mode_node, "output",
output, "input");
return node;
}
+
+GeglNode *
+gimp_gegl_add_buffer_source (GeglNode *parent,
+ GeglBuffer *buffer,
+ gint offset_x,
+ gint offset_y)
+{
+ GeglNode *buffer_source;
+
+ g_return_val_if_fail (GEGL_IS_NODE (parent), NULL);
+ g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
+
+ buffer_source = gegl_node_new_child (parent,
+ "operation", "gegl:buffer-source",
+ "buffer", buffer,
+ NULL);
+
+ if (offset_x != 0 || offset_y != 0)
+ {
+ GeglNode *translate =
+ gegl_node_new_child (parent,
+ "operation", "gegl:translate",
+ "x", (gdouble) offset_x,
+ "y", (gdouble) offset_y,
+ NULL);
+
+ gegl_node_connect_to (buffer_source, "output",
+ translate, "input");
+
+ buffer_source = translate;
+ }
+
+ return buffer_source;
+}
diff --git a/app/gegl/gimp-gegl-nodes.h b/app/gegl/gimp-gegl-nodes.h
index 01cce1c..36396c7 100644
--- a/app/gegl/gimp-gegl-nodes.h
+++ b/app/gegl/gimp-gegl-nodes.h
@@ -22,12 +22,29 @@
#define __GIMP_GEGL_NODES_H__
-GeglNode * gimp_gegl_create_flatten_node (const GimpRGB *background);
-GeglNode * gimp_gegl_create_apply_opacity_node (GeglBuffer *mask,
- gdouble opacity,
+GeglNode * gimp_gegl_create_flatten_node (const GimpRGB *background);
+GeglNode * gimp_gegl_create_apply_opacity_node (GeglBuffer *mask,
+ gdouble opacity,
/* offsets *into* the mask */
- gint mask_offset_x,
- gint mask_offset_y);
+ gint mask_offset_x,
+ gint mask_offset_y);
+GeglNode * gimp_gegl_create_apply_buffer_node (GeglBuffer *buffer,
+ gint buffer_offset_x,
+ gint buffer_offset_y,
+ gint src_offset_x,
+ gint src_offset_y,
+ gint dest_offset_x,
+ gint dest_offset_y,
+ GeglBuffer *mask,
+ gint mask_offset_x,
+ gint mask_offset_y,
+ gdouble opacity,
+ GimpLayerModeEffects mode);
+
+GeglNode * gimp_gegl_add_buffer_source (GeglNode *parent,
+ GeglBuffer *buffer,
+ gint offset_x,
+ gint offset_y);
#endif /* __GIMP_GEGL_NODES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]