Commit 33bba657 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Make sure the selection (gimpimage-mask.c) functionality is really built

2002-08-20  Michael Natterer  <mitch@gimp.org>

	Make sure the selection (gimpimage-mask.c) functionality is really
	built *on top* of the GimpChannel functionality:

	* app/undo.[ch]: renamed undo_push_image_mask() to
	undo_push_mask() and generalized it's API to take a GimpChannel
	param so undos can be pushed for channels which are not the
	image's selection. Simplified the API and added code which copies
	the region of interest instead of leaving this to callers.

	* app/undo_types.h: s/IMAGE_MASK_UNDO/MASK_UNDO/

	* app/undo_history.c: changed accordingly.

	* app/core/gimpchannel.[ch]: don't #include "gimpimage-mask.h".
	Changed gimp_channel_push_undo() to really push a channel undo,
	not a selection undo. Added "gboolean push_undo" params to all
	functions which are called from gimpimage-mask.c. Various cleanups
	and optimizations. Added /*< proxy-foo >*/ stuff to the header so
	we export just the struct itself to libgimpproxy. Added accessors
	gimp_channel_[get|set]_show_masked().

	* app/core/gimpimage-mask.[ch]: renamed gimp_image_mask_undo() to
	gimp_image_mask_push_undo(). Call it before calling GimpChannel
	functions which modify the mask, also call all GimpChannel
	functions with push_undo = FALSE. Emit gimp_image_mask_changed()
	after each operation instead of calling it in
	gimp_image_mask_invalidate(). Removed gimp_image_mask_none()
	because it is the same as gimp_image_mask_clear().
	General cleanup.

	* app/core/gimpimage-mask-select.c
	* app/core/gimpimage-qmask.c: changed accordingly.

	* app/core/gimpedit.c: call gimp_image_mask_clear(), not
	gimp_channel_clear (gimp_image_get_mask()).

	* app/core/gimpimage-crop.c
	* app/core/gimpimage-resize.c
	* app/core/gimpimage-scale.c: call gimp_image_mask_changed()

	* app/gui/channels-commands.c
	* app/gui/select-commands.c
	* app/tools/gimptexttool.c
	* tools/pdbgen/pdb/channel.pdb
	* tools/pdbgen/pdb/selection.pdb: follow GimpChannel and
	gimp_image_mask* API changes.

	* app/pdb/channel_cmds.c
	* app/pdb/selection_cmds.c
	* libgimpproxy/gimpchannel.h: regenerated.

	Unrelated:

	* app/core/gimpimage.c: call gimp_drawable_push_undo() instead of
	undo_push_image() directly.
