[gimp/soc-2011-warp: 23/72] gimpwarptool: create a gegl graph to render the transformation, and insert warp operation for each s
- From: Michael Murà <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-warp: 23/72] gimpwarptool: create a gegl graph to render the transformation, and insert warp operation for each s
- Date: Wed, 14 Mar 2012 12:19:17 +0000 (UTC)
commit 9a9ea12726377eeeb45c1f72cabcb2796f078611
Author: Michael Murà <mure michael gmail com>
Date: Wed Jun 8 14:15:21 2011 +0200
gimpwarptool: create a gegl graph to render the transformation, and
insert warp operation for each stroke
app/gegl/gimpoperationwarp.c | 4 +-
app/tools/gimpwarptool.c | 74 ++++++++++++++++++++++++++++++-----------
app/tools/gimpwarptool.h | 7 +++-
3 files changed, 61 insertions(+), 24 deletions(-)
---
diff --git a/app/gegl/gimpoperationwarp.c b/app/gegl/gimpoperationwarp.c
index 8645a76..ed8315c 100644
--- a/app/gegl/gimpoperationwarp.c
+++ b/app/gegl/gimpoperationwarp.c
@@ -182,6 +182,7 @@ gimp_operation_warp_process (GeglOperation *operation,
{
GimpOperationWarp *ow = GIMP_OPERATION_WARP (operation);
+/*
if (in_buf)
{
out_buf = gegl_buffer_dup (in_buf);
@@ -190,8 +191,7 @@ gimp_operation_warp_process (GeglOperation *operation,
{
gegl_buffer_clear (out_buf, roi);
}
-
-
+*/
return TRUE;
}
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index e257621..cf9289a 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -97,14 +97,18 @@ static void gimp_warp_tool_oper_update (GimpTool *tool
static void gimp_warp_tool_draw (GimpDrawTool *draw_tool);
+static void gimp_warp_tool_create_graph (GimpWarpTool *wt);
static void gimp_warp_tool_create_image_map (GimpWarpTool *wt,
GimpDrawable *drawable);
static void gimp_warp_tool_image_map_flush (GimpImageMap *image_map,
GimpTool *tool);
static void gimp_warp_tool_image_map_update (GimpWarpTool *wt);
+static void gimp_warp_tool_add_op (GimpWarpTool *wt);
+#if 0
static void gimp_warp_tool_act_on_coords (GimpWarpTool *wt,
gint x,
gint y);
+#endif
G_DEFINE_TYPE (GimpWarpTool, gimp_warp_tool, GIMP_TYPE_DRAW_TOOL)
@@ -185,10 +189,10 @@ gimp_warp_tool_control (GimpTool *tool,
wt->coords_buffer = NULL;
}
- if (wt->render_node)
+ if (wt->graph)
{
- g_object_unref (wt->render_node);
- wt->render_node = NULL;
+ g_object_unref (wt->graph);
+ wt->graph = NULL;
}
if (wt->image_map)
@@ -232,10 +236,10 @@ gimp_warp_tool_start (GimpWarpTool *wt,
wt->coords_buffer = NULL;
}
- if (wt->render_node)
+ if (wt->graph)
{
- g_object_unref (wt->render_node);
- wt->render_node = NULL;
+ g_object_unref (wt->graph);
+ wt->graph = NULL;
}
if (wt->image_map)
@@ -376,7 +380,9 @@ gimp_warp_tool_button_press (GimpTool *tool,
if (display != tool->display)
gimp_warp_tool_start (wt, display);
- gimp_warp_tool_act_on_coords (wt, coords->x, coords->y);
+ wt->current_stroke = gegl_path_new ();
+
+ gimp_warp_tool_add_op (wt);
gimp_warp_tool_image_map_update (wt);
gimp_tool_control_activate (tool->control);
@@ -440,26 +446,26 @@ gimp_warp_tool_draw (GimpDrawTool *draw_tool)
}
static void
-gimp_warp_tool_create_render_node (GimpWarpTool *wt)
+gimp_warp_tool_create_graph (GimpWarpTool *wt)
{
GeglNode *coords, *render; /* Render nodes */
GeglNode *input, *output; /* Proxy nodes*/
- GeglNode *node; /* wraper to be returned */
+ GeglNode *graph; /* wraper to be returned */
- g_return_if_fail (wt->render_node == NULL);
+ g_return_if_fail (wt->graph == NULL);
/* render_node is not supposed to be recreated */
- node = gegl_node_new ();
+ graph = gegl_node_new ();
- input = gegl_node_get_input_proxy (node, "input");
- output = gegl_node_get_output_proxy (node, "output");
+ input = gegl_node_get_input_proxy (graph, "input");
+ output = gegl_node_get_output_proxy (graph, "output");
- coords = gegl_node_new_child (node,
+ coords = gegl_node_new_child (graph,
"operation", "gegl:buffer-source",
"buffer", wt->coords_buffer,
NULL);
- render = gegl_node_new_child (node,
+ render = gegl_node_new_child (graph,
"operation", "gegl:map-relative",
NULL);
@@ -472,20 +478,21 @@ gimp_warp_tool_create_render_node (GimpWarpTool *wt)
gegl_node_connect_to (render, "output",
output, "input");
- wt->render_node = node;
- wt->coords_node = coords;
+ wt->graph = graph;
+ wt->render_node = render;
+ wt->read_coords_buffer_node = coords;
}
static void
gimp_warp_tool_create_image_map (GimpWarpTool *wt,
GimpDrawable *drawable)
{
- if (!wt->render_node)
- gimp_warp_tool_create_render_node (wt);
+ if (!wt->graph)
+ gimp_warp_tool_create_graph (wt);
wt->image_map = gimp_image_map_new (drawable,
_("Warp transform"),
- wt->render_node,
+ wt->graph,
NULL,
NULL);
@@ -536,6 +543,32 @@ gimp_warp_tool_image_map_update (GimpWarpTool *wt)
}
static void
+gimp_warp_tool_add_op (GimpWarpTool *wt)
+{
+ GimpWarpOptions *options = GIMP_WARP_TOOL_GET_OPTIONS (wt);
+ GeglNode *new_op, *last_op;
+
+ g_return_if_fail (GEGL_IS_NODE (wt->render_node));
+
+ new_op = gegl_node_new_child (wt->graph,
+ "operation", "gimp:warp",
+ "strength", options->effect_strength,
+ "size", options->effect_size,
+ "stroke", wt->current_stroke,
+ NULL);
+
+ last_op = gegl_node_get_producer (wt->render_node, "aux", NULL);
+
+ gegl_node_disconnect (wt->render_node, "aux");
+
+ gegl_node_connect_to (last_op, "output", new_op, "input");
+ gegl_node_connect_to (new_op, "output", wt->render_node, "aux");
+
+ g_object_unref (last_op);
+}
+
+#if 0
+static void
gimp_warp_tool_act_on_coords (GimpWarpTool *wt,
gint x,
gint y)
@@ -576,3 +609,4 @@ gimp_warp_tool_act_on_coords (GimpWarpTool *wt,
}
}
}
+#endif
diff --git a/app/tools/gimpwarptool.h b/app/tools/gimpwarptool.h
index e0d2a8b..f1b4c1f 100644
--- a/app/tools/gimpwarptool.h
+++ b/app/tools/gimpwarptool.h
@@ -46,8 +46,11 @@ struct _GimpWarpTool
GeglBuffer *coords_buffer; /* Gegl buffer where coordinates are stored */
- GeglNode *coords_node; /* Gegl node that read in the coords buffer */
- GeglNode *render_node; /* Gegl node graph to render the transfromation */
+ GeglNode *graph; /* Top level GeglNode. All others node are child of it */
+ GeglNode *read_coords_buffer_node; /* Gegl node that read in the coords buffer */
+ GeglNode *render_node; /* Gegl node to render the transformation */
+
+ GeglPath *current_stroke;
GimpImageMap *image_map; /* For preview */
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]