[gimp/soc-2010-cage] gimpcagetool: use cage_transform and gegl_render_mapping to do the transform gimpoperationcage: clea



commit 1854aeca502f390ca771dff0ba0e92529e5f2987
Author: Michael Muré <batolettre gmail com>
Date:   Sat Aug 7 15:10:23 2010 +0200

    gimpcagetool: use cage_transform and gegl_render_mapping to do the transform
    gimpoperationcage: cleaning
    gimpcageconfig: cleaning

 app/gegl/gimpcageconfig.h    |    2 +-
 app/gegl/gimpoperationcage.c |   12 +++---
 app/tools/gimpcagetool.c     |   73 ++++++++++++++++++++++++++++++++++++-----
 app/tools/gimpcagetool.h     |    2 +-
 4 files changed, 72 insertions(+), 17 deletions(-)
---
diff --git a/app/gegl/gimpcageconfig.h b/app/gegl/gimpcageconfig.h
index 3db18b6..6fa9ed9 100644
--- a/app/gegl/gimpcageconfig.h
+++ b/app/gegl/gimpcageconfig.h
@@ -43,7 +43,7 @@ struct _GimpCageConfig
   
   GimpVector2              *cage_vertices; /* cage before deformation */
   GimpVector2              *cage_vertices_d; /* cage after deformation */
-  gdouble        					 *scaling_factor;
+  gdouble                  *scaling_factor;
 };
 
 
diff --git a/app/gegl/gimpoperationcage.c b/app/gegl/gimpoperationcage.c
index 9f96a0b..8c0a674 100644
--- a/app/gegl/gimpoperationcage.c
+++ b/app/gegl/gimpoperationcage.c
@@ -30,8 +30,8 @@
 #include "gimpcageconfig.h"
 
 
