[gimp/soc-2010-cage-2: 313/315] app: Make cage tool apply to layer mask as well if one is present
- From: Alexia Death <alexiade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage-2: 313/315] app: Make cage tool apply to layer mask as well if one is present
- Date: Wed, 3 Nov 2010 23:12:46 +0000 (UTC)
commit e529428a68a2b858ffe89e9c636861e0a3f56c05
Author: Alexia Death <alexiadeath gmail com>
Date: Wed Nov 3 21:08:10 2010 +0200
app: Make cage tool apply to layer mask as well if one is present
app/tools/gimpcagetool.c | 112 ++++++++++++++++++++++++++--------------------
1 files changed, 63 insertions(+), 49 deletions(-)
---
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 3dceca7..9b99874 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -115,6 +115,9 @@ static void gimp_cage_tool_compute_coef (GimpCageTool *ct
GimpDisplay *display);
static void gimp_cage_tool_process (GimpCageTool *ct,
GimpDisplay *display);
+static void gimp_cage_tool_process_drawable (GimpCageTool *ct,
+ GimpDrawable *drawable,
+ GimpProgress *progress);
static void gimp_cage_tool_prepare_preview (GimpCageTool *ct,
GimpDisplay *display);
static gboolean gimp_cage_tool_update_preview (GimpTool *tool);
@@ -721,20 +724,22 @@ gimp_cage_tool_get_render_node (GimpCageTool *ct,
{
GimpCageOptions *options = GIMP_CAGE_TOOL_GET_OPTIONS (ct);
- GeglNode *cage, *render; /* Render nodes */
- GeglNode *input, *output, *aux; /* Proxy nodes*/
+ GeglNode *coef, *cage, *render; /* Render nodes */
+ GeglNode *input, *output; /* Proxy nodes*/
GeglNode *node; /* wraper to be returned */
node = gegl_node_new_child (parent,
- /* FIXME: Leavin this empty causes compiler warning,
- * but adding it causes a hang.
- * "operation", "gegl:nop", */
- NULL);
+ NULL,
+ NULL);
input = gegl_node_get_input_proxy (node, "input");
- aux = gegl_node_get_input_proxy (node, "aux");
+
output = gegl_node_get_output_proxy (node, "output");
+ coef = gegl_node_new_child (ct->node_preview,
+ "operation", "gegl:buffer-source",
+ "buffer", ct->coef,
+ NULL);
cage = gegl_node_new_child (parent,
"operation", "gimp:cage_transform",
@@ -749,7 +754,7 @@ gimp_cage_tool_get_render_node (GimpCageTool *ct,
gegl_node_connect_to (input, "output",
cage, "input");
- gegl_node_connect_to (aux, "output",
+ gegl_node_connect_to (coef, "output",
cage, "aux");
gegl_node_connect_to (input, "output",
@@ -771,7 +776,6 @@ gimp_cage_tool_prepare_preview (GimpCageTool *ct,
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
- GeglNode *coef;
GeglNode *node;
if (ct->node_preview)
@@ -782,17 +786,9 @@ gimp_cage_tool_prepare_preview (GimpCageTool *ct,
ct->node_preview = gegl_node_new ();
- coef = gegl_node_new_child (ct->node_preview,
- "operation", "gegl:buffer-source",
- "buffer", ct->coef,
- NULL);
-
node = gimp_cage_tool_get_render_node (ct,
ct->node_preview);
- gegl_node_connect_to (coef, "output",
- node, "aux");
-
ct->image_map = gimp_image_map_new (drawable,
_("Cage transform"),
node,
@@ -813,13 +809,11 @@ gimp_cage_tool_update_preview (GimpTool *tool)
return FALSE;
}
- gimp_projection_flush_now (gimp_image_get_projection (image));
- gimp_display_flush_now (tool->display);
-
if (!gimp_image_map_is_busy(ct->image_map))
{
ct->idle_id = 0;
-
+ gimp_projection_flush_now (gimp_image_get_projection (image));
+ gimp_display_flush_now (tool->display);
return FALSE;
}
@@ -832,25 +826,62 @@ static void
gimp_cage_tool_process (GimpCageTool *ct,
GimpDisplay *display)
{
- TileManager *new_tiles = NULL;
- TileManager *old_tiles = NULL;
- GeglRectangle rect;
+
GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
- GimpProgress *progress;
- GeglProcessor *processor;
- gdouble value;
+ GimpLayer *layer = gimp_image_get_active_layer (image);
+ GimpDrawable *drawable = GIMP_DRAWABLE (layer);
+ GimpDrawable *mask = GIMP_DRAWABLE (gimp_layer_get_mask(layer));
+
g_return_if_fail (ct->coef);
- if (GIMP_IS_LAYER (drawable))
- {
+ if (GIMP_IS_DRAWABLE (drawable))
+ {
+ GimpProgress *progress;
+ progress = gimp_progress_start (GIMP_PROGRESS (display),
+ _("Rendering cage transform"),
+ FALSE);
+
+ gimp_cage_tool_process_drawable (ct, drawable, progress);
+
+ gimp_progress_end (progress);
+
+ if(mask)
+ {
+ progress = gimp_progress_start (GIMP_PROGRESS (display),
+ _("Rendering mask cage transform"),
+ FALSE);
+ gimp_cage_tool_process_drawable (ct, mask, progress);
+
+ gimp_progress_end (progress);
+ }
+
+ gimp_image_flush (image);
+
+ gimp_cage_tool_halt (ct);
+ }
+}
+
+static void
+gimp_cage_tool_process_drawable (GimpCageTool *ct,
+ GimpDrawable *drawable,
+ GimpProgress *progress)
+
+{
+ TileManager *new_tiles = NULL;
+ TileManager *old_tiles = NULL;
+ GeglRectangle rect;
+ GeglProcessor *processor;
+ gdouble value;
+
+ if (GIMP_IS_DRAWABLE (drawable))
+ {
GeglNode *gegl = gegl_node_new ();
/* reverse transform */
- GeglNode *coef, *node, *input, *output;
+ GeglNode *node, *input, *output;
old_tiles = gimp_drawable_get_tiles (drawable);
@@ -860,10 +891,6 @@ gimp_cage_tool_process (GimpCageTool *ct,
"linear", TRUE,
NULL);
- coef = gegl_node_new_child (gegl,
- "operation", "gegl:buffer-source",
- "buffer", ct->coef,
- NULL);
node = gimp_cage_tool_get_render_node (ct,
gegl);
@@ -878,9 +905,6 @@ gimp_cage_tool_process (GimpCageTool *ct,
gegl_node_connect_to (input, "output",
node, "input");
- gegl_node_connect_to (coef, "output",
- node, "aux");
-
gegl_node_connect_to (node, "output",
output, "input");
@@ -898,10 +922,6 @@ gimp_cage_tool_process (GimpCageTool *ct,
output, "input");*/
- progress = gimp_progress_start (GIMP_PROGRESS (display),
- _("Rendering transform"),
- FALSE);
-
processor = gegl_node_new_processor (output, NULL);
while (gegl_processor_work (processor, &value))
@@ -921,16 +941,10 @@ gimp_cage_tool_process (GimpCageTool *ct,
g_object_unref (gegl);
- gimp_image_flush (image);
-
- gimp_progress_end (progress);
gegl_processor_destroy (processor);
-
- gimp_cage_tool_halt (ct);
- }
+ }
}
-
static void
gimp_cage_tool_halt (GimpCageTool *ct)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]