parent 68820735
2002-08-20 Michael Natterer <mitch@gimp.org>
Make sure the selection (gimpimage-mask.c) functionality is really
built *on top* of the GimpChannel functionality:
* app/undo.[ch]: renamed undo_push_image_mask() to
undo_push_mask() and generalized it's API to take a GimpChannel
param so undos can be pushed for channels which are not the
image's selection. Simplified the API and added code which copies
the region of interest instead of leaving this to callers.
* app/undo_types.h: s/IMAGE_MASK_UNDO/MASK_UNDO/
* app/undo_history.c: changed accordingly.
* app/core/gimpchannel.[ch]: don't #include "gimpimage-mask.h".
Changed gimp_channel_push_undo() to really push a channel undo,
not a selection undo. Added "gboolean push_undo" params to all
functions which are called from gimpimage-mask.c. Various cleanups
and optimizations. Added /*< proxy-foo >*/ stuff to the header so
we export just the struct itself to libgimpproxy. Added accessors
gimp_channel_[get|set]_show_masked().
* app/core/gimpimage-mask.[ch]: renamed gimp_image_mask_undo() to
gimp_image_mask_push_undo(). Call it before calling GimpChannel
functions which modify the mask, also call all GimpChannel
functions with push_undo = FALSE. Emit gimp_image_mask_changed()
after each operation instead of calling it in
gimp_image_mask_invalidate(). Removed gimp_image_mask_none()
because it is the same as gimp_image_mask_clear().
General cleanup.
* app/core/gimpimage-mask-select.c
* app/core/gimpimage-qmask.c: changed accordingly.
* app/core/gimpedit.c: call gimp_image_mask_clear(), not
gimp_channel_clear (gimp_image_get_mask()).
* app/core/gimpimage-crop.c
* app/core/gimpimage-resize.c
* app/core/gimpimage-scale.c: call gimp_image_mask_changed()
* app/gui/channels-commands.c
* app/gui/select-commands.c
* app/tools/gimptexttool.c
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/selection.pdb: follow GimpChannel and
gimp_image_mask* API changes.
* app/pdb/channel_cmds.c
* app/pdb/selection_cmds.c
* libgimpproxy/gimpchannel.h: regenerated.
Unrelated:
* app/core/gimpimage.c: call gimp_drawable_push_undo() instead of
undo_push_image() directly.
2002-08-18 Manish Singh <yosh@gimp.org>
* autogen.sh: remove bashism (function keyword)
......
......@@ -274,7 +274,7 @@ channels_new_channel_query (GimpImage *gimage,
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
gimp_get_user_context (gimage->gimp),
GIMP_TRANSPARENT_FILL);
gimp_channel_translate (new_channel, off_x, off_y);
gimp_channel_translate (new_channel, off_x, off_y, FALSE);
gimp_image_add_channel (gimage, new_channel, -1);
undo_push_group_end (gimage);
......
......@@ -105,7 +105,7 @@ select_none_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage, data);
gimp_image_mask_none (gimage);
gimp_image_mask_clear (gimage);
gimp_image_flush (gimage);
}
......
......@@ -212,7 +212,7 @@ gimp_edit_paste (GimpImage *gimage,
* it seems like the correct behavior.
*/
if (! gimp_image_mask_is_empty (gimage) && ! paste_into)
gimp_channel_clear (gimp_image_get_mask (gimage));
gimp_image_mask_clear (gimage);
/* if there's a drawable, add a new floating selection */
if (drawable != NULL)
......
......@@ -33,14 +33,12 @@
#include "base/lut-funcs.h"
#include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "base/temp-buf.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpchannel.h"
#include "gimplayer.h"
#include "gimpparasitelist.h"
......@@ -57,6 +55,10 @@ static void gimp_channel_finalize (GObject *object);
static gsize gimp_channel_get_memsize (GimpObject *object);
static void gimp_channel_push_undo (GimpChannel *mask);
static void gimp_channel_validate (TileManager *tm,
Tile *tile);
static GimpDrawableClass * parent_class = NULL;
......@@ -164,6 +166,21 @@ gimp_channel_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_channel_push_undo (GimpChannel *mask)
{
GimpImage *gimage;
gimage = gimp_item_get_image (GIMP_ITEM (mask));
undo_push_mask (gimage, mask);
mask->boundary_known = FALSE;
/* invalidate the preview */
GIMP_DRAWABLE (mask)->preview_valid = FALSE;
}
static void
gimp_channel_validate (TileManager *tm,
Tile *tile)
......@@ -173,6 +190,9 @@ gimp_channel_validate (TileManager *tm,
TRANSPARENT_OPACITY, tile_size (tile));
}
/* public functions */
GimpChannel *
gimp_channel_new (GimpImage *gimage,
gint width,
......@@ -268,7 +288,7 @@ gimp_channel_get_opacity (const GimpChannel *channel)
return channel->color.a;
}
void
void
gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity)
{
......@@ -279,6 +299,31 @@ gimp_channel_set_opacity (GimpChannel *channel,
channel->color.a = opacity;
}
gboolean
gimp_channel_get_show_masked (GimpChannel *channel)
{
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE);
return channel->show_masked;
}
void
gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked)
{
g_return_if_fail (GIMP_IS_CHANNEL (channel));
if (show_masked != channel->show_masked)
{
channel->show_masked = show_masked ? TRUE : FALSE;
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height);
}
}
void
gimp_channel_scale (GimpChannel *channel,
gint new_width,
......@@ -525,6 +570,7 @@ gimp_channel_boundary (GimpChannel *mask,
mask->num_segs_in = 0;
mask->num_segs_out = 0;
}
mask->boundary_known = TRUE;
}
......@@ -674,6 +720,7 @@ gimp_channel_bounds (GimpChannel *mask,
mask->x2 = tx2;
mask->y2 = ty2;
}
mask->bounds_known = TRUE;
*x1 = tx1;
......@@ -701,6 +748,7 @@ gimp_channel_is_empty (GimpChannel *mask)
0, 0,
GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, FALSE);
for (pr = pixel_regions_register (1, &maskPR);
pr != NULL;
pr = pixel_regions_process (pr))
......@@ -1207,15 +1255,16 @@ gimp_channel_feather (GimpChannel *mask,
}
void
gimp_channel_sharpen (GimpChannel *mask)
gimp_channel_sharpen (GimpChannel *mask,
gboolean push_undo)
{
PixelRegion maskPR;
GimpLut *lut;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
......@@ -1229,44 +1278,16 @@ gimp_channel_sharpen (GimpChannel *mask)
}
void
gimp_channel_push_undo (GimpChannel *mask)
{
gint x1, y1, x2, y2;
TileManager *undo_tiles;
PixelRegion srcPR, destPR;
GimpImage *gimage;
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
{
undo_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
pixel_region_init (&srcPR, GIMP_DRAWABLE (mask)->tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, undo_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
copy_region (&srcPR, &destPR);
}
else
undo_tiles = NULL;
gimage = gimp_item_get_image (GIMP_ITEM (mask));
undo_push_image_mask (gimage, undo_tiles, x1, y1);
gimp_image_mask_invalidate (gimage);
/* invalidate the preview */
GIMP_DRAWABLE (mask)->preview_valid = FALSE;
}
void
gimp_channel_clear (GimpChannel *mask)
gimp_channel_clear (GimpChannel *mask,
gboolean push_undo)
{
PixelRegion maskPR;
guchar bg = 0;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
if (mask->bounds_known && !mask->empty)
{
......@@ -1295,15 +1316,16 @@ gimp_channel_clear (GimpChannel *mask)
}
void
gimp_channel_all (GimpChannel *mask)
gimp_channel_all (GimpChannel *mask,
gboolean push_undo)
{
PixelRegion maskPR;
guchar bg = 255;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
/* clear the mask */
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
......@@ -1325,32 +1347,41 @@ void
gimp_channel_invert (GimpChannel *mask,
gboolean push_undo)
{
PixelRegion maskPR;
GimpLut *lut;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE);
if (mask->bounds_known && mask->empty)
{
gimp_channel_all (mask, FALSE);
}
else
{
PixelRegion maskPR;
GimpLut *lut;
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE);
lut = invert_lut_new (1);
lut = invert_lut_new (1);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline, lut,
1, &maskPR);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline, lut,
1, &maskPR);
gimp_lut_free (lut);
mask->bounds_known = FALSE;
gimp_lut_free (lut);
mask->bounds_known = FALSE;
}
}
void
gimp_channel_border (GimpChannel *mask,
gint radius_x,
gint radius_y)
gint radius_y,
gboolean push_undo)
{
PixelRegion bPR;
gint x1, y1, x2, y2;
......@@ -1362,6 +1393,7 @@ gimp_channel_border (GimpChannel *mask,
if (! gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
return;
if (gimp_channel_is_empty (mask))
return;
......@@ -1383,8 +1415,8 @@ gimp_channel_border (GimpChannel *mask,
else
y2 += radius_y;
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1,
(x2-x1), (y2-y1), TRUE);
......@@ -1397,7 +1429,8 @@ gimp_channel_border (GimpChannel *mask,
void
gimp_channel_grow (GimpChannel *mask,
gint radius_x,
gint radius_y)
gint radius_y,
gboolean push_undo)
{
PixelRegion bPR;
gint x1, y1, x2, y2;
......@@ -1409,7 +1442,7 @@ gimp_channel_grow (GimpChannel *mask,
if (radius_x <= 0 && radius_y <= 0)
{
gimp_channel_shrink (mask, -radius_x, -radius_y, FALSE);
gimp_channel_shrink (mask, -radius_x, -radius_y, FALSE, push_undo);
return;
}
......@@ -1418,6 +1451,7 @@ gimp_channel_grow (GimpChannel *mask,
if (! gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
return;
if (gimp_channel_is_empty (mask))
return;
......@@ -1438,8 +1472,8 @@ gimp_channel_grow (GimpChannel *mask,
else
y2 = GIMP_DRAWABLE (mask)->height;
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
/* need full extents for grow, not! */
pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2 - x1),
......@@ -1454,7 +1488,8 @@ void
gimp_channel_shrink (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock)
gboolean edge_lock,
gboolean push_undo)
{
PixelRegion bPR;
gint x1, y1, x2, y2;
......@@ -1466,7 +1501,7 @@ gimp_channel_shrink (GimpChannel *mask,
if (radius_x <= 0 && radius_y <= 0)
{
gimp_channel_grow (mask, -radius_x, -radius_y);
gimp_channel_grow (mask, -radius_x, -radius_y, push_undo);
return;
}
......@@ -1475,6 +1510,7 @@ gimp_channel_shrink (GimpChannel *mask,
if (! gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
return;
if (gimp_channel_is_empty (mask))
return;
......@@ -1487,8 +1523,8 @@ gimp_channel_shrink (GimpChannel *mask,
if (y2 < GIMP_DRAWABLE (mask)->height)
y2++;
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&bPR, GIMP_DRAWABLE (mask)->tiles, x1, y1, (x2 - x1),
(y2 - y1), TRUE);
......@@ -1501,7 +1537,8 @@ gimp_channel_shrink (GimpChannel *mask,
void
gimp_channel_translate (GimpChannel *mask,
gint off_x,
gint off_y)
gint off_y,
gboolean push_undo)
{
gint width, height;
GimpChannel *tmp_mask;
......@@ -1513,8 +1550,8 @@ gimp_channel_translate (GimpChannel *mask,
tmp_mask = NULL;
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
gimp_channel_bounds (mask, &x1, &y1, &x2, &y2);
x1 = CLAMP ((x1 + off_x), 0, GIMP_DRAWABLE (mask)->width);
......@@ -1580,15 +1617,16 @@ gimp_channel_translate (GimpChannel *mask,
void
gimp_channel_load (GimpChannel *mask,
GimpChannel *channel)
GimpChannel *channel,
gboolean push_undo)
{
PixelRegion srcPR, destPR;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (GIMP_IS_CHANNEL (channel));
/* push the current mask onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
/* copy the channel to the mask */
pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles,
......@@ -1606,25 +1644,22 @@ gimp_channel_load (GimpChannel *mask,
void
gimp_channel_layer_alpha (GimpChannel *mask,
GimpLayer *layer)
GimpLayer *layer,
gboolean push_undo)
{
PixelRegion srcPR, destPR;
guchar empty = 0;
gint x1, y1, x2, y2;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)));
/* push the current mask onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
/* clear the mask */
pixel_region_init (&destPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE);
color_region (&destPR, &empty);
/* clear the mask if it is not already known to be empty */
if (! (mask->bounds_known && mask->empty))
gimp_channel_clear (mask, FALSE);
x1 = CLAMP (GIMP_DRAWABLE (layer)->offset_x, 0, GIMP_DRAWABLE (mask)->width);
y1 = CLAMP (GIMP_DRAWABLE (layer)->offset_y, 0, GIMP_DRAWABLE (mask)->height);
......@@ -1646,25 +1681,22 @@ gimp_channel_layer_alpha (GimpChannel *mask,
void
gimp_channel_layer_mask (GimpChannel *mask,
GimpLayer *layer)
GimpLayer *layer,
gboolean push_undo)
{
PixelRegion srcPR, destPR;
guchar empty = 0;
gint x1, y1, x2, y2;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_get_mask (layer));
/* push the current mask onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
/* clear the mask */
pixel_region_init (&destPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
GIMP_DRAWABLE (mask)->width, GIMP_DRAWABLE (mask)->height,
TRUE);
color_region (&destPR, &empty);
/* clear the mask if it is not already known to be empty */
if (! (mask->bounds_known && mask->empty))
gimp_channel_clear (mask, FALSE);
x1 = CLAMP (GIMP_DRAWABLE (layer)->offset_x, 0, GIMP_DRAWABLE (mask)->width);
y1 = CLAMP (GIMP_DRAWABLE (layer)->offset_y, 0, GIMP_DRAWABLE (mask)->height);
......
......@@ -22,6 +22,7 @@
#include "gimpdrawable.h"
/*< proxy-skip >*/
/* Half way point where a region is no longer visible in a selection */
#define HALF_WAY 127
......@@ -37,6 +38,8 @@
typedef struct _GimpChannelClass GimpChannelClass;
/*< proxy-resume >*/
struct _GimpChannel
{
GimpDrawable parent_instance;
......@@ -57,6 +60,8 @@ struct _GimpChannel
gint x2, y2; /* lower right hand coordinate */
};
/*< proxy-skip >*/
struct _GimpChannelClass
{
GimpDrawableClass parent_class;
......@@ -85,6 +90,10 @@ void gimp_channel_get_color (const GimpChannel *channel,
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);;
void gimp_channel_scale (GimpChannel *channel,
gint new_width,
gint new_height,
......@@ -154,36 +163,44 @@ void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void gimp_channel_sharpen (GimpChannel *mask);
void gimp_channel_push_undo (GimpChannel *mask);
void gimp_channel_sharpen (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_clear (GimpChannel *mask);
void gimp_channel_all (GimpChannel *mask);
void gimp_channel_clear (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_all (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
gint radius_y);
gint radius_y,
gboolean push_undo);
void gimp_channel_grow (GimpChannel *mask,
gint radius_x,
gint radius_y);
gint radius_y,
gboolean push_undo);
void gimp_channel_shrink (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock);
gboolean edge_lock,
gboolean push_undo);
void gimp_channel_translate (GimpChannel *mask,
gint off_x,
gint off_y);
void gimp_channel_load (GimpChannel *mask,
GimpChannel *channel);
gint off_y,
gboolean push_undo);
void gimp_channel_load (GimpChannel *mask,
GimpChannel *channel,
gboolean push_undo);
void gimp_channel_layer_alpha (GimpChannel *mask,
GimpLayer *layer);
GimpLayer *layer,
gboolean push_undo);
void gimp_channel_layer_mask (GimpChannel *mask,
GimpLayer *layer);
GimpLayer *layer,
gboolean push_undo);
void gimp_channel_invalidate_bounds (GimpChannel *channel);
......
......@@ -50,7 +50,7 @@ gimp_image_mask_select_rectangle (GimpImage *gimage,
if (op == GIMP_CHANNEL_OP_REPLACE)
gimp_image_mask_clear (gimage);
else
gimp_image_mask_undo (gimage);
gimp_image_mask_push_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
......@@ -95,7 +95,7 @@ gimp_image_mask_select_ellipse (GimpImage *gimage,
if (op == GIMP_CHANNEL_OP_REPLACE)
gimp_image_mask_clear (gimage);
else
gimp_image_mask_undo (gimage);
gimp_image_mask_push_undo (gimage);
/* if feathering for rect, make a new mask with the
* rectangle and feather that with the old mask
......@@ -145,7 +145,7 @@ gimp_image_mask_select_polygon (GimpImage *gimage,
if (op == GIMP_CHANNEL_OP_REPLACE)
gimp_image_mask_clear (gimage);
else
gimp_image_mask_undo (gimage);
gimp_image_mask_push_undo (gimage);
#define SUPERSAMPLE 3
......@@ -247,7 +247,7 @@ gimp_image_mask_select_channel (GimpImage *gimage,
if (op == GIMP_CHANNEL_OP_REPLACE)
gimp_image_mask_clear (gimage);
else
gimp_image_mask_undo (gimage);
gimp_image_mask_push_undo (gimage);
if (feather)
gimp_channel_feather (channel,
......
......@@ -33,14 +33,12 @@
#include "base/lut-funcs.h"
#include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "base/temp-buf.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpchannel.h"
#include "gimplayer.h"
#include "gimpparasitelist.h"
......@@ -57,6 +55,10 @@ static void gimp_channel_finalize (GObject *object);
static gsize gimp_channel_get_memsize (GimpObject *object);
static void gimp_channel_push_undo (GimpChannel *mask);
static void gimp_channel_validate (TileManager *tm,
Tile *tile);
static GimpDrawableClass * parent_class = NULL;
......@@ -164,6 +166,21 @@ gimp_channel_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static void
gimp_channel_push_undo (GimpChannel *mask)
{
GimpImage *gimage;
gimage = gimp_item_get_image (GIMP_ITEM (mask));
undo_push_mask (gimage, mask);
mask->boundary_known = FALSE;
/* invalidate the preview */
GIMP_DRAWABLE (mask)->preview_valid = FALSE;
}
static void
gimp_channel_validate (TileManager *tm,
Tile *tile)
......@@ -173,6 +190,9 @@ gimp_channel_validate (TileManager *tm,
TRANSPARENT_OPACITY, tile_size (tile));
}
/* public functions */
GimpChannel *
gimp_channel_new (GimpImage *gimage,
gint width,
......@@ -268,7 +288,7 @@ gimp_channel_get_opacity (const GimpChannel *channel)
return channel->color.a;
}
void
void
gimp_channel_set_opacity (GimpChannel *channel,