gimp r25734 - in trunk: . app/core app/pdb tools/pdbgen/pdb



Author: neo
Date: Wed May 21 16:45:44 2008
New Revision: 25734
URL: http://svn.gnome.org/viewvc/gimp?rev=25734&view=rev

Log:
2008-05-21  Sven Neumann  <sven gimp org>

	* app/core/Makefile.am
	* app/core/gimpdrawable-process.[ch]: new file holding code to
	apply a PixelProcessor to the full drawable.

	* app/core/gimpdrawable-desaturate.c
	* app/core/gimpdrawable-invert.c: use the new helper function.

	* app/core/gimpdrawable-desaturate.[ch] 
(gimp_drawable_desaturate):
	take a GimpProgress parameter.

	* tools/pdbgen/pdb/color.pdb: changed accordingly.

	* app/pdb/color-cmds.c: regenerated.



Added:
   trunk/app/core/gimpdrawable-process.c
   trunk/app/core/gimpdrawable-process.h
Modified:
   trunk/ChangeLog
   trunk/app/core/Makefile.am
   trunk/app/core/gimpdrawable-curves.c
   trunk/app/core/gimpdrawable-desaturate.c
   trunk/app/core/gimpdrawable-desaturate.h
   trunk/app/core/gimpdrawable-invert.c
   trunk/app/pdb/color-cmds.c
   trunk/tools/pdbgen/pdb/color.pdb

Modified: trunk/app/core/Makefile.am
==============================================================================
--- trunk/app/core/Makefile.am	(original)
+++ trunk/app/core/Makefile.am	Wed May 21 16:45:44 2008
@@ -145,6 +145,8 @@
 	gimpdrawable-posterize.h		\
 	gimpdrawable-preview.c			\
 	gimpdrawable-preview.h			\
+	gimpdrawable-process.c			\
+	gimpdrawable-process.h			\
 	gimpdrawable-shadow.c			\
 	gimpdrawable-shadow.h			\
 	gimpdrawable-stroke.c			\

Modified: trunk/app/core/gimpdrawable-curves.c
==============================================================================
--- trunk/app/core/gimpdrawable-curves.c	(original)
+++ trunk/app/core/gimpdrawable-curves.c	Wed May 21 16:45:44 2008
@@ -25,7 +25,6 @@
 #include "base/curves.h"
 #include "base/gimplut.h"
 #include "base/pixel-processor.h"
-#include "base/pixel-region.h"
 
 #include "gegl/gimpcurvesconfig.h"
 
@@ -37,7 +36,7 @@
 #include "gimpdrawable.h"
 #include "gimpdrawable-curves.h"
 #include "gimpdrawable-operation.h"
-#include "gimpdrawable-shadow.h"
+#include "gimpdrawable-process.h"
 
 #include "gimp-intl.h"
 
@@ -171,40 +170,20 @@
     }
   else
     {
-      gint x, y, width, height;
+      GimpLut *lut = gimp_lut_new ();
+      Curves   cruft;
 
-      /* The application should occur only within selection bounds */
-      if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
-        {
-          Curves       cruft;
-          PixelRegion  srcPR, destPR;
-          GimpLut     *lut;
+      gimp_curves_config_to_cruft (config, &cruft,
+                                   gimp_drawable_is_rgb (drawable));
 
-          lut = gimp_lut_new ();
+      gimp_lut_setup (lut,
+                      (GimpLutFunc) curves_lut_func,
+                      &cruft,
+                      gimp_drawable_bytes (drawable));
 
-          gimp_curves_config_to_cruft (config, &cruft,
-                                       gimp_drawable_is_rgb (drawable));
+      gimp_drawable_process (drawable, progress, _("Curves"),
+                             (PixelProcessorFunc) gimp_lut_process, lut);
 
-          gimp_lut_setup (lut,
-                          (GimpLutFunc) curves_lut_func,
-                          &cruft,
-                          gimp_drawable_bytes (drawable));
-
-          pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
-                             x, y, width, height, FALSE);
-          pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
-                             x, y, width, height, TRUE);
-
-          pixel_regions_process_parallel ((PixelProcessorFunc)
-                                          gimp_lut_process,
-                                          lut, 2, &srcPR, &destPR);
-
-          gimp_lut_free (lut);
-
-          gimp_drawable_merge_shadow_tiles (drawable, TRUE, _("Curves"));
-          gimp_drawable_free_shadow_tiles (drawable);
-
-          gimp_drawable_update (drawable, x, y, width, height);
-        }
+      gimp_lut_free (lut);
     }
 }

