gimp r24573 - in trunk: . app/core app/tools



Author: mitch
Date: Wed Jan  9 01:06:46 2008
New Revision: 24573
URL: http://svn.gnome.org/viewvc/gimp?rev=24573&view=rev

Log:
2008-01-09  Michael Natterer  <mitch gimp org>

	* app/core/core-types.h: add typedef GimpImageMapApplyFunc here.

	* app/core/gimpimagemap.[ch] (gimp_image_map_new): add apply_func
	and apply_data parameters.

	(gimp_image_map_apply): remove them here and add a GeglRectangle
	parameter which is the visible area of the affected drawable.

	* app/tools/gimpimagemaptool.[ch]: keep apply_func and apply_data
	around in the GimpImageMapTool struct.

	(gimp_image_map_tool_create_map): pass them to gimp_image_map_new().

	(gimp_image_map_tool_map): call gimp_image_map_apply() here and
	pass the drawable's visible rectangle.

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorizetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c (init): set apply_func and
	apply_data in the parent instance.

	(map): remove calls to gimp_image_map_apply().



Modified:
   trunk/ChangeLog
   trunk/app/core/core-types.h
   trunk/app/core/gimpimagemap.c
   trunk/app/core/gimpimagemap.h
   trunk/app/tools/gimpbrightnesscontrasttool.c
   trunk/app/tools/gimpcolorbalancetool.c
   trunk/app/tools/gimpcolorizetool.c
   trunk/app/tools/gimpcurvestool.c
   trunk/app/tools/gimphuesaturationtool.c
   trunk/app/tools/gimpimagemaptool.c
   trunk/app/tools/gimpimagemaptool.h
   trunk/app/tools/gimplevelstool.c
   trunk/app/tools/gimpposterizetool.c
   trunk/app/tools/gimpthresholdtool.c

Modified: trunk/app/core/core-types.h
==============================================================================
--- trunk/app/core/core-types.h	(original)
+++ trunk/app/core/core-types.h	Wed Jan  9 01:06:46 2008
@@ -165,15 +165,19 @@
 
 /*  functions  */
 
-typedef void     (* GimpInitStatusFunc)   (const gchar      *text1,
-                                           const gchar      *text2,
-                                           gdouble           percentage);
-
-typedef gboolean (* GimpObjectFilterFunc) (const GimpObject *object,
-                                           gpointer          user_data);
-
-typedef gint64   (* GimpMemsizeFunc)      (gpointer          instance,
-                                           gint64           *gui_size);
+typedef void     (* GimpInitStatusFunc)    (const gchar      *text1,
+                                            const gchar      *text2,
+                                            gdouble           percentage);
+
+typedef gboolean (* GimpObjectFilterFunc)  (const GimpObject *object,
+                                            gpointer          user_data);
+
+typedef gint64   (* GimpMemsizeFunc)       (gpointer          instance,
+                                            gint64           *gui_size);
+
+typedef void     (* GimpImageMapApplyFunc) (gpointer          apply_data,
+                                            PixelRegion      *srcPR,
+                                            PixelRegion      *destPR);
 
 
 /*  structs  */

Modified: trunk/app/core/gimpimagemap.c
==============================================================================
--- trunk/app/core/gimpimagemap.c	(original)
+++ trunk/app/core/gimpimagemap.c	Wed Jan  9 01:06:46 2008
@@ -295,15 +295,18 @@
 }
 
 GimpImageMap *
-gimp_image_map_new (GimpDrawable *drawable,
-                    const gchar  *undo_desc,
-                    GeglNode     *operation)
+gimp_image_map_new (GimpDrawable          *drawable,
+                    const gchar           *undo_desc,
+                    GeglNode              *operation,
+                    GimpImageMapApplyFunc  apply_func,
+                    gpointer               apply_data)
 {
   GimpImageMap *image_map;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
   g_return_val_if_fail (operation == NULL || GEGL_IS_NODE (operation), NULL);
+  g_return_val_if_fail (operation != NULL || apply_func != NULL, NULL);
 
   image_map = g_object_new (GIMP_TYPE_IMAGE_MAP, NULL);
 
@@ -313,25 +316,25 @@
   if (operation)
     image_map->operation = g_object_ref (operation);
 
+  image_map->apply_func = apply_func;
+  image_map->apply_data = apply_data;
+
   gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable));
 
   return image_map;
 }
 
 void
