ref new tiles before unrefing the old ones.

2004-03-16  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable.c (gimp_drawable_set_tiles): ref new
	tiles before unrefing the old ones.

	* app/core/gimpimage-undo-push.c: keep undo memsize exact by
	adjusting undo->size when the stored data changes.

	* app/core/gimpchannel.[ch] (gimp_channel_new_from_alpha)
	* app/core/gimpchannel-select.[ch] (gimp_channel_select_alpha):
	replaced "layer" parameter by "drawable".

	* app/gui/layers-commands.c
	* tools/pdbgen/pdb/selection.pdb: changed accordingly.

	* app/pdb/selection_cmds.c: regenerated.

	* app/core/gimpchannel.c
	* app/core/gimplayer.c
	* app/core/gimplayermask.[ch]
	* app/core/gimpselection.c: remdom cleanup & code review.
This commit is contained in:
Michael Natterer 2004-03-16 16:23:06 +00:00 committed by Michael Natterer
parent 05410dc036
commit 49238237dc
15 changed files with 228 additions and 272 deletions

View File

@ -1,3 +1,25 @@
2004-03-16 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawable.c (gimp_drawable_set_tiles): ref new
tiles before unrefing the old ones.
* app/core/gimpimage-undo-push.c: keep undo memsize exact by
adjusting undo->size when the stored data changes.
* app/core/gimpchannel.[ch] (gimp_channel_new_from_alpha)
* app/core/gimpchannel-select.[ch] (gimp_channel_select_alpha):
replaced "layer" parameter by "drawable".
* app/gui/layers-commands.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
* app/core/gimpchannel.c
* app/core/gimplayer.c
* app/core/gimplayermask.[ch]
* app/core/gimpselection.c: remdom cleanup & code review.
2004-03-16 Michael Natterer <mitch@gimp.org>
* app/core/gimplist.c (gimp_list_dispose): removed this function.

View File

@ -491,7 +491,8 @@ layers_alpha_to_selection_cmd_callback (GtkWidget *widget,
op = (GimpChannelOps) action;
gimp_channel_select_alpha (gimp_image_get_mask (gimage), active_layer,
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
GIMP_DRAWABLE (active_layer),
op, FALSE, 0.0, 0.0);
gimp_image_flush (gimage);
}

View File

