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>
* app/vectors/gimpbezierstroke.c
......
......@@ -377,9 +377,7 @@ gimp_channel_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpChannel *channel;
GimpItem *new_item;
GimpChannel *new_channel;
GimpItem *new_item;
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
......@@ -389,22 +387,22 @@ gimp_channel_duplicate (GimpItem *item,
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
add_alpha);
if (! GIMP_IS_CHANNEL (new_item))
return new_item;
channel = GIMP_CHANNEL (item);
new_channel = GIMP_CHANNEL (new_item);
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
new_channel->bounds_known = channel->bounds_known;
new_channel->empty = channel->empty;
new_channel->x1 = channel->x1;
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
if (GIMP_IS_CHANNEL (new_item))
{
GimpChannel *channel = GIMP_CHANNEL (item);
GimpChannel *new_channel = GIMP_CHANNEL (new_item);
new_channel->color = channel->color;
new_channel->show_masked = channel->show_masked;
/* selection mask variables */
new_channel->bounds_known = channel->bounds_known;
new_channel->empty = channel->empty;
new_channel->x1 = channel->x1;
new_channel->y1 = channel->y1;
new_channel->x2 = channel->x2;
new_channel->y2 = channel->y2;
}
return new_item;
}
......
......@@ -302,53 +302,51 @@ gimp_drawable_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpDrawable *drawable;
GimpItem *new_item;
GimpDrawable *new_drawable;
GimpImageType new_image_type;
PixelRegion srcPR;
PixelRegion destPR;
GimpItem *new_item;
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,
add_alpha);
if (! GIMP_IS_DRAWABLE (new_item))
return new_item;
drawable = GIMP_DRAWABLE (item);
new_drawable = GIMP_DRAWABLE (new_item);
if (add_alpha)
new_image_type = gimp_drawable_type_with_alpha (drawable);
else
new_image_type = gimp_drawable_type (drawable);
if (GIMP_IS_DRAWABLE (new_item))
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpDrawable *new_drawable = GIMP_DRAWABLE (new_item);
GimpImageType new_image_type;
PixelRegion srcPR;
PixelRegion destPR;
if (add_alpha)
new_image_type = gimp_drawable_type_with_alpha (drawable);
else
new_image_type = gimp_drawable_type (drawable);
gimp_drawable_configure (new_drawable,
gimp_item_get_image (GIMP_ITEM (drawable)),
item->offset_x,
item->offset_y,
item->width,
item->height,
new_image_type,
GIMP_OBJECT (new_drawable)->name);
gimp_drawable_configure (new_drawable,
gimp_item_get_image (item),
item->offset_x,
item->offset_y,
item->width,
item->height,
new_image_type,
GIMP_OBJECT (new_drawable)->name);
pixel_region_init (&srcPR, drawable->tiles,
0, 0,
item->width,
item->height,
FALSE);
pixel_region_init (&destPR, new_drawable->tiles,
0, 0,
new_item->width,
new_item->height,
TRUE);
pixel_region_init (&srcPR, drawable->tiles,
0, 0,
item->width,
item->height,
FALSE);
pixel_region_init (&destPR, new_drawable->tiles,
0, 0,
new_item->width,
new_item->height,
TRUE);
if (new_image_type == drawable->type)
copy_region (&srcPR, &destPR);
else
add_alpha_region (&srcPR, &destPR);
if (new_image_type == drawable->type)
copy_region (&srcPR, &destPR);
else
add_alpha_region (&srcPR, &destPR);
}
return new_item;
}
......
......@@ -514,32 +514,31 @@ gimp_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpLayer *layer;
GimpItem *new_item;
GimpLayer *new_layer;
GimpItem *new_item;
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,
add_alpha);
if (! GIMP_IS_LAYER (new_item))
return new_item;
layer = GIMP_LAYER (item);
new_layer = GIMP_LAYER (new_item);
if (GIMP_IS_LAYER (new_item))
{
GimpLayer *layer = GIMP_LAYER (item);;
GimpLayer *new_layer = GIMP_LAYER (new_item);
new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity;
new_layer->lock_alpha = layer->lock_alpha;
new_layer->mode = layer->mode;
new_layer->opacity = layer->opacity;
new_layer->lock_alpha = layer->lock_alpha;
/* duplicate the layer mask if necessary */
if (layer->mask)
{
GimpItem *dup = gimp_item_duplicate (GIMP_ITEM (layer->mask),
G_TYPE_FROM_INSTANCE (layer->mask),
FALSE);
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (dup), FALSE);
/* duplicate the layer mask if necessary */
if (layer->mask)
{
GimpItem *new_mask =
gimp_item_duplicate (GIMP_ITEM (layer->mask),
G_TYPE_FROM_INSTANCE (layer->mask),
FALSE);
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (new_mask), FALSE);
}
}
return new_item;
......
......@@ -128,24 +128,22 @@ gimp_layer_mask_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpLayerMask *layer_mask;
GimpItem *new_item;
GimpLayerMask *new_layer_mask;
GimpItem *new_item;
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,
add_alpha);
if (! GIMP_IS_LAYER_MASK (new_item))
return new_item;
layer_mask = GIMP_LAYER_MASK (item);
new_layer_mask = GIMP_LAYER_MASK (new_item);
if (GIMP_IS_LAYER_MASK (new_item))
{
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (item);
GimpLayerMask *new_layer_mask = GIMP_LAYER_MASK (new_item);
new_layer_mask->apply_mask = layer_mask->apply_mask;
new_layer_mask->edit_mask = layer_mask->edit_mask;
new_layer_mask->show_mask = layer_mask->show_mask;
new_layer_mask->apply_mask = layer_mask->apply_mask;
new_layer_mask->edit_mask = layer_mask->edit_mask;
new_layer_mask->show_mask = layer_mask->show_mask;
}
return new_item;
}
......
......@@ -244,9 +244,7 @@ gimp_text_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpTextLayer *layer;
GimpTextLayer *new_layer;
GimpItem *new_item;
GimpItem *new_item;
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,
new_type,
add_alpha);
if (! GIMP_IS_TEXT_LAYER (new_item))
return new_item;
if (GIMP_IS_TEXT_LAYER (new_item))
{
GimpTextLayer *layer = GIMP_TEXT_LAYER (item);
GimpTextLayer *new_layer = GIMP_TEXT_LAYER (new_item);
layer = GIMP_TEXT_LAYER (item);
new_layer = GIMP_TEXT_LAYER (new_item);
gimp_config_sync (G_OBJECT (layer), G_OBJECT (new_layer), 0);
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)
{
GimpText *text = gimp_config_duplicate (GIMP_CONFIG (layer->text));
gimp_text_layer_set_text (new_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;
}
......
......@@ -274,22 +274,20 @@ gimp_vectors_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpVectors *vectors;
GimpItem *new_item;
GimpVectors *new_vectors;
GimpItem *new_item;
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,
add_alpha);
if (! GIMP_IS_VECTORS (new_item))
return new_item;
vectors = GIMP_VECTORS (item);
new_vectors = GIMP_VECTORS (new_item);
if (GIMP_IS_VECTORS (new_item))
{
GimpVectors *vectors = GIMP_VECTORS (item);
GimpVectors *new_vectors = GIMP_VECTORS (new_item);
gimp_vectors_copy_strokes (vectors, new_vectors);
gimp_vectors_copy_strokes (vectors, new_vectors);
}
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