-gimp_image_map_apply (GimpImageMap          *image_map,
-                      GimpImageMapApplyFunc  apply_func,
-                      gpointer               apply_data)
+gimp_image_map_apply (GimpImageMap        *image_map,
+                      const GeglRectangle *visible)
 {
   GeglRectangle rect;
-  gint          undo_offset_x, undo_offset_y;
-  gint          undo_width, undo_height;
+  gint          undo_offset_x;
+  gint          undo_offset_y;
+  gint          undo_width;
+  gint          undo_height;
 
   g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
-  g_return_if_fail (apply_func != NULL);
-
-  image_map->apply_func = apply_func;
-  image_map->apply_data = apply_data;
 
   /*  If we're still working, remove the timer  */
   if (image_map->idle_id)

Modified: trunk/app/core/gimpimagemap.h
==============================================================================
--- trunk/app/core/gimpimagemap.h	(original)
+++ trunk/app/core/gimpimagemap.h	Wed Jan  9 01:06:46 2008
@@ -23,11 +23,6 @@
 #include "gimpobject.h"
 
 
-typedef void (* GimpImageMapApplyFunc) (gpointer     data,
-                                        PixelRegion *srcPR,
-                                        PixelRegion *destPR);
-
-
 #define GIMP_TYPE_IMAGE_MAP            (gimp_image_map_get_type ())
 #define GIMP_IMAGE_MAP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMap))
 #define GIMP_IMAGE_MAP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass))
@@ -57,11 +52,12 @@
 
 GimpImageMap * gimp_image_map_new          (GimpDrawable          *drawable,
                                             const gchar           *undo_desc,
-                                            GeglNode              *operation);
-
-void           gimp_image_map_apply        (GimpImageMap          *image_map,
+                                            GeglNode              *operation,
                                             GimpImageMapApplyFunc  apply_func,
                                             gpointer               apply_data);
+
+void           gimp_image_map_apply        (GimpImageMap          *image_map,
+                                            const GeglRectangle   *visible);
 void           gimp_image_map_commit       (GimpImageMap          *image_map);
 void           gimp_image_map_clear        (GimpImageMap          *image_map);
 void           gimp_image_map_abort        (GimpImageMap          *image_map);

Modified: trunk/app/tools/gimpbrightnesscontrasttool.c
==============================================================================
--- trunk/app/tools/gimpbrightnesscontrasttool.c	(original)
+++ trunk/app/tools/gimpbrightnesscontrasttool.c	Wed Jan  9 01:06:46 2008
@@ -130,9 +130,14 @@
 static void
 gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (bc_tool);
+
   bc_tool->brightness = 0.0;
   bc_tool->contrast   = 0.0;
   bc_tool->lut        = gimp_lut_new ();
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = bc_tool->lut;
 }
 
 static void
@@ -212,9 +217,6 @@
                                  bc_tool->brightness / 255.0,
                                  bc_tool->contrast / 127.0,
                                  gimp_drawable_bytes (im_tool->drawable));
-  gimp_image_map_apply (im_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        bc_tool->lut);
 }
 
 

Modified: trunk/app/tools/gimpcolorbalancetool.c
==============================================================================
--- trunk/app/tools/gimpcolorbalancetool.c	(original)
+++ trunk/app/tools/gimpcolorbalancetool.c	Wed Jan  9 01:06:46 2008
@@ -111,10 +111,15 @@
 static void
 gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (cb_tool);
+
   cb_tool->color_balance = g_slice_new0 (ColorBalance);
   cb_tool->transfer_mode = GIMP_MIDTONES;
 
   color_balance_init (cb_tool->color_balance);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) color_balance;
+  im_tool->apply_data = cb_tool->color_balance;
 }
 
 static void
@@ -164,9 +169,6 @@
   GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
 
   color_balance_create_lookup_tables (cb_tool->color_balance);
-  gimp_image_map_apply (im_tool->image_map,
-                        (GimpImageMapApplyFunc) color_balance,
-                        cb_tool->color_balance);
 }
 
 

