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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
@ -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__ */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user