[gimp] app: add an "area" parameter to gimp_image_map_apply()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add an "area" parameter to gimp_image_map_apply()
- Date: Fri, 17 May 2013 23:47:13 +0000 (UTC)
commit ef917b2c5c0be46ff3dd7e3579f2a02a2aeba2d4
Author: Michael Natterer <mitch gimp org>
Date: Sat May 18 01:45:01 2013 +0200
app: add an "area" parameter to gimp_image_map_apply()
and only update the drawable in that area if it's not NULL. Useful for
expensive interactive operations like warp, where the tool exactly
knows which area has changed.
app/core/gimpimagemap.c | 55 ++++++++++++++++++++++++++++---------
app/core/gimpimagemap.h | 17 ++++++-----
app/tools/gimpcagetool.c | 2 +-
app/tools/gimpimagemaptool.c | 2 +-
app/tools/gimpseamlessclonetool.c | 2 +-
5 files changed, 54 insertions(+), 24 deletions(-)
---
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index 6c164c9..9d44974 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -35,6 +35,8 @@
#include <gegl.h>
+#include "libgimpbase/gimpbase.h"
+
#include "core-types.h"
#include "gegl/gimpapplicator.h"
@@ -72,12 +74,13 @@ struct _GimpImageMap
};
-static void gimp_image_map_dispose (GObject *object);
-static void gimp_image_map_finalize (GObject *object);
+static void gimp_image_map_dispose (GObject *object);
+static void gimp_image_map_finalize (GObject *object);
-static gboolean gimp_image_map_add_filter (GimpImageMap *image_map);
-static gboolean gimp_image_map_remove_filter (GimpImageMap *image_map);
-static void gimp_image_map_update_drawable (GimpImageMap *image_map);
+static gboolean gimp_image_map_add_filter (GimpImageMap *image_map);
+static gboolean gimp_image_map_remove_filter (GimpImageMap *image_map);
+static void gimp_image_map_update_drawable (GimpImageMap *image_map,
+ const GeglRectangle *area);
@@ -192,10 +195,12 @@ gimp_image_map_new (GimpDrawable *drawable,
}
void
-gimp_image_map_apply (GimpImageMap *image_map)
+gimp_image_map_apply (GimpImageMap *image_map,
+ const GeglRectangle *area)
{
GimpImage *image;
GimpChannel *mask;
+ GeglRectangle update_area;
GimpComponentMask active_mask;
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
@@ -218,6 +223,29 @@ gimp_image_map_apply (GimpImageMap *image_map)
return;
}
+ /* Only update "area" because only that has changed */
+ if (area &&
+ ! gimp_rectangle_intersect (area->x,
+ area->y,
+ area->width,
+ area->height,
+ image_map->filter_area.x,
+ image_map->filter_area.y,
+ image_map->filter_area.width,
+ image_map->filter_area.height,
+ &update_area.x,
+ &update_area.y,
+ &update_area.width,
+ &update_area.height))
+ {
+ /* Bail out, but don't remove the filter */
+ return;
+ }
+ else
+ {
+ update_area = image_map->filter_area;
+ }
+
if (! image_map->filter)
{
GeglNode *filter_node;
@@ -339,7 +367,7 @@ gimp_image_map_apply (GimpImageMap *image_map)
}
gimp_image_map_add_filter (image_map);
- gimp_image_map_update_drawable (image_map);
+ gimp_image_map_update_drawable (image_map, &update_area);
}
void
@@ -366,7 +394,7 @@ gimp_image_map_abort (GimpImageMap *image_map)
if (gimp_image_map_remove_filter (image_map))
{
- gimp_image_map_update_drawable (image_map);
+ gimp_image_map_update_drawable (image_map, &image_map->filter_area);
}
}
@@ -409,13 +437,14 @@ gimp_image_map_remove_filter (GimpImageMap *image_map)
}
static void
-gimp_image_map_update_drawable (GimpImageMap *image_map)
+gimp_image_map_update_drawable (GimpImageMap *image_map,
+ const GeglRectangle *area)
{
gimp_drawable_update (image_map->drawable,
- image_map->filter_area.x,
- image_map->filter_area.y,
- image_map->filter_area.width,
- image_map->filter_area.height);
+ area->x,
+ area->y,
+ area->width,
+ area->height);
g_signal_emit (image_map, image_map_signals[FLUSH], 0);
}
diff --git a/app/core/gimpimagemap.h b/app/core/gimpimagemap.h
index f0c61df..fe5901a 100644
--- a/app/core/gimpimagemap.h
+++ b/app/core/gimpimagemap.h
@@ -49,16 +49,17 @@ struct _GimpImageMapClass
GType gimp_image_map_get_type (void) G_GNUC_CONST;
-GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
- const gchar *undo_desc,
- GeglNode *operation,
- const gchar *stock_id);
+GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
+ const gchar *undo_desc,
+ GeglNode *operation,
+ const gchar *stock_id);
-void gimp_image_map_apply (GimpImageMap *image_map);
+void gimp_image_map_apply (GimpImageMap *image_map,
+ const GeglRectangle *area);
-void gimp_image_map_commit (GimpImageMap *image_map,
- GimpProgress *progress);
-void gimp_image_map_abort (GimpImageMap *image_map);
+void gimp_image_map_commit (GimpImageMap *image_map,
+ GimpProgress *progress);
+void gimp_image_map_abort (GimpImageMap *image_map);
#endif /* __GIMP_IMAGE_MAP_H__ */
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 4e80f64..9c7f2aa 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -1260,5 +1260,5 @@ gimp_cage_tool_image_map_flush (GimpImageMap *image_map,
static void
gimp_cage_tool_image_map_update (GimpCageTool *ct)
{
- gimp_image_map_apply (ct->image_map);
+ gimp_image_map_apply (ct->image_map, NULL);
}
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index 3f41d68..7d5a55a 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -592,7 +592,7 @@ gimp_image_map_tool_map (GimpImageMapTool *tool)
if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map)
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool);
- gimp_image_map_apply (tool->image_map);
+ gimp_image_map_apply (tool->image_map, NULL);
}
static void
diff --git a/app/tools/gimpseamlessclonetool.c b/app/tools/gimpseamlessclonetool.c
index ed73cb1..f7d3890 100644
--- a/app/tools/gimpseamlessclonetool.c
+++ b/app/tools/gimpseamlessclonetool.c
@@ -776,5 +776,5 @@ gimp_seamless_clone_tool_image_map_update (GimpSeamlessCloneTool *sc)
g_object_unref (op);
/* Now update the image map and show this area */
- gimp_image_map_apply (sc->image_map);
+ gimp_image_map_apply (sc->image_map, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]