Modified: trunk/app/tools/gimpcolorizetool.c
==============================================================================
--- trunk/app/tools/gimpcolorizetool.c	(original)
+++ trunk/app/tools/gimpcolorizetool.c	Wed Jan  9 01:06:46 2008
@@ -109,9 +109,14 @@
 static void
 gimp_colorize_tool_init (GimpColorizeTool *col_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (col_tool);
+
   col_tool->colorize = g_slice_new0 (Colorize);
 
   colorize_init (col_tool->colorize);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) colorize;
+  im_tool->apply_data = col_tool->colorize;
 }
 
 static void
@@ -176,10 +181,6 @@
     }
 
   colorize_calculate (col_tool->colorize);
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) colorize,
-                        col_tool->colorize);
 }
 
 

Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c	(original)
+++ trunk/app/tools/gimpcurvestool.c	Wed Jan  9 01:06:46 2008
@@ -171,7 +171,8 @@
 static void
 gimp_curves_tool_init (GimpCurvesTool *tool)
 {
-  gint i;
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+  gint              i;
 
   for (i = 0; i < G_N_ELEMENTS (tool->curve); i++)
     {
@@ -187,6 +188,9 @@
 
   for (i = 0; i < G_N_ELEMENTS (tool->col_value); i++)
     tool->col_value[i] = -1;
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = tool->lut;
 }
 
 static void
@@ -411,10 +415,6 @@
                   (GimpLutFunc) curves_lut_func,
                   &curves,
                   gimp_drawable_bytes (image_map_tool->drawable));
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        tool->lut);
 }
 
 

Modified: trunk/app/tools/gimphuesaturationtool.c
==============================================================================
--- trunk/app/tools/gimphuesaturationtool.c	(original)
+++ trunk/app/tools/gimphuesaturationtool.c	Wed Jan  9 01:06:46 2008
@@ -129,10 +129,15 @@
 static void
 gimp_hue_saturation_tool_init (GimpHueSaturationTool *hs_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (hs_tool);
+
   hs_tool->hue_saturation = g_slice_new0 (HueSaturation);
   hs_tool->hue_partition  = GIMP_ALL_HUES;
 
   hue_saturation_init (hs_tool->hue_saturation);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) hue_saturation;
+  im_tool->apply_data = hs_tool->hue_saturation;
 }
 
 static void
@@ -179,11 +184,6 @@
 static void
 gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool)
 {
-  GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) hue_saturation,
-                        hs_tool->hue_saturation);
 }
 
 

Modified: trunk/app/tools/gimpimagemaptool.c
==============================================================================
--- trunk/app/tools/gimpimagemaptool.c	(original)
+++ trunk/app/tools/gimpimagemaptool.c	Wed Jan  9 01:06:46 2008
@@ -49,6 +49,8 @@
 #include "widgets/gimpwidgets-utils.h"
 
 #include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+#include "display/gimpdisplayshell-transform.h"
 
 #include "gimpcoloroptions.h"
 #include "gimpimagemaptool.h"
@@ -421,7 +423,33 @@
 static void
 gimp_image_map_tool_map (GimpImageMapTool *tool)
 {
+  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (GIMP_TOOL (tool)->display->shell);
+  GimpItem         *item  = GIMP_ITEM (tool->drawable);
+  gint              x, y;
+  gint              w, h;
+  gint              off_x, off_y;
+  GeglRectangle     visible;
+
   GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool);
+
+  gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h);
+
+  gimp_item_offsets (item, &off_x, &off_y);
+
+  gimp_rectangle_intersect (x, y, w, h,
+                            off_x,
+                            off_y,
+                            gimp_item_width  (item),
+                            gimp_item_height (item),
+                            &visible.x,
+                            &visible.y,
+                            &visible.width,
+                            &visible.height);
+
+  visible.x -= off_x;
+  visible.y -= off_y;
+
+  gimp_image_map_apply (tool->image_map, &visible);
 }
 
 static void
