Commit 54c86f97 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/core/gimpchannel.c app/core/gimpdrawable.c app/core/gimplayer.c

2005-12-23  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpchannel.c
	* app/core/gimpdrawable.c
	* app/core/gimplayer.c
	* app/core/gimplayermask.c
	* app/text/gimptextlayer.c
	* app/vectors/gimpvectors.c: moved variables to local scopes in
	implementations of GimpItem::duplicate()
parent 14d43a50
2005-12-23 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c
* app/core/gimpdrawable.c
* app/core/gimplayer.c
* app/core/gimplayermask.c
* app/text/gimptextlayer.c
* app/vectors/gimpvectors.c: moved variables to local scopes in
implementations of GimpItem::duplicate()
2005-12-23 Simon Budig <simon@gimp.org> 2005-12-23 Simon Budig <simon@gimp.org>
* app/vectors/gimpbezierstroke.c * app/vectors/gimpbezierstroke.c
......
...@@ -377,9 +377,7 @@ gimp_channel_duplicate (GimpItem *item, ...@@ -377,9 +377,7 @@ gimp_channel_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha) gboolean add_alpha)
{ {
GimpChannel *channel; GimpItem *new_item;
GimpItem *new_item;
GimpChannel *new_channel;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
...@@ -389,22 +387,22 @@ gimp_channel_duplicate (GimpItem *item, ...@@ -389,22 +387,22 @@ gimp_channel_duplicate (GimpItem *item,
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type, new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha); add_alpha);
if (! GIMP_IS_CHANNEL (new_item)) if (GIMP_IS_CHANNEL (new_item))
return new_item; {
GimpChannel *channel = GIMP_CHANNEL (item);
channel = GIMP_CHANNEL (item); GimpChannel *new_channel = GIMP_CHANNEL (new_item);
new_channel = GIMP_CHANNEL (new_item);
new_channel->color = channel->color;
new_channel->color = channel->color; new_channel->show_masked = channel->show_masked;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
/* selection mask variables */ new_channel->bounds_known = channel->bounds_known;
new_channel->bounds_known = channel->bounds_known; new_channel->empty = channel->empty;
new_channel->empty = channel->empty; new_channel->x1 = channel->x1;
new_channel->x1 = channel->x1; new_channel->y1 = channel->y1;
new_channel->y1 = channel->y1; new_channel->x2 = channel->x2;
new_channel->x2 = channel->x2; new_channel->y2 = channel->y2;
new_channel->y2 = channel->y2; }
return new_item; return new_item;
} }
......
...@@ -302,53 +302,51 @@ gimp_drawable_duplicate (GimpItem *item, ...@@ -302,53 +302,51 @@ gimp_drawable_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha) gboolean add_alpha)
{ {
GimpDrawable *drawable; GimpItem *new_item;
GimpItem *new_item;
GimpDrawable *new_drawable;
GimpImageType new_image_type;
PixelRegion srcPR;
PixelRegion destPR;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type, new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha); add_alpha);
if (! GIMP_IS_DRAWABLE (new_item)) if (GIMP_IS_DRAWABLE (new_item))
return new_item; {
GimpDrawable *drawable = GIMP_DRAWABLE (item);
drawable = GIMP_DRAWABLE (item); GimpDrawable *new_drawable = GIMP_DRAWABLE (new_item);
new_drawable = GIMP_DRAWABLE (new_item); GimpImageType new_image_type;
PixelRegion srcPR;
if (add_alpha) PixelRegion destPR;
new_image_type = gimp_drawable_type_with_alpha (drawable);
else if (add_alpha)
new_image_type = gimp_drawable_type (drawable); new_image_type = gimp_drawable_type_with_alpha (drawable);
else
new_image_type = gimp_drawable_type (drawable);
gimp_drawable_configure (new_drawable, gimp_drawable_configure (new_drawable,
gimp_item_get_image (GIMP_ITEM (drawable)), gimp_item_get_image (item),
item->offset_x, item->offset_x,
item->offset_y, item->offset_y,
item->width, item->width,
item->height, item->height,
new_image_type, new_image_type,
GIMP_OBJECT (new_drawable)->name); GIMP_OBJECT (new_drawable)->name);
pixel_region_init (&srcPR, drawable->tiles, pixel_region_init (&srcPR, drawable->tiles,
0, 0, 0, 0,
item->width, item->width,
item->height, item->height,
FALSE); FALSE);
pixel_region_init (&destPR, new_drawable->tiles, pixel_region_init (&destPR, new_drawable->tiles,
0, 0, 0, 0,
new_item->width, new_item->width,
new_item->height, new_item->height,
TRUE); TRUE);
if (new_image_type == drawable->type) if (new_image_type == drawable->type)
copy_region (&srcPR, &destPR); copy_region (&srcPR, &destPR);
else else
add_alpha_region (&srcPR, &destPR); add_alpha_region (&srcPR, &destPR);
}
return new_item; return new_item;
} }
......
...@@ -514,32 +514,31 @@ gimp_layer_duplicate (GimpItem *item, ...@@ -514,32 +514,31 @@ gimp_layer_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha) gboolean add_alpha)
{ {
GimpLayer *layer; GimpItem *new_item;
GimpItem *new_item;
GimpLayer *new_layer;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type, new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha); add_alpha);
if (! GIMP_IS_LAYER (new_item)) if (GIMP_IS_LAYER (new_item))
return new_item; {
GimpLayer *layer = GIMP_LAYER (item);;
layer = GIMP_LAYER (item); GimpLayer *new_layer = GIMP_LAYER (new_item);
new_layer = GIMP_LAYER (new_item);
new_layer->mode = layer->mode; new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity; new_layer->opacity = layer->opacity;
new_layer->lock_alpha = layer->lock_alpha; new_layer->lock_alpha = layer->lock_alpha;
/* duplicate the layer mask if necessary */ /* duplicate the layer mask if necessary */
if (layer->mask) if (layer->mask)
{ {
GimpItem *dup = gimp_item_duplicate (GIMP_ITEM (layer->mask), GimpItem *new_mask =
G_TYPE_FROM_INSTANCE (layer->mask), gimp_item_duplicate (GIMP_ITEM (layer->mask),
FALSE); G_TYPE_FROM_INSTANCE (layer->mask),
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (dup), FALSE); FALSE);
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (new_mask), FALSE);
}
} }
return new_item; return new_item;
......
...@@ -128,24 +128,22 @@ gimp_layer_mask_duplicate (GimpItem *item, ...@@ -128,24 +128,22 @@ gimp_layer_mask_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha) gboolean add_alpha)
{ {
GimpLayerMask *layer_mask; GimpItem *new_item;
GimpItem *new_item;
GimpLayerMask *new_layer_mask;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type, new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha); add_alpha);
if (! GIMP_IS_LAYER_MASK (new_item)) if (GIMP_IS_LAYER_MASK (new_item))
return new_item; {
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (item);
layer_mask = GIMP_LAYER_MASK (item); GimpLayerMask *new_layer_mask = GIMP_LAYER_MASK (new_item);
new_layer_mask = GIMP_LAYER_MASK (new_item);
new_layer_mask->apply_mask = layer_mask->apply_mask; new_layer_mask->apply_mask = layer_mask->apply_mask;
new_layer_mask->edit_mask = layer_mask->edit_mask; new_layer_mask->edit_mask = layer_mask->edit_mask;
new_layer_mask->show_mask = layer_mask->show_mask; new_layer_mask->show_mask = layer_mask->show_mask;
}
return new_item; return new_item;
} }
......
...@@ -244,9 +244,7 @@ gimp_text_layer_duplicate (GimpItem *item, ...@@ -244,9 +244,7 @@ gimp_text_layer_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha) gboolean add_alpha)
{ {
GimpTextLayer *layer; GimpItem *new_item;
GimpTextLayer *new_layer;
GimpItem *new_item;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
...@@ -254,27 +252,27 @@ gimp_text_layer_duplicate (GimpItem *item, ...@@ -254,27 +252,27 @@ gimp_text_layer_duplicate (GimpItem *item,
new_type, new_type,
add_alpha); add_alpha);
if (! GIMP_IS_TEXT_LAYER (new_item)) if (GIMP_IS_TEXT_LAYER (new_item))
return new_item; {
GimpTextLayer *layer = GIMP_TEXT_LAYER (item);
GimpTextLayer *new_layer = GIMP_TEXT_LAYER (new_item);
layer = GIMP_TEXT_LAYER (item); gimp_config_sync (G_OBJECT (layer), G_OBJECT (new_layer), 0);
new_layer = GIMP_TEXT_LAYER (new_item);
gimp_config_sync (G_OBJECT (layer), G_OBJECT (new_layer), 0); if (layer->text)
{
GimpText *text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
if (layer->text) gimp_text_layer_set_text (new_layer, text);
{
GimpText *text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
gimp_text_layer_set_text (new_layer, text); g_object_unref (text);
}
g_object_unref (text); /* this is just the parasite name, not a pointer to the parasite */
if (layer->text_parasite)
new_layer->text_parasite = layer->text_parasite;
} }
/* this is just the parasite name, not a pointer to the parasite */
if (layer->text_parasite)
new_layer->text_parasite = layer->text_parasite;
return new_item; return new_item;
} }
......
...@@ -274,22 +274,20 @@ gimp_vectors_duplicate (GimpItem *item, ...@@ -274,22 +274,20 @@ gimp_vectors_duplicate (GimpItem *item,
GType new_type, GType new_type,
gboolean add_alpha) gboolean add_alpha)
{ {
GimpVectors *vectors; GimpItem *new_item;
GimpItem *new_item;
GimpVectors *new_vectors;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL);
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type, new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha); add_alpha);
if (! GIMP_IS_VECTORS (new_item)) if (GIMP_IS_VECTORS (new_item))
return new_item; {
GimpVectors *vectors = GIMP_VECTORS (item);
vectors = GIMP_VECTORS (item); GimpVectors *new_vectors = GIMP_VECTORS (new_item);
new_vectors = GIMP_VECTORS (new_item);
gimp_vectors_copy_strokes (vectors, new_vectors); gimp_vectors_copy_strokes (vectors, new_vectors);
}
return new_item; return new_item;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment