app/core/Makefile.am new file holding code to apply a PixelProcessor to

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.


svn path=/trunk/; revision=25734
This commit is contained in:
Sven Neumann
2008-05-21 16:45:44 +00:00
committed by Sven Neumann
parent 97edc3567f
commit a786d4deab
10 changed files with 135 additions and 87 deletions

View File

@ -1,3 +1,19 @@
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.
2008-05-21 Martin Nordholts <martinn@svn.gnome.org> 2008-05-21 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimpfreeselecttool.c * app/tools/gimpfreeselecttool.c
@ -12,7 +28,7 @@
2008-05-21 Sven Neumann <sven@gimp.org> 2008-05-21 Sven Neumann <sven@gimp.org>
* app/base/desaturate.[ch]: changed to take a pointer as first * app/base/desaturate.[ch]: changed to take a pointer as first
argument as all PixelProcessor functions. argument like all PixelProcessor functions.
* app/core/gimpdrawable-desaturate.c: changed accordingly. * app/core/gimpdrawable-desaturate.c: changed accordingly.

View File

@ -145,6 +145,8 @@ libappcore_a_sources = \
gimpdrawable-posterize.h \ gimpdrawable-posterize.h \
gimpdrawable-preview.c \ gimpdrawable-preview.c \
gimpdrawable-preview.h \ gimpdrawable-preview.h \
gimpdrawable-process.c \
gimpdrawable-process.h \
gimpdrawable-shadow.c \ gimpdrawable-shadow.c \
gimpdrawable-shadow.h \ gimpdrawable-shadow.h \
gimpdrawable-stroke.c \ gimpdrawable-stroke.c \

View File

@ -25,7 +25,6 @@
#include "base/curves.h" #include "base/curves.h"
#include "base/gimplut.h" #include "base/gimplut.h"
#include "base/pixel-processor.h" #include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "gegl/gimpcurvesconfig.h" #include "gegl/gimpcurvesconfig.h"
@ -37,7 +36,7 @@
#include "gimpdrawable.h" #include "gimpdrawable.h"
#include "gimpdrawable-curves.h" #include "gimpdrawable-curves.h"
#include "gimpdrawable-operation.h" #include "gimpdrawable-operation.h"
#include "gimpdrawable-shadow.h" #include "gimpdrawable-process.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -171,40 +170,20 @@ gimp_drawable_curves (GimpDrawable *drawable,
} }
else else
{ {
gint x, y, width, height; GimpLut *lut = gimp_lut_new ();
Curves cruft;
/* The application should occur only within selection bounds */ gimp_curves_config_to_cruft (config, &cruft,
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_is_rgb (drawable));
{
Curves cruft;
PixelRegion srcPR, destPR;
GimpLut *lut;
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_process (drawable, progress, _("Curves"),
gimp_drawable_is_rgb (drawable)); (PixelProcessorFunc) gimp_lut_process, lut);
gimp_lut_setup (lut, gimp_lut_free (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);
}
} }
} }

View File

@ -20,13 +20,10 @@
#include <gegl.h> #include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
#include "core-types.h" #include "core-types.h"
#include "base/desaturate.h" #include "base/desaturate.h"
#include "base/pixel-processor.h" #include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "gegl/gimpdesaturateconfig.h" #include "gegl/gimpdesaturateconfig.h"
@ -37,17 +34,20 @@
#include "gimpdrawable.h" #include "gimpdrawable.h"
#include "gimpdrawable-desaturate.h" #include "gimpdrawable-desaturate.h"
#include "gimpdrawable-operation.h" #include "gimpdrawable-operation.h"
#include "gimpdrawable-shadow.h" #include "gimpdrawable-process.h"
#include "gimpprogress.h"
#include "gimp-intl.h" #include "gimp-intl.h"
void void
gimp_drawable_desaturate (GimpDrawable *drawable, gimp_drawable_desaturate (GimpDrawable *drawable,
GimpProgress *progress,
GimpDesaturateMode mode) GimpDesaturateMode mode)
{ {
g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_drawable_is_rgb (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))); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
if (gimp_use_gegl (GIMP_ITEM (drawable)->image->gimp)) if (gimp_use_gegl (GIMP_ITEM (drawable)->image->gimp))
@ -70,30 +70,13 @@ gimp_drawable_desaturate (GimpDrawable *drawable,
g_object_unref (config); g_object_unref (config);
gimp_drawable_apply_operation (drawable, desaturate, TRUE, gimp_drawable_apply_operation (drawable, desaturate, TRUE,
NULL, _("Desaturate")); progress, _("Desaturate"));
g_object_unref (desaturate); g_object_unref (desaturate);
} }
else else
{ {
PixelRegion srcPR, destPR; gimp_drawable_process (drawable, progress, _("Desaturate"),
gint x, y, width, height; (PixelProcessorFunc) desaturate_region, &mode);
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);
} }
} }

