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:

committed by
Sven Neumann

parent
97edc3567f
commit
a786d4deab
18
ChangeLog
18
ChangeLog
@ -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>
|
||||
|
||||
* app/tools/gimpfreeselecttool.c
|
||||
@ -12,7 +28,7 @@
|
||||
2008-05-21 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* 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.
|
||||
|
||||
|
@ -145,6 +145,8 @@ libappcore_a_sources = \
|
||||
gimpdrawable-posterize.h \
|
||||
gimpdrawable-preview.c \
|
||||
gimpdrawable-preview.h \
|
||||
gimpdrawable-process.c \
|
||||
gimpdrawable-process.h \
|
||||
gimpdrawable-shadow.c \
|
||||
gimpdrawable-shadow.h \
|
||||
gimpdrawable-stroke.c \
|
||||
|
@ -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,16 +170,8 @@ gimp_drawable_curves (GimpDrawable *drawable,
|
||||
}
|
||||
else
|
||||
{
|
||||
gint x, y, width, height;
|
||||
|
||||
/* The application should occur only within selection bounds */
|
||||
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
||||
{
|
||||
GimpLut *lut = gimp_lut_new ();
|
||||
Curves cruft;
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpLut *lut;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
gimp_curves_config_to_cruft (config, &cruft,
|
||||
gimp_drawable_is_rgb (drawable));
|
||||
@ -190,21 +181,9 @@ gimp_drawable_curves (GimpDrawable *drawable,
|
||||
&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_drawable_process (drawable, progress, _("Curves"),
|
||||
(PixelProcessorFunc) gimp_lut_process, lut);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ gimp_drawable_desaturate (GimpDrawable *drawable,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
void gimp_drawable_desaturate (GimpDrawable *drawable,
|
||||
GimpProgress *progress,
|
||||
GimpDesaturateMode mode);
|
||||
|
||||
|
||||
|
@ -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 @@ gimp_drawable_invert (GimpDrawable *drawable,
|
||||
{
|
||||
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 @@ gimp_drawable_invert (GimpDrawable *drawable,
|
||||
}
|
||||
else
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
gint x, y, width, height;
|
||||
GimpLut *lut;
|
||||
GimpLut *lut = invert_lut_new (gimp_drawable_bytes (drawable));
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
57
app/core/gimpdrawable-process.c
Normal file
57
app/core/gimpdrawable-process.c
Normal 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);
|
||||
}
|
30
app/core/gimpdrawable-process.h
Normal file
30
app/core/gimpdrawable-process.h
Normal 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__ */
|
@ -225,7 +225,7 @@ desaturate_invoker (GimpProcedure *procedure,
|
||||
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 @@ desaturate_full_invoker (GimpProcedure *procedure,
|
||||
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);
|
||||
|
@ -227,7 +227,7 @@ HELP
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_drawable_desaturate (drawable, GIMP_DESATURATE_LIGHTNESS);
|
||||
gimp_drawable_desaturate (drawable, progress, GIMP_DESATURATE_LIGHTNESS);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
@ -264,7 +264,7 @@ HELP
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_drawable_desaturate (drawable, desaturate_mode);
|
||||
gimp_drawable_desaturate (drawable, progress, desaturate_mode);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
Reference in New Issue
Block a user