diff --git a/ChangeLog b/ChangeLog index 0dc1f1421c..b27cf556f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-30 Øyvind Kolås + + * app/core/Makefile.am: added GEGL_CFLAGS. + * app/core/gimpdrawable-invert.c: added an alternate GEGL code path + that can be enabled by uncommenting ENABLE_GEGL in the file. + 2007-12-30 Manish Singh * plug-ins/pygimp/gimpmodule.c @@ -16,6 +22,14 @@ * plug-ins/pygimp/pygimp.h * plug-ins/pygimp/pygimp-tile.c: Basic wrapping of GimpPixelFetcher. +2007-12-30 Øyvind Kolås + + reviewed by: + + * app/core/Makefile.am: + * app/core/gimpdrawable-invert.c: (idle_fun), + (gimp_drawable_invert): + 2007-12-30 Øyvind Kolås * app/gegl/gimpoperationtilesink.c: specify that this operation does diff --git a/app/core/Makefile.am b/app/core/Makefile.am index f6be244824..ffda7956b6 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -13,6 +13,7 @@ INCLUDES = \ $(LIBART_CFLAGS) \ $(GEGL_CFLAGS) \ $(GLIB_CFLAGS) \ + $(GEGL_CFLAGS) \ -I$(includedir) noinst_LIBRARIES = libappcore.a diff --git a/app/core/gimpdrawable-invert.c b/app/core/gimpdrawable-invert.c index 4ec735ddbc..9cd69ff358 100644 --- a/app/core/gimpdrawable-invert.c +++ b/app/core/gimpdrawable-invert.c @@ -16,6 +16,115 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/*#define ENABLE_GEGL*/ +#ifdef ENABLE_GEGL + +#include "config.h" + +#include +#include + +#include "core-types.h" + +#include "gimpdrawable.h" +#include "gimpdrawable-invert.h" +#include "gimpimage.h" +#include "gimpprogress.h" +#include "gimp-intl.h" + +typedef struct Data { + GeglNode *gegl; + GeglNode *output; + GeglProcessor *processor; + GeglRectangle rect; + GimpDrawable *drawable; + GimpProgress *progress; +} Data; + +static gboolean +idle_fun (gpointer fdata) +{ + Data *data = fdata; + gboolean more_work; + gdouble progress; + + more_work = gegl_processor_work (data->processor, &progress); + if (more_work) + { + gimp_progress_set_text (data->progress, _("Invert")); + gimp_progress_set_value (data->progress, progress); + return TRUE; + } + + g_object_unref (data->processor); + gimp_drawable_update (data->drawable, data->rect.x, data->rect.y, + data->rect.width, data->rect.height); + gimp_drawable_merge_shadow (data->drawable, TRUE, _("Invert")); + { + GimpImage *image = gimp_item_get_image (GIMP_ITEM (data->drawable)); + if (image) + { + /* FIXME: gimp image flush has already been called by the action, + * it needs to still do so as long as only the ifdef is used to + * toggle between the versions + */ + gimp_image_flush (image); + } + } + + gimp_progress_end (data->progress); + g_object_unref (data->gegl); + g_free (data); + return FALSE; +} + +void +gimp_drawable_invert (GimpDrawable *drawable, + GimpProgress *progress) +{ + GeglNode *input; + GeglNode *invert; + + Data *data; + + g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); + g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); + + data = g_malloc0 (sizeof (Data)); + data->drawable = drawable; + + if (! gimp_drawable_mask_intersect (drawable, + &data->rect.x, &data->rect.y, + &data->rect.width, &data->rect.height)) + return; + + data->gegl = gegl_node_new (); + data->progress = progress; + input = gegl_node_new_child (data->gegl, + "operation", "gimp-tilemanager-source", + "tile-manager", gimp_drawable_get_tiles (drawable), + NULL); + data->output = gegl_node_new_child (data->gegl, + "operation", "gimp-tilemanager-sink", + "tile-manager", gimp_drawable_get_shadow_tiles (drawable), + NULL); + invert = gegl_node_new_child (data->gegl, + "operation", "invert", + NULL); + + gegl_node_link_many (input, invert, data->output, NULL); + + data->processor = gegl_node_new_processor (data->output, &data->rect); + + gimp_progress_start (data->progress, _("Invert"), FALSE); + + /* do the actual processing in an idle callback */ + g_idle_add (idle_fun, data); +} + + +#else /* ENABLE_GEGL is not defined */ + #include "config.h" #include @@ -65,3 +174,5 @@ gimp_drawable_invert (GimpDrawable *drawable, gimp_drawable_update (drawable, x, y, width, height); } + +#endif