-static void           gimp_operation_cage_finalize          				(GObject              *object);
-static void           gimp_operation_cage_get_property      				(GObject              *object,
+static void           gimp_operation_cage_finalize                  (GObject              *object);
+static void           gimp_operation_cage_get_property              (GObject              *object,
                                                                      guint                 property_id,
                                                                      GValue               *value,
                                                                      GParamSpec           *pspec);
@@ -60,9 +60,9 @@ G_DEFINE_TYPE (GimpOperationCage, gimp_operation_cage,
 static void
 gimp_operation_cage_class_init (GimpOperationCageClass *klass)
 {
-  GObjectClass                    *object_class    	= G_OBJECT_CLASS (klass);
-  GeglOperationClass              *operation_class 	= GEGL_OPERATION_CLASS (klass);
-  GeglOperationComposerClass      *composer_class		= GEGL_OPERATION_COMPOSER_CLASS (klass);
+  GObjectClass                    *object_class     = G_OBJECT_CLASS (klass);
+  GeglOperationClass              *operation_class  = GEGL_OPERATION_CLASS (klass);
+  GeglOperationComposerClass      *composer_class   = GEGL_OPERATION_COMPOSER_CLASS (klass);
 
   object_class->get_property          = gimp_operation_cage_get_property;
   object_class->set_property          = gimp_operation_cage_set_property;
@@ -96,7 +96,7 @@ gimp_operation_cage_init (GimpOperationCage *self)
 }
 
 static void
-gimp_operation_cage_finalize	(GObject	*object)
+gimp_operation_cage_finalize  (GObject  *object)
 {
   GimpOperationCage *self = GIMP_OPERATION_CAGE (object);
 
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 21d299f..14377da 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -42,6 +42,8 @@
 
 #include "core/gimpdrawable.h"
 #include "core/gimpdrawable-operation.h"
+#include "core/gimpdrawable-shadow.h"
+#include "base/tile-manager.h"
 
 #include "widgets/gimphelp-ids.h"
 
@@ -50,6 +52,8 @@
 
 #include "gimp-intl.h"
 
+#include <stdio.h>
+
 /*static gboolean     gimp_cage_tool_initialize     (GimpTool    *tool,
                                                    GimpDisplay *display,
                                                    GError     **error);*/
@@ -261,7 +265,6 @@ gimp_cage_tool_button_press (GimpTool              *tool,
 
     gimp_cage_config_reverse_cage_if_needed (config);
     gimp_cage_tool_compute_coef (ct, display);
-    gimp_cage_tool_process (ct, display);
   }
 
   gimp_draw_tool_resume (GIMP_DRAW_TOOL (ct));
@@ -300,7 +303,8 @@ gimp_cage_tool_key_press (GimpTool    *tool,
     case GDK_Return:
     case GDK_KP_Enter:
     case GDK_ISO_Enter:
-      gimp_cage_tool_switch_to_deform (ct);
+      if (ct->cage_complete)
+      gimp_cage_tool_process (ct, display); /*RUN IT BABY*/
       return TRUE;
 
     case GDK_Escape:
@@ -529,6 +533,7 @@ gimp_cage_tool_compute_coef (GimpCageTool *ct,
   GeglBuffer *buffer;
   gdouble value;
   
+  printf("compute the coef\n");
   if (ct->coef)
   {
     gegl_buffer_destroy (ct->coef);
@@ -577,6 +582,9 @@ static void
 gimp_cage_tool_process (GimpCageTool *ct,
                         GimpDisplay  *display)
 {
+  TileManager  *new_tiles;
+  GeglRectangle rect;
+  
   GimpImage    *image    = gimp_display_get_image (display);
   GimpDrawable *drawable = gimp_image_get_active_drawable (image);
   GimpProgress *progress = gimp_progress_start (GIMP_PROGRESS (display),
@@ -584,13 +592,21 @@ gimp_cage_tool_process (GimpCageTool *ct,
                                                 FALSE);
   g_return_if_fail (ct->coef);
 
+  printf("process the cage\n");
+  
   if (GIMP_IS_LAYER (drawable))
   {
     GeglNode *gegl = gegl_node_new ();
-    GeglNode *coef, *cage;
-                                  
+    GeglNode *coef, *cage, *render, *input, *output;
+    
+    input  = gegl_node_new_child (gegl,
+                              "operation",    "gimp:tilemanager-source",
+                              "tile-manager", gimp_drawable_get_tiles (drawable),
+                              "linear",       TRUE,
+                              NULL);
+                                
     cage = gegl_node_new_child (gegl,
-                                  "operation", "gegl:cage",
+                                  "operation", "gegl:cage_transform",
                                   "config", ct->config,
                                   NULL);
     
@@ -598,12 +614,51 @@ gimp_cage_tool_process (GimpCageTool *ct,
                                 "operation", "gegl:buffer-source",
                                 "buffer",    ct->coef,
                                 NULL);
-    
+
     gegl_node_connect_to (coef, "output",
-                          cage, "aux");
+                          cage, "input");
+                          
+    render = gegl_node_new_child (gegl,
+                                  "operation", "gegl:render_mapping",
+                                  NULL);
+    
+    gegl_node_connect_to (cage, "output",
+                          render, "aux");
+    
+                                
+/*    render = gegl_node_new_child (gegl,
+                                  "operation", "gegl:debugit",
+                                  NULL);*/
+    
+    gegl_node_connect_to (input, "output",
+                          render, "input");
+                          
+/*    gimp_drawable_apply_operation (drawable, progress, _("Cage transform"),
+                                   render, TRUE);*/
+    
+    new_tiles = gimp_drawable_get_shadow_tiles (drawable);
+    
+    output = gegl_node_new_child (gegl,
+                                "operation",    "gimp:tilemanager-sink",
+                                "tile-manager", new_tiles,
+                                "linear",       TRUE,
+                                NULL);
+    
+    gegl_node_connect_to (render, "output",
+                          output, "input");
 
-    gimp_drawable_apply_operation (drawable, progress, _("Cage transform"),
-                                   cage, TRUE);
+    gegl_node_process (output);
+    
+    rect.x      = 0;
+    rect.y      = 0;
+    rect.width  = tile_manager_width  (new_tiles);
+    rect.height = tile_manager_height (new_tiles);
+  
+    gimp_drawable_merge_shadow_tiles (drawable, TRUE, _("Cage transform"));
+    gimp_drawable_free_shadow_tiles (drawable);
+
+    gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
+    
     g_object_unref (gegl);
     
     if (progress)
diff --git a/app/tools/gimpcagetool.h b/app/tools/gimpcagetool.h
index c598d47..6be9254 100644
--- a/app/tools/gimpcagetool.h
+++ b/app/tools/gimpcagetool.h
@@ -46,7 +46,7 @@ struct _GimpCageTool
   gint                  handle_moved;
   gboolean              cage_complete;
   
-  GeglBuffer           *coef;
+  GeglBuffer					 *coef;
 };
 
 



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