@@ -454,7 +482,9 @@
   tool->image_map = gimp_image_map_new (tool->drawable,
                                         GIMP_TOOL (tool)->tool_info->blurb,
                                         config->use_gegl ?
-                                        tool->operation : NULL);
+                                        tool->operation : NULL,
+                                        tool->apply_func,
+                                        tool->apply_data);
 
   g_signal_connect (tool->image_map, "flush",
                     G_CALLBACK (gimp_image_map_tool_flush),

Modified: trunk/app/tools/gimpimagemaptool.h
==============================================================================
--- trunk/app/tools/gimpimagemaptool.h	(original)
+++ trunk/app/tools/gimpimagemaptool.h	Wed Jan  9 01:06:46 2008
@@ -41,20 +41,24 @@
 
 struct _GimpImageMapTool
 {
-  GimpColorTool  parent_instance;
+  GimpColorTool          parent_instance;
 
-  GimpDrawable  *drawable;
-  GeglNode      *operation;
-  GimpImageMap  *image_map;
+  GimpDrawable          *drawable;
+
+  GeglNode              *operation;
+  GimpImageMapApplyFunc  apply_func;
+  gpointer               apply_data;
+
+  GimpImageMap          *image_map;
 
   /* dialog */
-  GtkWidget     *shell;
-  GtkWidget     *main_vbox;
-  GtkWidget     *load_button;
-  GtkWidget     *save_button;
+  GtkWidget             *shell;
+  GtkWidget             *main_vbox;
+  GtkWidget             *load_button;
+  GtkWidget             *save_button;
 
   /* settings file dialog */
-  GtkWidget     *settings_dialog;
+  GtkWidget             *settings_dialog;
 };
 
 struct _GimpImageMapToolClass

Modified: trunk/app/tools/gimplevelstool.c
==============================================================================
--- trunk/app/tools/gimplevelstool.c	(original)
+++ trunk/app/tools/gimplevelstool.c	Wed Jan  9 01:06:46 2008
@@ -175,6 +175,8 @@
 static void
 gimp_levels_tool_init (GimpLevelsTool *tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
+
   tool->lut           = gimp_lut_new ();
   tool->levels        = g_slice_new0 (Levels);
   tool->hist          = NULL;
@@ -182,6 +184,9 @@
   tool->active_picker = NULL;
 
   levels_init (tool->levels);
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = tool->lut;
 }
 
 static void
@@ -293,10 +298,6 @@
                   (GimpLutFunc) levels_lut_func,
                   tool->levels,
                   gimp_drawable_bytes (image_map_tool->drawable));
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        tool->lut);
 }
 
 

Modified: trunk/app/tools/gimpposterizetool.c
==============================================================================
--- trunk/app/tools/gimpposterizetool.c	(original)
+++ trunk/app/tools/gimpposterizetool.c	Wed Jan  9 01:06:46 2008
@@ -106,8 +106,13 @@
 static void
 gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
+
   posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
   posterize_tool->lut    = gimp_lut_new ();
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
+  im_tool->apply_data = posterize_tool->lut;
 }
 
 static void
@@ -179,10 +184,6 @@
   posterize_lut_setup (posterize_tool->lut,
                        posterize_tool->levels,
                        gimp_drawable_bytes (image_map_tool->drawable));
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) gimp_lut_process,
-                        posterize_tool->lut);
 }
 
 

Modified: trunk/app/tools/gimpthresholdtool.c
==============================================================================
--- trunk/app/tools/gimpthresholdtool.c	(original)
+++ trunk/app/tools/gimpthresholdtool.c	Wed Jan  9 01:06:46 2008
@@ -111,11 +111,16 @@
 static void
 gimp_threshold_tool_init (GimpThresholdTool *t_tool)
 {
+  GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
+
   t_tool->threshold = g_slice_new0 (Threshold);
   t_tool->hist      = NULL;
 
   t_tool->threshold->low_threshold  = 127;
   t_tool->threshold->high_threshold = 255;
+
+  im_tool->apply_func = (GimpImageMapApplyFunc) threshold;
+  im_tool->apply_data = t_tool->threshold;
 }
 
 static void
@@ -200,10 +205,6 @@
                      "high", t_tool->threshold->high_threshold / 255.0,
                      NULL);
     }
-
-  gimp_image_map_apply (image_map_tool->image_map,
-                        (GimpImageMapApplyFunc) threshold,
-                        t_tool->threshold);
 }
 
 



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