Commit 58b4220b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Merged from HEAD branch:

2005-01-13  Michael Natterer  <mitch@gimp.org>

	Merged from HEAD branch:

	Splitting GimpItem::convert() into two virtual functions was
	apparently buggy over-engineering. Reverted that stuff and
	implement item conversion much simpler:

	* app/core/gimpitem.[ch]: have a single virtual function,
	GimpItem::convert(), which takes a newly duplicated item and the
	destination image.

	(gimp_item_convert): simply call GimpItem::convert() on the result
	of gimp_item_duplicate().

	(gimp_item_real_convert): set the item's new image.

	* app/core/gimplayer.c (gimp_layer_convert)
	* app/vectors/gimpvectors.c (gimp_vectors_convert): changed
	accordingly and chain up after, not before doing our own stuff
	so the old image is still available as item->image for stuff
	like colormap conversion. Fixes bug #163879.
parent 34bf50b0
2005-01-13 Michael Natterer <mitch@gimp.org>
Merged from HEAD branch:
Splitting GimpItem::convert() into two virtual functions was
apparently buggy over-engineering. Reverted that stuff and
implement item conversion much simpler:
* app/core/gimpitem.[ch]: have a single virtual function,
GimpItem::convert(), which takes a newly duplicated item and the
destination image.
(gimp_item_convert): simply call GimpItem::convert() on the result
of gimp_item_duplicate().
(gimp_item_real_convert): set the item's new image.
* app/core/gimplayer.c (gimp_layer_convert)
* app/vectors/gimpvectors.c (gimp_vectors_convert): changed
accordingly and chain up after, not before doing our own stuff
so the old image is still available as item->image for stuff
like colormap conversion. Fixes bug #163879.
2005-01-13 Michael Natterer <mitch@gimp.org>
Merged from HEAD branch:
......
......@@ -66,10 +66,8 @@ static gint64 gimp_item_get_memsize (GimpObject *object,
static GimpItem * gimp_item_real_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
static GimpItem * gimp_item_real_convert_from (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha);
static void gimp_item_real_convert (GimpItem *item,
GimpImage *dest_image);
static gboolean gimp_item_real_rename (GimpItem *item,
const gchar *new_name,
const gchar *undo_desc);
......@@ -176,8 +174,7 @@ gimp_item_class_init (GimpItemClass *klass)
klass->is_attached = NULL;
klass->duplicate = gimp_item_real_duplicate;
klass->convert_from = gimp_item_real_convert_from;
klass->convert_to = NULL;
klass->convert = gimp_item_real_convert;
klass->rename = gimp_item_real_rename;
klass->translate = gimp_item_real_translate;
klass->scale = gimp_item_real_scale;
......@@ -306,13 +303,11 @@ gimp_item_real_duplicate (GimpItem *item,
return new_item;
}
static GimpItem *
gimp_item_real_convert_from (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha)
static void
gimp_item_real_convert (GimpItem *item,
GimpImage *dest_image)
{
return gimp_item_duplicate (item, new_type, add_alpha);
gimp_item_set_image (item, dest_image);
}
static gboolean
......@@ -536,17 +531,10 @@ gimp_item_convert (GimpItem *item,
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_ITEM), NULL);
new_item = GIMP_ITEM_GET_CLASS (item)->convert_from (item, dest_image,
new_type, add_alpha);
new_item = gimp_item_duplicate (item, new_type, add_alpha);
if (new_item)
{
if (dest_image != item->gimage)
gimp_item_set_image (new_item, dest_image);
if (GIMP_ITEM_GET_CLASS (new_item)->convert_to)
GIMP_ITEM_GET_CLASS (new_item)->convert_to (new_item, item);
}
GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, dest_image);
return new_item;
}
......
......@@ -68,12 +68,8 @@ struct _GimpItemClass
GimpItem * (* duplicate) (GimpItem *item,
GType new_type,
gboolean add_alpha);
GimpItem * (* convert_from) (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha);
void (* convert_to) (GimpItem *item,
GimpItem *src_item);
void (* convert) (GimpItem *item,
GimpImage *dest_image);
gboolean (* rename) (GimpItem *item,
const gchar *new_name,
const gchar *undo_desc);
......
......@@ -79,8 +79,8 @@ static gboolean gimp_layer_is_attached (GimpItem *item);
static GimpItem * gimp_layer_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
static void gimp_layer_convert_to (GimpItem *item,
GimpItem *src_item);
static void gimp_layer_convert (GimpItem *item,
GimpImage *dest_image);
static gboolean gimp_layer_rename (GimpItem *item,
const gchar *new_name,
const gchar *undo_desc);
......@@ -239,7 +239,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
item_class->removed = gimp_layer_removed;
item_class->is_attached = gimp_layer_is_attached;
item_class->duplicate = gimp_layer_duplicate;
item_class->convert_to = gimp_layer_convert_to;
item_class->convert = gimp_layer_convert;
item_class->rename = gimp_layer_rename;
item_class->translate = gimp_layer_translate;
item_class->scale = gimp_layer_scale;
......@@ -487,19 +487,16 @@ gimp_layer_duplicate (GimpItem *item,
}
static void
gimp_layer_convert_to (GimpItem *item,
GimpItem *src_item)
gimp_layer_convert (GimpItem *item,
GimpImage *dest_image)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpImageBaseType old_base_type;
GimpImageBaseType new_base_type;
if (GIMP_ITEM_CLASS (parent_class)->convert_to)
GIMP_ITEM_CLASS (parent_class)->convert_to (item, src_item);
old_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
new_base_type = gimp_image_base_type (gimp_item_get_image (item));
new_base_type = gimp_image_base_type (dest_image);
if (old_base_type != new_base_type)
{
......@@ -560,8 +557,10 @@ gimp_layer_convert_to (GimpItem *item,
tile_manager_unref (new_tiles);
}
if (layer->mask && item->gimage != src_item->gimage)
gimp_item_set_image (GIMP_ITEM (layer->mask), item->gimage);
if (layer->mask)
gimp_item_set_image (GIMP_ITEM (layer->mask), dest_image);
GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
}
static gboolean
......
......@@ -69,10 +69,8 @@ static gboolean gimp_vectors_is_attached (GimpItem *item);
static GimpItem * gimp_vectors_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
static GimpItem * gimp_vectors_convert_from (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha);
static void gimp_vectors_convert (GimpItem *item,
GimpImage *dest_image);
static void gimp_vectors_translate (GimpItem *item,
gint offset_x,
gint offset_y,
......@@ -220,7 +218,7 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
item_class->is_attached = gimp_vectors_is_attached;
item_class->duplicate = gimp_vectors_duplicate;
item_class->convert_from = gimp_vectors_convert_from;
item_class->convert = gimp_vectors_convert;
item_class->translate = gimp_vectors_translate;
item_class->scale = gimp_vectors_scale;
item_class->resize = gimp_vectors_resize;
......@@ -332,29 +330,14 @@ gimp_vectors_duplicate (GimpItem *item,
return new_item;
}
static GimpItem *
gimp_vectors_convert_from (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha)
static void
gimp_vectors_convert (GimpItem *item,
GimpImage *dest_image)
{
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)->convert_from (item, dest_image,
new_type, add_alpha);
item->width = dest_image->width;
item->height = dest_image->height;
if (! GIMP_IS_VECTORS (new_item))
return new_item;
if (dest_image != item->gimage)
{
new_item->width = dest_image->width;
new_item->height = dest_image->height;
}
return new_item;
GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
}
static void
......
Supports Markdown
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