[gimp/metadata-browser] app: keep the transform graph around during one paint stroke



commit ad56fb534647f6cf19570f6e44f998d2b1ad2d0b
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 31 02:16:59 2012 +0200

    app: keep the transform graph around during one paint stroke

 app/paint/gimpperspectiveclone.c |   68 +++++++++++++++++++++++++++++--------
 app/paint/gimpperspectiveclone.h |    5 +++
 2 files changed, 58 insertions(+), 15 deletions(-)
---
diff --git a/app/paint/gimpperspectiveclone.c b/app/paint/gimpperspectiveclone.c
index 0f054fc..4267530 100644
--- a/app/paint/gimpperspectiveclone.c
+++ b/app/paint/gimpperspectiveclone.c
@@ -174,12 +174,43 @@ gimp_perspective_clone_paint (GimpPaintCore    *paint_core,
 
           source_core->first_stroke = TRUE;
         }
-      else if (options->align_mode == GIMP_SOURCE_ALIGN_NO)
+      else
         {
-          source_core->orig_src_x = source_core->src_x;
-          source_core->orig_src_y = source_core->src_y;
+          if (options->align_mode == GIMP_SOURCE_ALIGN_NO)
+            {
+              source_core->orig_src_x = source_core->src_x;
+              source_core->orig_src_y = source_core->src_y;
 
-          source_core->first_stroke = TRUE;
+              source_core->first_stroke = TRUE;
+            }
+
+          clone->node = gegl_node_new ();
+
+          g_object_set (clone->node,
+                        "dont-cache", TRUE,
+                        NULL);
+
+          clone->src_node =
+            gegl_node_new_child (clone->node,
+                                 "operation", "gegl:buffer-source",
+                                  NULL);
+
+          clone->transform_node =
+            gegl_node_new_child (clone->node,
+                                 "operation",  "gegl:transform",
+                                 "filter",     gimp_interpolation_to_gegl_filter (GIMP_INTERPOLATION_NONE),
+                                 "hard-edges", TRUE,
+                                 NULL);
+
+          clone->dest_node =
+            gegl_node_new_child (clone->node,
+                                 "operation", "gegl:write-buffer",
+                                 NULL);
+
+          gegl_node_link_many (clone->src_node,
+                               clone->transform_node,
+                               clone->dest_node,
+                               NULL);
         }
       break;
 
@@ -240,6 +271,14 @@ gimp_perspective_clone_paint (GimpPaintCore    *paint_core,
       break;
 
     case GIMP_PAINT_STATE_FINISH:
+      if (clone->node)
+        {
+          g_object_unref (clone->node);
+          clone->node = NULL;
+          clone->src_node = NULL;
+          clone->transform_node = NULL;
+          clone->dest_node = NULL;
+        }
       break;
 
     default:
@@ -276,7 +315,6 @@ gimp_perspective_clone_get_source (GimpSourceCore   *source_core,
   GeglBuffer           *orig_buffer;
   GeglBuffer           *dest_buffer;
   GimpMatrix3           matrix;
-  GeglNode             *affine;
   gchar                *matrix_string;
   GimpMatrix3           gegl_matrix;
 
@@ -365,19 +403,19 @@ gimp_perspective_clone_get_source (GimpSourceCore   *source_core,
   gimp_matrix3_translate (&gegl_matrix, -x1d, -y1d);
 
   matrix_string = gegl_matrix3_to_string ((GeglMatrix3 *) &gegl_matrix);
-  affine = gegl_node_new_child (NULL,
-                                "operation",  "gegl:transform",
-                                "transform",  matrix_string,
-                                "filter",     gimp_interpolation_to_gegl_filter (GIMP_INTERPOLATION_LINEAR),
-                                "hard-edges", TRUE,
-                                NULL);
+  gegl_node_set (clone->transform_node,
+                 "transform", matrix_string,
+                 NULL);
   g_free (matrix_string);
 
-  gimp_apply_operation (orig_buffer, NULL, NULL,
-                        affine,
-                        dest_buffer, NULL);
+  gegl_node_set (clone->src_node,
+                 "buffer", orig_buffer,
+                 NULL);
+  gegl_node_set (clone->dest_node,
+                 "buffer", dest_buffer,
+                 NULL);
 
-  g_object_unref (affine);
+  gegl_node_process (clone->dest_node);
 
   g_object_unref (orig_buffer);
 
diff --git a/app/paint/gimpperspectiveclone.h b/app/paint/gimpperspectiveclone.h
index 2acdf9c..a3d56f0 100644
--- a/app/paint/gimpperspectiveclone.h
+++ b/app/paint/gimpperspectiveclone.h
@@ -44,6 +44,11 @@ struct _GimpPerspectiveClone
 
   GimpMatrix3  transform;
   GimpMatrix3  transform_inv;
+
+  GeglNode    *node;
+  GeglNode    *src_node;
+  GeglNode    *transform_node;
+  GeglNode    *dest_node;
 };
 
 struct _GimpPerspectiveCloneClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]