@ -28,7 +28,6 @@
#include "gimpchannel-select.h"
#include "gimpchannel-combine.h"
#include "gimpimage-contiguous-region.h"
#include "gimplayer.h"
#include "gimpscanconvert.h"
#include "vectors/gimpstroke.h"
@ -328,7 +327,7 @@ gimp_channel_select_channel (GimpChannel *channel,
void
gimp_channel_select_alpha (GimpChannel *channel,
GimpLayer *layer,
GimpDrawable *drawable,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,
@ -339,18 +338,18 @@ gimp_channel_select_alpha (GimpChannel *channel,
gint off_x, off_y;
g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
item = GIMP_ITEM (channel);
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
if (gimp_drawable_has_alpha (drawable))
{
GimpRGB color;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
add_on = gimp_channel_new_from_alpha (gimp_item_get_image (item),
layer, NULL, &color);
drawable, NULL, &color);
}
else
{
@ -358,12 +357,12 @@ gimp_channel_select_alpha (GimpChannel *channel,
* so simply select the whole layer's extents. --mitch
*/
add_on = gimp_channel_new_mask (gimp_item_get_image (item),
gimp_item_width (GIMP_ITEM (layer)),
gimp_item_height (GIMP_ITEM (layer)));
gimp_item_width (GIMP_ITEM (drawable)),
gimp_item_height (GIMP_ITEM (drawable)));
gimp_channel_all (add_on, FALSE);
}
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
gimp_channel_select_channel (channel, _("Alpha to Selection"), add_on,
off_x, off_y,

View File

@ -86,7 +86,7 @@ void gimp_channel_select_channel (GimpChannel *channel,
gdouble feather_radius_x,
gdouble feather_radius_y);
void gimp_channel_select_alpha (GimpChannel *channel,
GimpLayer *layer,
GimpDrawable *drawable,
GimpChannelOps op,
gboolean feather,
gdouble feather_radius_x,

View File

@ -49,7 +49,6 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-stroke.h"
#include "gimplayer.h"
#include "gimppaintinfo.h"
#include "gimpstrokeoptions.h"
@ -227,17 +226,11 @@ gimp_channel_get_type (void)
static void
gimp_channel_class_init (GimpChannelClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpItemClass *item_class;
GimpDrawableClass *drawable_class;
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
drawable_class = GIMP_DRAWABLE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
GimpDrawableClass *drawable_class = GIMP_DRAWABLE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -375,9 +368,7 @@ gimp_channel_duplicate (GimpItem *item,
channel = GIMP_CHANNEL (item);
new_channel = GIMP_CHANNEL (new_item);
/* set the channel color and opacity */
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
@ -397,21 +388,17 @@ gimp_channel_translate (GimpItem *item,
gint off_y,
gboolean push_undo)
{
GimpChannel *channel;
GimpChannel *channel = GIMP_CHANNEL (item);
GimpChannel *tmp_mask = NULL;
gint width, height;
PixelRegion srcPR, destPR;
guchar empty = TRANSPARENT_OPACITY;
gint x1, y1, x2, y2;
channel = GIMP_CHANNEL (item);
gimp_channel_bounds (channel, &x1, &y1, &x2, &y2);
/* update the old area */
gimp_drawable_update (GIMP_DRAWABLE (item),
x1, y1,
x2 - x1, y2 - y1);
gimp_drawable_update (GIMP_DRAWABLE (item), x1, y1, x2 - x1, y2 - y1);
if (push_undo)
gimp_channel_push_undo (channel,
@ -532,11 +519,7 @@ gimp_channel_flip (GimpItem *item,
gdouble axis,
gboolean clip_result)
{
GimpChannel *channel;
GimpImage *gimage;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Flip Channel"));
@ -547,9 +530,6 @@ gimp_channel_flip (GimpItem *item,
GIMP_ITEM_CLASS (parent_class)->flip (item, flip_type, axis, clip_result);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
}
static void
@ -559,11 +539,7 @@ gimp_channel_rotate (GimpItem *item,
gdouble center_y,
gboolean clip_result)
{
GimpChannel *channel;
GimpImage *gimage;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Rotate Channel"));
@ -575,9 +551,6 @@ gimp_channel_rotate (GimpItem *item,
clip_result);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
}
static void
@ -591,11 +564,7 @@ gimp_channel_transform (GimpItem *item,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpChannel *channel;
GimpImage *gimage;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Transform Channel"));
@ -610,9 +579,6 @@ gimp_channel_transform (GimpItem *item,
progress_callback, progress_data);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
}
static gboolean
@ -693,9 +659,7 @@ gimp_channel_stroke (GimpItem *item,
static void
gimp_channel_invalidate_boundary (GimpDrawable *drawable)
{
GimpChannel *channel = GIMP_CHANNEL (drawable);
channel->boundary_known = FALSE;
GIMP_CHANNEL (drawable)->boundary_known = FALSE;
}
static void
@ -809,7 +773,8 @@ gimp_channel_real_boundary (GimpChannel *channel,
if (gimp_channel_bounds (channel, &x3, &y3, &x4, &y4))
{
pixel_region_init (&bPR, GIMP_DRAWABLE (channel)->tiles,
x3, y3, (x4 - x3), (y4 - y3), FALSE);
x3, y3, x4 - x3, y4 - y3, FALSE);
channel->segs_out = find_mask_boundary (&bPR, &channel->num_segs_out,
IgnoreBounds,
x1, y1,
@ -826,6 +791,7 @@ gimp_channel_real_boundary (GimpChannel *channel,
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height, FALSE);
channel->segs_in = find_mask_boundary (&bPR, &channel->num_segs_in,
WithinBounds,
x1, y1,
@ -1452,9 +1418,7 @@ gimp_channel_new (GimpImage *gimage,
0, 0, width, height,
GIMP_GRAY_IMAGE, name);
/* set the channel color and opacity */
channel->color = *color;
channel->show_masked = TRUE;
/* selection mask variables */
@ -1466,7 +1430,7 @@ gimp_channel_new (GimpImage *gimage,
GimpChannel *
gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
GimpDrawable *drawable,
const gchar *name,
const GimpRGB *color)
{
@ -1476,18 +1440,18 @@ gimp_channel_new_from_alpha (GimpImage *gimage,
PixelRegion srcPR, destPR;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_drawable_has_alpha (drawable), NULL);
g_return_val_if_fail (color != NULL, NULL);
width = gimp_item_width (GIMP_ITEM (layer));
height = gimp_item_height (GIMP_ITEM (layer));
width = gimp_item_width (GIMP_ITEM (drawable));
height = gimp_item_height (GIMP_ITEM (drawable));
channel = gimp_channel_new (gimage, width, height, name, color);
gimp_channel_clear (channel, NULL, FALSE);
pixel_region_init (&srcPR, gimp_drawable_data (GIMP_DRAWABLE (layer)),
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
0, 0, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_data (GIMP_DRAWABLE (channel)),
0, 0, width, height, TRUE);
@ -1528,7 +1492,7 @@ gimp_channel_new_from_component (GimpImage *gimage,
pixel_region_init (&src, projection,
0, 0, width, height, FALSE);
pixel_region_init (&dest, GIMP_DRAWABLE (channel)->tiles,
pixel_region_init (&dest, gimp_drawable_data (GIMP_DRAWABLE (channel)),
0, 0, width, height, TRUE);
copy_component (&src, &dest, pixel);
@ -1668,11 +1632,9 @@ gimp_channel_new_mask (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
/* Create the new channel */
new_channel = gimp_channel_new (gimage, width, height,
_("Selection Mask"), &black);
/* Set the validate procedure */
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
gimp_channel_validate);

View File

@ -40,7 +40,7 @@ struct _GimpChannel
{
GimpDrawable parent_instance;
GimpRGB color; /* Also stored the opacity */
GimpRGB color; /* Also stores the opacity */
gboolean show_masked; /* Show masked areas--as */
/* opposed to selected areas */
@ -129,7 +129,7 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
GimpDrawable *drawable,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,

View File

@ -590,10 +590,13 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
gimp_image_undo_push_drawable_mod (gimp_item_get_image (item), undo_desc,
drawable);
/* ref new before unrefing old, they might be the same */
tile_manager_ref (tiles);
if (drawable->tiles)
tile_manager_unref (drawable->tiles);
drawable->tiles = tile_manager_ref (tiles);
drawable->tiles = tiles;
drawable->type = type;
drawable->bytes = tile_manager_bpp (tiles);
drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);

View File

@ -640,6 +640,8 @@ undo_pop_drawable (GimpUndo *undo,
{
DrawableUndo *drawable_undo = undo->data;
undo->size -= tile_manager_get_memsize (drawable_undo->tiles);
gimp_drawable_swap_pixels (GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item),
drawable_undo->tiles,
drawable_undo->sparse,
@ -648,6 +650,8 @@ undo_pop_drawable (GimpUndo *undo,
drawable_undo->width,
drawable_undo->height);
undo->size += tile_manager_get_memsize (drawable_undo->tiles);
return TRUE;
}
@ -726,6 +730,8 @@ undo_pop_drawable_mod (GimpUndo *undo,
GimpImageType drawable_type;
gint offset_x, offset_y;
undo->size -= tile_manager_get_memsize (drawable_undo->tiles);
tiles = drawable_undo->tiles;
drawable_type = drawable_undo->type;
offset_x = drawable_undo->offset_x;
@ -740,6 +746,8 @@ undo_pop_drawable_mod (GimpUndo *undo,
tiles, drawable_type, offset_x, offset_y);
tile_manager_unref (tiles);
undo->size += tile_manager_get_memsize (drawable_undo->tiles);
return TRUE;
}
@ -777,7 +785,7 @@ gimp_image_undo_push_mask (GimpImage *gimage,
const gchar *undo_desc,
GimpChannel *mask)
{
TileManager *undo_tiles;
TileManager *undo_tiles = NULL;
gint x1, y1, x2, y2;
GimpUndo *new;
gint64 size;
@ -785,26 +793,25 @@ gimp_image_undo_push_mask (GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_CHANNEL (mask), FALSE);
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
{
PixelRegion srcPR, destPR;
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;
size = sizeof (MaskUndo);
if (undo_tiles)
if (gimp_channel_bounds (mask, &x1, &y1, &x2, &y2))
{
GimpDrawable *drawable = GIMP_DRAWABLE (mask);
PixelRegion srcPR, destPR;
undo_tiles = tile_manager_new (x2 - x1, y2 - y1,
gimp_drawable_bytes (drawable));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, x2 - x1, y2 - y1, FALSE);
pixel_region_init (&destPR, undo_tiles,
0, 0, x2 - x1, y2 - y1, TRUE);
copy_region (&srcPR, &destPR);
size += tile_manager_get_memsize (undo_tiles);
}
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (mask),
size, sizeof (MaskUndo),
@ -813,11 +820,11 @@ gimp_image_undo_push_mask (GimpImage *gimage,
undo_pop_mask,
undo_free_mask)))
{
MaskUndo *mu = new->data;
MaskUndo *mask_undo = new->data;
mu->tiles = undo_tiles;
mu->x = x1;
mu->y = y1;
mask_undo->tiles = undo_tiles;
mask_undo->x = x1;
mask_undo->y = y1;
return TRUE;
}
@ -842,6 +849,9 @@ undo_pop_mask (GimpUndo *undo,
gint height = 0;
guchar empty = 0;
if (mu->tiles)
undo->size -= tile_manager_get_memsize (mu->tiles);
if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2))
{
new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), 1);
@ -911,6 +921,9 @@ undo_pop_mask (GimpUndo *undo,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
if (mu->tiles)
undo->size += tile_manager_get_memsize (mu->tiles);
return TRUE;
}
@ -935,7 +948,7 @@ typedef struct _ItemRenameUndo ItemRenameUndo;
struct _ItemRenameUndo
{
gchar *old_name;
gchar *name;
};
static gboolean undo_pop_item_rename (GimpUndo *undo,
@ -969,7 +982,7 @@ gimp_image_undo_push_item_rename (GimpImage *gimage,
{
ItemRenameUndo *iru = new->data;
iru->old_name = g_strdup (name);
iru->name = g_strdup (name);
return TRUE;
}
@ -986,10 +999,14 @@ undo_pop_item_rename (GimpUndo *undo,
GimpItem *item = GIMP_ITEM_UNDO (undo)->item;
gchar *tmp;
undo->size -= strlen (iru->name);
tmp = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
gimp_object_set_name (GIMP_OBJECT (item), iru->old_name);
g_free (iru->old_name);
iru->old_name = tmp;
gimp_object_set_name (GIMP_OBJECT (item), iru->name);
g_free (iru->name);
iru->name = tmp;
undo->size += strlen (iru->name);
return TRUE;
}
@ -1000,7 +1017,7 @@ undo_free_item_rename (GimpUndo *undo,
{
ItemRenameUndo *iru = undo->data;
g_free (iru->old_name);
g_free (iru->name);
g_free (iru);
}
@ -1325,12 +1342,6 @@ undo_pop_layer (GimpUndo *undo,
{
/* remove layer */
#if 0
g_printerr ("undo_pop_layer: taking ownership, size += "
"%" G_GINT64_FORMAT "\n",
gimp_object_get_memsize (GIMP_OBJECT (layer), NULL));
#endif
undo->size += gimp_object_get_memsize (GIMP_OBJECT (layer), NULL);
/* record the current position */
@ -1372,12 +1383,6 @@ undo_pop_layer (GimpUndo *undo,
{
/* restore layer */
#if 0
g_printerr ("undo_pop_layer: dropping ownership, size -= "
"%" G_GINT64_FORMAT "\n",
gimp_object_get_memsize (GIMP_OBJECT (layer), NULL));
#endif
undo->size -= gimp_object_get_memsize (GIMP_OBJECT (layer), NULL);
/* record the active layer */
@ -1473,8 +1478,7 @@ undo_push_layer_mask (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (mask), NULL);
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
size,
sizeof (LayerMaskUndo),
size, sizeof (LayerMaskUndo),
type, undo_desc,
TRUE,
undo_pop_layer_mask,
@ -1763,8 +1767,7 @@ gimp_image_undo_push_text_layer (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (layer->text), NULL);
undo = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer),
size,
sizeof (TextUndo),
size, sizeof (TextUndo),
GIMP_UNDO_TEXT_LAYER, undo_desc,
TRUE,
undo_pop_text_layer,
@ -1792,6 +1795,9 @@ undo_pop_text_layer (GimpUndo *undo,
GimpTextLayer *layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item);
GimpText *text;
if (tu->text)
undo->size -= gimp_object_get_memsize (GIMP_OBJECT (tu->text), NULL);
text = (layer->text ?
gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL);
@ -1802,6 +1808,9 @@ undo_pop_text_layer (GimpUndo *undo,
tu->text = text;
if (tu->text)
undo->size += gimp_object_get_memsize (GIMP_OBJECT (tu->text), NULL);
return TRUE;
}
@ -1888,8 +1897,7 @@ undo_push_channel (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (channel), NULL);
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (channel),
size,
sizeof (ChannelUndo),
size, sizeof (ChannelUndo),
type, undo_desc,
TRUE,
undo_pop_channel,
@ -2172,8 +2180,7 @@ undo_push_vectors (GimpImage *gimage,
size += gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL);
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
size,
sizeof (VectorsUndo),
size, sizeof (VectorsUndo),
type, undo_desc,
TRUE,
undo_pop_vectors,
@ -2250,7 +2257,7 @@ typedef struct _VectorsModUndo VectorsModUndo;
struct _VectorsModUndo
{
GimpVectors *undo_vectors;
GimpVectors *vectors;
};
static gboolean undo_pop_vectors_mod (GimpUndo *undo,
@ -2264,18 +2271,22 @@ gimp_image_undo_push_vectors_mod (GimpImage *gimage,
const gchar *undo_desc,
GimpVectors *vectors)
{
GimpVectors *copy;
GimpUndo *new;
gint64 size;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
copy = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors),
FALSE));
size = (sizeof (VectorsModUndo) +
gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL));
gimp_object_get_memsize (GIMP_OBJECT (copy), NULL));
if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors),
size,
sizeof (VectorsModUndo),
size, sizeof (VectorsModUndo),
GIMP_UNDO_VECTORS_MOD, undo_desc,
TRUE,
undo_pop_vectors_mod,
@ -2283,13 +2294,14 @@ gimp_image_undo_push_vectors_mod (GimpImage *gimage,
{
VectorsModUndo *vmu = new->data;
vmu->undo_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors),
FALSE));
vmu->vectors = copy;
return TRUE;
}
if (copy)
g_object_unref (copy);
return FALSE;
}
@ -2302,9 +2314,11 @@ undo_pop_vectors_mod (GimpUndo *undo,
GimpVectors *vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (undo)->item);
GimpVectors *temp;
temp = vmu->undo_vectors;
undo->size -= gimp_object_get_memsize (GIMP_OBJECT (vmu->vectors), NULL);
vmu->undo_vectors =
temp = vmu->vectors;
vmu->vectors =
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
G_TYPE_FROM_INSTANCE (vectors),
FALSE));
@ -2322,6 +2336,8 @@ undo_pop_vectors_mod (GimpUndo *undo,
gimp_vectors_thaw (vectors);
undo->size += gimp_object_get_memsize (GIMP_OBJECT (vmu->vectors), NULL);
return TRUE;
}
@ -2331,7 +2347,7 @@ undo_free_vectors_mod (GimpUndo *undo,
{
VectorsModUndo *vmu = undo->data;
g_object_unref (vmu->undo_vectors);
g_object_unref (vmu->vectors);
g_free (vmu);
}
@ -2843,9 +2859,7 @@ static void
undo_free_parasite (GimpUndo *undo,
GimpUndoMode undo_mode)
{
ParasiteUndo *pu;
pu = (ParasiteUndo *) undo->data;
ParasiteUndo *pu = undo->data;
if (pu->parasite)
gimp_parasite_free (pu->parasite);

View File

@ -180,17 +180,11 @@ gimp_layer_get_type (void)
static void
gimp_layer_class_init (GimpLayerClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpItemClass *item_class;
GimpDrawableClass *drawable_class;
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
drawable_class = GIMP_DRAWABLE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
GimpDrawableClass *drawable_class = GIMP_DRAWABLE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -307,6 +301,12 @@ gimp_layer_finalize (GObject *object)
layer->mask = NULL;
}
if (layer->fs.backing_store)
{
tile_manager_unref (layer->fs.backing_store);
layer->fs.backing_store = NULL;
}
if (layer->fs.segs)
{
g_free (layer->fs.segs);
@ -314,13 +314,6 @@ gimp_layer_finalize (GObject *object)
layer->fs.num_segs = 0;
}
/* free the floating selection if it exists */
if (layer->fs.backing_store)
{
tile_manager_unref (layer->fs.backing_store);
layer->fs.backing_store = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -631,7 +624,6 @@ gimp_layer_translate (GimpItem *item,
GIMP_ITEM (layer->mask)->offset_x = item->offset_x;
GIMP_ITEM (layer->mask)->offset_y = item->offset_y;
/* invalidate the mask preview */
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer->mask));
}
}
@ -647,9 +639,7 @@ gimp_layer_scale (GimpItem *item,
gpointer progress_data)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpImage *gimage;
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
if (layer->mask)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_SCALE,
@ -660,7 +650,6 @@ gimp_layer_scale (GimpItem *item,
interpolation_type,
progress_callback, progress_data);
/* If there is a layer mask, make sure it gets scaled also */
if (layer->mask)
{
gimp_item_scale (GIMP_ITEM (layer->mask),
@ -680,9 +669,7 @@ gimp_layer_resize (GimpItem *item,
gint offset_y)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpImage *gimage;
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
if (layer->mask)
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_RESIZE,
@ -707,16 +694,13 @@ gimp_layer_flip (GimpItem *item,
gboolean clip_result)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpImage *gimage;
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Flip Layer"));
GIMP_ITEM_CLASS (parent_class)->flip (item, flip_type, axis, clip_result);
/* If there is a layer mask, make sure it gets flipped as well */
if (layer->mask)
gimp_item_flip (GIMP_ITEM (layer->mask),
flip_type, axis, clip_result);
@ -732,9 +716,7 @@ gimp_layer_rotate (GimpItem *item,
gboolean clip_result)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpImage *gimage;
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Rotate Layer"));
@ -743,7 +725,6 @@ gimp_layer_rotate (GimpItem *item,
rotate_type, center_x, center_y,
clip_result);
/* If there is a layer mask, make sure it gets rotates as well */
if (layer->mask)
gimp_item_rotate (GIMP_ITEM (layer->mask),
rotate_type, center_x, center_y, clip_result);
@ -763,9 +744,7 @@ gimp_layer_transform (GimpItem *item,
gpointer progress_data)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpImage *gimage;
gimage = gimp_item_get_image (item);
GimpImage *gimage = gimp_item_get_image (item);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Transform Layer"));
@ -776,7 +755,6 @@ gimp_layer_transform (GimpItem *item,
clip_result,
progress_callback, progress_data);
/* If there is a layer mask, make sure it gets flipped also */
if (layer->mask)
gimp_item_transform (GIMP_ITEM (layer->mask),
matrix, direction,
@ -943,12 +921,8 @@ gimp_layer_new_from_tiles (TileManager *tiles,
width = tile_manager_width (tiles);
height = tile_manager_height (tiles);
new_layer = gimp_layer_new (dest_gimage,
width, height,
type,
name,
opacity,
mode);
new_layer = gimp_layer_new (dest_gimage, width, height, type, name,
opacity, mode);
if (! new_layer)
{
@ -958,12 +932,10 @@ gimp_layer_new_from_tiles (TileManager *tiles,
/* Configure the pixel regions */
pixel_region_init (&bufPR, tiles,
0, 0,
width, height,
0, 0, width, height,
FALSE);
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
0, 0,
width, height,
0, 0, width, height,
TRUE);
if ((tile_manager_bpp (tiles) == 4 &&
@ -1400,8 +1372,6 @@ gimp_layer_add_alpha (GimpLayer *layer)
GIMP_ITEM (layer)->offset_x,
GIMP_ITEM (layer)->offset_y);
tile_manager_unref (new_tiles);
GIMP_DRAWABLE (layer)->preview_valid = FALSE;
}
void

View File

@ -94,13 +94,9 @@ gimp_layer_mask_get_type (void)
static void
gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
{
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpItemClass *item_class;
gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -222,7 +218,6 @@ gimp_layer_mask_new (GimpImage *gimage,
/* set the layer_mask color and opacity */
GIMP_CHANNEL (layer_mask)->color = *color;
GIMP_CHANNEL (layer_mask)->show_masked = TRUE;
/* selection mask variables */
@ -275,9 +270,7 @@ gimp_layer_mask_set_apply (GimpLayerMask *layer_mask,
if (layer_mask->layer)
{
GimpDrawable *drawable;
drawable = GIMP_DRAWABLE (layer_mask->layer);
GimpDrawable *drawable = GIMP_DRAWABLE (layer_mask->layer);
gimp_drawable_update (drawable,
0, 0,
@ -331,9 +324,7 @@ gimp_layer_mask_set_show (GimpLayerMask *layer_mask,
if (layer_mask->layer)
{
GimpDrawable *drawable;
drawable = GIMP_DRAWABLE (layer_mask->layer);
GimpDrawable *drawable = GIMP_DRAWABLE (layer_mask->layer);
gimp_drawable_update (drawable,
0, 0,

View File

@ -161,15 +161,10 @@ gimp_selection_get_type (void)
static void
gimp_selection_class_init (GimpSelectionClass *klass)
{
GimpViewableClass *viewable_class;
GimpItemClass *item_class;
GimpDrawableClass *drawable_class;
GimpChannelClass *channel_class;
viewable_class = GIMP_VIEWABLE_CLASS (klass);
item_class = GIMP_ITEM_CLASS (klass);
drawable_class = GIMP_DRAWABLE_CLASS (klass);
channel_class = GIMP_CHANNEL_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
GimpDrawableClass *drawable_class = GIMP_DRAWABLE_CLASS (klass);
GimpChannelClass *channel_class = GIMP_CHANNEL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -329,13 +324,9 @@ gimp_selection_stroke (GimpItem *item,
static void
gimp_selection_invalidate_boundary (GimpDrawable *drawable)
{
GimpChannel *selection;
GimpChannel *selection = GIMP_CHANNEL (drawable);
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpLayer *layer;
GimpImage *gimage;
selection = GIMP_CHANNEL (drawable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_return_if_fail (GIMP_IS_IMAGE (gimage));

View File

@ -491,7 +491,8 @@ layers_alpha_to_selection_cmd_callback (GtkWidget *widget,
op = (GimpChannelOps) action;
gimp_channel_select_alpha (gimp_image_get_mask (gimage), active_layer,
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
GIMP_DRAWABLE (active_layer),
op, FALSE, 0.0, 0.0);
gimp_image_flush (gimage);
}

View File

@ -867,7 +867,8 @@ selection_layer_alpha_invoker (Gimp *gimp,
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (layer));
gimp_channel_select_alpha (gimp_image_get_mask (gimage), layer,
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
GIMP_DRAWABLE (layer),
GIMP_CHANNEL_OP_REPLACE, FALSE, 0.0, 0.0);
}

View File

@ -328,7 +328,8 @@ HELP
code => <<'CODE'
{
gimage = gimp_item_get_image (GIMP_ITEM (layer));
gimp_channel_select_alpha (gimp_image_get_mask (gimage), layer,
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
GIMP_DRAWABLE (layer),
GIMP_CHANNEL_OP_REPLACE, FALSE, 0.0, 0.0);
}
CODE