Modified: trunk/app/core/gimpdrawable-desaturate.c
==============================================================================
--- trunk/app/core/gimpdrawable-desaturate.c	(original)
+++ trunk/app/core/gimpdrawable-desaturate.c	Wed May 21 16:45:44 2008
@@ -20,13 +20,10 @@
 
 #include <gegl.h>
 
-#include "libgimpcolor/gimpcolor.h"
-
 #include "core-types.h"
 
 #include "base/desaturate.h"
 #include "base/pixel-processor.h"
-#include "base/pixel-region.h"
 
 #include "gegl/gimpdesaturateconfig.h"
 
@@ -37,17 +34,20 @@
 #include "gimpdrawable.h"
 #include "gimpdrawable-desaturate.h"
 #include "gimpdrawable-operation.h"
-#include "gimpdrawable-shadow.h"
+#include "gimpdrawable-process.h"
+#include "gimpprogress.h"
 
 #include "gimp-intl.h"
 
 
 void
 gimp_drawable_desaturate (GimpDrawable       *drawable,
+                          GimpProgress       *progress,
                           GimpDesaturateMode  mode)
 {
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_drawable_is_rgb (drawable));
+  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
 
   if (gimp_use_gegl (GIMP_ITEM (drawable)->image->gimp))
@@ -70,30 +70,13 @@
       g_object_unref (config);
 
       gimp_drawable_apply_operation (drawable, desaturate, TRUE,
-                                     NULL, _("Desaturate"));
+                                     progress, _("Desaturate"));
 
       g_object_unref  (desaturate);
     }
   else
     {
-      PixelRegion  srcPR, destPR;
-      gint         x, y, width, height;
-
-      if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
-        return;
-
-      pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
-                         x, y, width, height, FALSE);
-      pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
-                         x, y, width, height, TRUE);
-
-      pixel_regions_process_parallel ((PixelProcessorFunc) desaturate_region,
-                                      &mode,
-                                      2, &srcPR, &destPR);
-
-      gimp_drawable_merge_shadow_tiles (drawable, TRUE, _("Desaturate"));
-      gimp_drawable_free_shadow_tiles (drawable);
-
-      gimp_drawable_update (drawable, x, y, width, height);
+      gimp_drawable_process (drawable, progress, _("Desaturate"),
+                             (PixelProcessorFunc) desaturate_region, &mode);
     }
 }

Modified: trunk/app/core/gimpdrawable-desaturate.h
==============================================================================
--- trunk/app/core/gimpdrawable-desaturate.h	(original)
+++ trunk/app/core/gimpdrawable-desaturate.h	Wed May 21 16:45:44 2008
@@ -21,6 +21,7 @@
 
 
 void   gimp_drawable_desaturate (GimpDrawable       *drawable,
+                                 GimpProgress       *progress,
                                  GimpDesaturateMode  mode);
 
 

Modified: trunk/app/core/gimpdrawable-invert.c
==============================================================================
--- trunk/app/core/gimpdrawable-invert.c	(original)
+++ trunk/app/core/gimpdrawable-invert.c	Wed May 21 16:45:44 2008
@@ -25,7 +25,6 @@
 #include "base/gimplut.h"
 #include "base/lut-funcs.h"
 #include "base/pixel-processor.h"
-#include "base/pixel-region.h"
 
 /* temp */
 #include "gimp.h"
@@ -34,7 +33,7 @@
 #include "gimpdrawable.h"
 #include "gimpdrawable-invert.h"
 #include "gimpdrawable-operation.h"
-#include "gimpdrawable-shadow.h"
+#include "gimpdrawable-process.h"
 #include "gimpprogress.h"
 
 #include "gimp-intl.h"
@@ -52,9 +51,7 @@
     {
       GeglNode *invert;
 
-      invert = g_object_new (GEGL_TYPE_NODE,
-                             "operation", "invert",
-                             NULL);
+      invert = g_object_new (GEGL_TYPE_NODE, "operation", "invert", NULL);
 
       gimp_drawable_apply_operation (drawable, invert, TRUE,
                                      progress, _("Invert"));
@@ -63,28 +60,11 @@
     }
   else
     {
-      PixelRegion  srcPR, destPR;
-      gint         x, y, width, height;
-      GimpLut     *lut;
-
-      if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
-        return;
-
-      lut = invert_lut_new (gimp_drawable_bytes (drawable));
-
-      pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
-                         x, y, width, height, FALSE);
-      pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
-                         x, y, width, height, TRUE);
+      GimpLut *lut = invert_lut_new (gimp_drawable_bytes (drawable));
 