View File

@ -21,6 +21,7 @@
void gimp_drawable_desaturate (GimpDrawable *drawable, void gimp_drawable_desaturate (GimpDrawable *drawable,
GimpProgress *progress,
GimpDesaturateMode mode); GimpDesaturateMode mode);

View File

@ -25,7 +25,6 @@
#include "base/gimplut.h" #include "base/gimplut.h"
#include "base/lut-funcs.h" #include "base/lut-funcs.h"
#include "base/pixel-processor.h" #include "base/pixel-processor.h"
#include "base/pixel-region.h"
/* temp */ /* temp */
#include "gimp.h" #include "gimp.h"
@ -34,7 +33,7 @@
#include "gimpdrawable.h" #include "gimpdrawable.h"
#include "gimpdrawable-invert.h" #include "gimpdrawable-invert.h"
#include "gimpdrawable-operation.h" #include "gimpdrawable-operation.h"
#include "gimpdrawable-shadow.h" #include "gimpdrawable-process.h"
#include "gimpprogress.h" #include "gimpprogress.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -52,9 +51,7 @@ gimp_drawable_invert (GimpDrawable *drawable,
{ {
GeglNode *invert; GeglNode *invert;
invert = g_object_new (GEGL_TYPE_NODE, invert = g_object_new (GEGL_TYPE_NODE, "operation", "invert", NULL);
"operation", "invert",
NULL);
gimp_drawable_apply_operation (drawable, invert, TRUE, gimp_drawable_apply_operation (drawable, invert, TRUE,
progress, _("Invert")); progress, _("Invert"));
@ -63,28 +60,11 @@ gimp_drawable_invert (GimpDrawable *drawable,
} }
else else
{ {
PixelRegion srcPR, destPR; GimpLut *lut = invert_lut_new (gimp_drawable_bytes (drawable));
gint x, y, width, height;
GimpLut *lut;
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) gimp_drawable_process (drawable, progress, _("Invert"),
return; (PixelProcessorFunc) gimp_lut_process, lut);
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);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (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);
} }
} }

View File

@ -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);
}

View File

@ -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__ */

View File

@ -225,7 +225,7 @@ desaturate_invoker (GimpProcedure *procedure,
success = FALSE; success = FALSE;
if (success) 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); return gimp_procedure_get_return_values (procedure, success);
@ -253,7 +253,7 @@ desaturate_full_invoker (GimpProcedure *procedure,
success = FALSE; success = FALSE;
if (success) if (success)
gimp_drawable_desaturate (drawable, desaturate_mode); gimp_drawable_desaturate (drawable, progress, desaturate_mode);
} }
return gimp_procedure_get_return_values (procedure, success); return gimp_procedure_get_return_values (procedure, success);

View File

@ -227,7 +227,7 @@ HELP
success = FALSE; success = FALSE;
if (success) if (success)
gimp_drawable_desaturate (drawable, GIMP_DESATURATE_LIGHTNESS); gimp_drawable_desaturate (drawable, progress, GIMP_DESATURATE_LIGHTNESS);
} }
CODE CODE
); );
@ -264,7 +264,7 @@ HELP
success = FALSE; success = FALSE;
if (success) if (success)
gimp_drawable_desaturate (drawable, desaturate_mode); gimp_drawable_desaturate (drawable, progress, desaturate_mode);
} }
CODE CODE
); );