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



Author: mitch
Date: Sun Apr 20 13:38:13 2008
New Revision: 25501
URL: http://svn.gnome.org/viewvc/gimp?rev=25501&view=rev

Log:
2008-04-20  Michael Natterer  <mitch gimp org>

	* app/core/gimpdrawable-levels.[ch]: replaced unused parameter
	"context" by "progress" and pass the progress on internally.
	Factor common code out to gimp_drawable_levels_internal().

	* tools/pdbgen/pdb/color.pdb: pass progress instead of context.

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



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpdrawable-levels.c
   trunk/app/core/gimpdrawable-levels.h
   trunk/app/pdb/color-cmds.c
   trunk/tools/pdbgen/pdb/color.pdb

Modified: trunk/app/core/gimpdrawable-levels.c
==============================================================================
--- trunk/app/core/gimpdrawable-levels.c	(original)
+++ trunk/app/core/gimpdrawable-levels.c	Sun Apr 20 13:38:13 2008
@@ -34,7 +34,6 @@
 #include "gimp.h"
 #include "gimpimage.h"
 
-#include "gimpcontext.h"
 #include "gimpdrawable.h"
 #include "gimpdrawable-histogram.h"
 #include "gimpdrawable-levels.h"
@@ -42,15 +41,25 @@
 
 #include "gimp-intl.h"
 
+
+/*  local function prototypes  */
+
+static void   gimp_drawable_levels_internal (GimpDrawable     *drawable,
+                                             GimpProgress     *progress,
+                                             GimpLevelsConfig *config);
+
+
+/*  public functions  */
+
 void
-gimp_drawable_levels (GimpDrawable   *drawable,
-                      GimpContext    *context,
-                      gint32          channel,
-                      gint32          low_input,
-                      gint32          high_input,
-                      gdouble         gamma,
-                      gint32          low_output,
-                      gint32          high_output)
+gimp_drawable_levels (GimpDrawable *drawable,
+                      GimpProgress *progress,
+                      gint32        channel,
+                      gint32        low_input,
+                      gint32        high_input,
+                      gdouble       gamma,
+                      gint32        low_output,
+                      gint32        high_output)
 {
   GimpLevelsConfig *config;
 
@@ -86,76 +95,23 @@
                 "high-output", high_output / 255.0,
                 NULL);
 
-  if (gimp_use_gegl (GIMP_ITEM (drawable)->image->gimp))
-    {
-      GeglNode *levels;
-
-      levels = g_object_new (GEGL_TYPE_NODE,
-                             "operation", "gimp-levels",
-                             NULL);
-
-      gegl_node_set (levels,
-                     "config", config,
-                     NULL);
-
-      gimp_drawable_apply_operation (drawable, levels, TRUE,
-                                     NULL, _("Levels"));
-
-      g_object_unref (levels);
-    }
-  else
-    {
-      PixelRegion  srcPR, destPR;
-      Levels       levels;
-      GimpLut     *lut;
-      gint         x, y;
-      gint         width, height;
-
-      if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
-        return;
-
-      gimp_levels_config_to_cruft (config, &levels,
-                                   gimp_drawable_is_rgb (drawable));
-
-      lut = gimp_lut_new ();
-      gimp_lut_setup (lut,
-                      (GimpLutFunc) levels_lut_func,
-                      &levels,
-                      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 (drawable, TRUE, _("Levels"));
-
-      gimp_drawable_update (drawable, x, y, width, height);
-    }
+  gimp_drawable_levels_internal (drawable, progress, config);
 
   g_object_unref (config);
 }
 
 void
 gimp_drawable_levels_stretch (GimpDrawable *drawable,
-                              GimpContext  *context)
+                              GimpProgress *progress)
 {
   GimpLevelsConfig *config;
   GimpHistogram    *histogram;
-  gint              x, y;
-  gint              width, height;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (! gimp_drawable_is_indexed (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
-  g_return_if_fail (GIMP_IS_CONTEXT  (context));
 
-  if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
+  if (! gimp_drawable_mask_intersect (drawable, NULL, NULL, NULL, NULL))
     return;
 
   config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
@@ -168,6 +124,19 @@
 
   gimp_histogram_unref (histogram);
 
+  gimp_drawable_levels_internal (drawable, progress, config);
+
+  g_object_unref (config);
+}
+
+
+/*  private functions  */
+
+static void
+gimp_drawable_levels_internal (GimpDrawable     *drawable,
+                               GimpProgress     *progress,
+                               GimpLevelsConfig *config)
+{
   if (gimp_use_gegl (GIMP_ITEM (drawable)->image->gimp))
     {
       GeglNode *levels;
@@ -181,7 +150,7 @@
                      NULL);
 
       gimp_drawable_apply_operation (drawable, levels, TRUE,
-                                     NULL, _("Levels"));
+                                     progress, _("Levels"));
 
       g_object_unref (levels);
     }
@@ -190,11 +159,16 @@
       PixelRegion  srcPR, destPR;
       Levels       levels;
       GimpLut     *lut;
+      gint         x, y;
+      gint         width, height;
+
+      if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
+        return;
 
       gimp_levels_config_to_cruft (config, &levels,
                                    gimp_drawable_is_rgb (drawable));
 
-      lut  = gimp_lut_new ();
+      lut = gimp_lut_new ();
       gimp_lut_setup (lut,
                       (GimpLutFunc) levels_lut_func,
                       &levels,
@@ -214,6 +188,4 @@
 
       gimp_drawable_update (drawable, x, y, width, height);
     }
-
-  g_object_unref (config);
 }