-      pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
-                                      lut, 2, &srcPR, &destPR);
+      gimp_drawable_process (drawable, progress, _("Invert"),
+                             (PixelProcessorFunc) gimp_lut_process, lut);
 
       gimp_lut_free (lut);
-
-      gimp_drawable_merge_shadow_tiles (drawable, TRUE, _("Invert"));
-      gimp_drawable_free_shadow_tiles (drawable);
-
-      gimp_drawable_update (drawable, x, y, width, height);
     }
 }

Added: trunk/app/core/gimpdrawable-process.c
==============================================================================
--- (empty file)
+++ trunk/app/core/gimpdrawable-process.c	Wed May 21 16:45:44 2008
@@ -0,0 +1,57 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+
+#include "core-types.h"
+
+#include "base/pixel-processor.h"
+#include "base/pixel-region.h"
+
+#include "gimpdrawable.h"
+#include "gimpdrawable-shadow.h"
+#include "gimpprogress.h"
+
+void
+gimp_drawable_process (GimpDrawable       *drawable,
+                       GimpProgress       *progress,
+                       const gchar        *undo_desc,
+                       PixelProcessorFunc  func,
+                       gpointer            data)
+{
+  PixelRegion  srcPR, destPR;
+  gint         x, y, width, height;
+
+  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
+  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+
+  pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
+                     x, y, width, height, FALSE);
+  pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
+                     x, y, width, height, TRUE);
+
+  pixel_regions_process_parallel (func, data, 2, &srcPR, &destPR);
+
+  gimp_drawable_merge_shadow_tiles (drawable, TRUE, undo_desc);
+  gimp_drawable_free_shadow_tiles (drawable);
+
+  gimp_drawable_update (drawable, x, y, width, height);
+}

Added: trunk/app/core/gimpdrawable-process.h
==============================================================================
--- (empty file)
+++ trunk/app/core/gimpdrawable-process.h	Wed May 21 16:45:44 2008
@@ -0,0 +1,30 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_DRAWABLE_PROCESS_H__
+#define __GIMP_DRAWABLE_PROCESS_H__
+
+
+void  gimp_drawable_process (GimpDrawable       *drawable,
+                             GimpProgress       *progress,
+                             const gchar        *undo_desc,
+                             PixelProcessorFunc  func,
+                             gpointer            data);
+
+
+#endif  /*  __GIMP_DRAWABLE_PROCESS_H__  */

Modified: trunk/app/pdb/color-cmds.c
==============================================================================
--- trunk/app/pdb/color-cmds.c	(original)
+++ trunk/app/pdb/color-cmds.c	Wed May 21 16:45:44 2008
@@ -225,7 +225,7 @@
         success = FALSE;
 
       if (success)
-        gimp_drawable_desaturate (drawable, GIMP_DESATURATE_LIGHTNESS);
+        gimp_drawable_desaturate (drawable, progress, GIMP_DESATURATE_LIGHTNESS);
     }
 
   return gimp_procedure_get_return_values (procedure, success);
@@ -253,7 +253,7 @@
         success = FALSE;
 
       if (success)
-        gimp_drawable_desaturate (drawable, desaturate_mode);
+        gimp_drawable_desaturate (drawable, progress, desaturate_mode);
     }
 
   return gimp_procedure_get_return_values (procedure, success);

Modified: trunk/tools/pdbgen/pdb/color.pdb
==============================================================================
--- trunk/tools/pdbgen/pdb/color.pdb	(original)
+++ trunk/tools/pdbgen/pdb/color.pdb	Wed May 21 16:45:44 2008
@@ -227,7 +227,7 @@
     success = FALSE;
 
   if (success)
-    gimp_drawable_desaturate (drawable, GIMP_DESATURATE_LIGHTNESS);
+    gimp_drawable_desaturate (drawable, progress, GIMP_DESATURATE_LIGHTNESS);
 }
 CODE
     );
@@ -264,7 +264,7 @@
     success = FALSE;
 
   if (success)
-    gimp_drawable_desaturate (drawable, desaturate_mode);
+    gimp_drawable_desaturate (drawable, progress, desaturate_mode);
 }
 CODE
     );



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