optionally use gegl where we already have operations (breaking the

2008-01-04  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/color.pdb: optionally use gegl where we already
	have operations (breaking the indentation to keep the diff small
	and readable).

	* app/pdb/Makefile.am: add GEGL_CFLAGS.

	* app/pdb/color_cmds.c: regenerated.


svn path=/trunk/; revision=24531
This commit is contained in:
Michael Natterer
2008-01-04 17:56:09 +00:00
committed by Michael Natterer
parent dd97e60591
commit 45b2a5e03a
4 changed files with 191 additions and 15 deletions

View File

@ -1,3 +1,13 @@
2008-01-04 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/color.pdb: optionally use gegl where we already
have operations (breaking the indentation to keep the diff small
and readable).
* app/pdb/Makefile.am: add GEGL_CFLAGS.
* app/pdb/color_cmds.c: regenerated.
2008-01-04 Michael Natterer <mitch@gimp.org>
* app/config/gimpcoreconfig.[ch]: add "use-gegl" property but

View File

@ -77,6 +77,7 @@ INCLUDES = \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(GDK_PIXBUF_CFLAGS) \
$(GEGL_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(includedir)

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <gegl.h>
#include <glib-object.h>
@ -34,11 +35,11 @@
#include "base/gimphistogram.h"
#include "base/gimplut.h"
#include "base/hue-saturation.h"
#include "base/levels.h"
#include "base/lut-funcs.h"
#include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "base/threshold.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpcurve.h"
#include "core/gimpdrawable-desaturate.h"
@ -46,6 +47,7 @@
#include "core/gimpdrawable-histogram.h"
#include "core/gimpdrawable-invert.h"
#include "core/gimpdrawable-levels.h"
#include "core/gimpdrawable-operation.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "gimp-intl.h"
@ -77,6 +79,26 @@ brightness_contrast_invoker (GimpProcedure *procedure,
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "brightness-contrast",
NULL);
gegl_node_set (node,
"brightness", brightness / 127.0,
"contrast", (contrast < 0 ?
(contrast + 127.0) / 127.0 :
contrast * 4.0 / 127.0 + 1),
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Brightness-Contrast"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -105,6 +127,7 @@ brightness_contrast_invoker (GimpProcedure *procedure,
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
return gimp_procedure_get_return_values (procedure, success);
@ -230,6 +253,23 @@ posterize_invoker (GimpProcedure *procedure,
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-posterize",
NULL);
gegl_node_set (node,
"levels", levels,
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Levels"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -256,6 +296,7 @@ posterize_invoker (GimpProcedure *procedure,
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
return gimp_procedure_get_return_values (procedure, success);
@ -633,6 +674,25 @@ colorize_invoker (GimpProcedure *procedure,
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-colorize",
NULL);
gegl_node_set (node,
"hue", hue,
"saturation", saturation,
"lightness", lightness,
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Colorize"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -662,6 +722,7 @@ colorize_invoker (GimpProcedure *procedure,
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
return gimp_procedure_get_return_values (procedure, success);
@ -827,6 +888,24 @@ threshold_invoker (GimpProcedure *procedure,
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-threshold",
NULL);
gegl_node_set (node,
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Threshold"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -852,6 +931,7 @@ threshold_invoker (GimpProcedure *procedure,
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
return gimp_procedure_get_return_values (procedure, success);

View File

@ -46,6 +46,26 @@ HELP
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "brightness-contrast",
NULL);
gegl_node_set (node,
"brightness", brightness / 127.0,
"contrast", (contrast < 0 ?
(contrast + 127.0) / 127.0 :
contrast * 4.0 / 127.0 + 1),
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Brightness-Contrast"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -74,6 +94,7 @@ HELP
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
CODE
);
@ -116,8 +137,7 @@ HELP
);
%invoke = (
headers => [ qw("base/levels.h"
"core/gimpdrawable-levels.h") ],
headers => [ qw("core/gimpdrawable-levels.h") ],
code => <<'CODE'
{
if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
@ -159,9 +179,7 @@ HELP
);
%invoke = (
headers => [ qw("base/levels.h"
"base/gimphistogram.h"
"core/gimpdrawable-histogram.h"
headers => [ qw("core/gimpdrawable-histogram.h"
"core/gimpdrawable-levels.h") ],
code => <<'CODE'
{
@ -185,9 +203,7 @@ sub levels_auto {
);
%invoke = (
headers => [ qw("base/levels.h"
"base/gimphistogram.h"
"core/gimpdrawable-histogram.h"
headers => [ qw("core/gimpdrawable-histogram.h"
"core/gimpdrawable-levels.h") ],
code => <<'CODE'
{
@ -228,6 +244,23 @@ HELP
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-posterize",
NULL);
gegl_node_set (node,
"levels", levels,
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Levels"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -254,6 +287,7 @@ HELP
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
CODE
);
@ -692,6 +726,25 @@ HELP
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-colorize",
NULL);
gegl_node_set (node,
"hue", hue,
"saturation", saturation,
"lightness", lightness,
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Colorize"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -721,6 +774,7 @@ HELP
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
CODE
);
@ -774,7 +828,7 @@ HELP
);
%invoke = (
headers => [ qw("core/gimp.h" "core/gimpdrawable-histogram.h") ],
headers => [ qw("core/gimpdrawable-histogram.h") ],
code => <<'CODE'
{
if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
@ -911,6 +965,24 @@ HELP
success = FALSE;
if (success)
{
if (gimp->config->use_gegl)
{
GeglNode *node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-threshold",
NULL);
gegl_node_set (node,
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
gimp_drawable_apply_operation (drawable, node, TRUE,
progress, _("Threshold"));
g_object_unref (node);
}
else
{
gint x, y, width, height;
@ -936,24 +1008,37 @@ HELP
gimp_drawable_update (drawable, x, y, width, height);
}
}
}
}
CODE
);
}
@headers = qw("base/gimphistogram.h"
@headers = qw(<gegl.h>
"base/gimphistogram.h"
"base/gimplut.h"
"base/lut-funcs.h"
"base/pixel-region.h"
"base/pixel-region.h"
"base/pixel-processor.h"
"config/gimpcoreconfig.h"
"core/gimp.h"
"core/gimpdrawable.h"
"core/gimpdrawable-operation.h"
"core/gimpimage.h"
"gimp-intl.h");
@procs = qw(brightness_contrast levels levels_auto levels_stretch posterize
desaturate desaturate_full equalize invert curves_spline
curves_explicit color_balance colorize histogram hue_saturation
@procs = qw(brightness_contrast
levels levels_auto levels_stretch
posterize
desaturate desaturate_full
equalize
invert
curves_spline curves_explicit
color_balance
colorize
histogram
hue_saturation
threshold);
%exports = (app => [@procs], lib => [@procs]);