Modified: trunk/app/core/gimpdrawable-levels.h
==============================================================================
--- trunk/app/core/gimpdrawable-levels.h	(original)
+++ trunk/app/core/gimpdrawable-levels.h	Sun Apr 20 13:38:13 2008
@@ -21,7 +21,7 @@
 
 
 void   gimp_drawable_levels         (GimpDrawable *drawable,
-                                     GimpContext  *context,
+                                     GimpProgress *progress,
                                      gint32        channel,
                                      gint32        low_input,
                                      gint32        high_input,
@@ -30,7 +30,7 @@
                                      gint32        high_output);
 
 void   gimp_drawable_levels_stretch (GimpDrawable *drawable,
-                                     GimpContext  *context);
+                                     GimpProgress *progress);
 
 
 #endif  /*  __GIMP_DRAWABLE_LEVELS_H__  */

Modified: trunk/app/pdb/color-cmds.c
==============================================================================
--- trunk/app/pdb/color-cmds.c	(original)
+++ trunk/app/pdb/color-cmds.c	Sun Apr 20 13:38:13 2008
@@ -115,7 +115,7 @@
         success = FALSE;
 
       if (success)
-        gimp_drawable_levels (drawable, context,
+        gimp_drawable_levels (drawable, progress,
                               channel,
                               low_input, high_input,
                               gamma,
@@ -145,7 +145,7 @@
         success = FALSE;
 
       if (success)
-        gimp_drawable_levels_stretch (drawable, context);
+        gimp_drawable_levels_stretch (drawable, progress);
     }
 
   return gimp_procedure_get_return_values (procedure, success);
@@ -171,7 +171,7 @@
         success = FALSE;
 
       if (success)
-        gimp_drawable_levels_stretch (drawable, context);
+        gimp_drawable_levels_stretch (drawable, progress);
     }
 
   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	Sun Apr 20 13:38:13 2008
@@ -103,7 +103,7 @@
     success = FALSE;
 
   if (success)
-    gimp_drawable_levels (drawable, context,
+    gimp_drawable_levels (drawable, progress,
                           channel,
                           low_input, high_input,
                           gamma,
@@ -141,7 +141,7 @@
     success = FALSE;
 
   if (success)
-    gimp_drawable_levels_stretch (drawable, context);
+    gimp_drawable_levels_stretch (drawable, progress);
 }
 CODE
     );
@@ -164,7 +164,7 @@
     success = FALSE;
 
   if (success)
-    gimp_drawable_levels_stretch (drawable, context);
+    gimp_drawable_levels_stretch (drawable, progress);
 }
 CODE
     );



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