[gimp] app: add "gboolean convert_profile" to GimpDrawable::convert_type()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "gboolean convert_profile" to GimpDrawable::convert_type()
- Date: Sun, 16 Aug 2015 13:56:49 +0000 (UTC)
commit 76782e622dbc72f5287a14d5b05d0453b7fdd079
Author: Michael Natterer <mitch gimp org>
Date: Sun Aug 16 15:47:43 2015 +0200
app: add "gboolean convert_profile" to GimpDrawable::convert_type()
also add "GType old_type" to GimpItem::convert() so implementations
can do things depending on the type of the original item.
In gimp_layer_convert(), if the original item is also a layer, and
color management is not off (with a FIXME because this is the wrong
check), pass convert_profile = TRUE to gimp_drawable_convert_type().
There is no color profile conversion anywhere behind this, this is
just an API change commit.
app/core/gimpchannel.c | 12 ++++++++----
app/core/gimpdrawable.c | 15 +++++++--------
app/core/gimpdrawable.h | 2 ++
app/core/gimpgrouplayer.c | 14 ++++++++++----
app/core/gimpgrouplayerundo.c | 2 +-
app/core/gimpimage-convert-precision.c | 1 +
app/core/gimpimage-convert-type.c | 2 +-
app/core/gimpitem.c | 11 ++++++++---
app/core/gimpitem.h | 3 ++-
app/core/gimplayer.c | 28 ++++++++++++++++++++++++----
app/core/gimplayermask.c | 3 +++
app/core/gimpselection.c | 3 +++
app/text/gimptextlayer.c | 3 +++
app/text/gimptextundo.c | 3 ++-
app/vectors/gimpvectors.c | 8 +++++---
app/widgets/gimpchanneltreeview.c | 3 ++-
16 files changed, 82 insertions(+), 31 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 72b053d..5276fcb 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -85,7 +85,8 @@ static gboolean gimp_channel_bounds (GimpItem *item,
static GimpItem * gimp_channel_duplicate (GimpItem *item,
GType new_type);
static void gimp_channel_convert (GimpItem *item,
- GimpImage *dest_image);
+ GimpImage *dest_image,
+ GType old_type);
static void gimp_channel_translate (GimpItem *item,
gint off_x,
gint off_y,
@@ -141,6 +142,7 @@ static void gimp_channel_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
static void gimp_channel_invalidate_boundary (GimpDrawable *drawable);
static void gimp_channel_get_active_components (const GimpDrawable *drawable,
@@ -543,7 +545,8 @@ gimp_channel_duplicate (GimpItem *item,
static void
gimp_channel_convert (GimpItem *item,
- GimpImage *dest_image)
+ GimpImage *dest_image,
+ GType old_type)
{
GimpChannel *channel = GIMP_CHANNEL (item);
GimpDrawable *drawable = GIMP_DRAWABLE (item);
@@ -552,7 +555,7 @@ gimp_channel_convert (GimpItem *item,
{
gimp_drawable_convert_type (drawable, dest_image, GIMP_GRAY,
gimp_image_get_precision (dest_image),
- 0, 0,
+ 0, 0, FALSE,
FALSE);
}
@@ -598,7 +601,7 @@ gimp_channel_convert (GimpItem *item,
}
}
- GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
+ GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image, old_type);
}
static void
@@ -895,6 +898,7 @@ gimp_channel_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
GeglBuffer *dest_buffer;
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index dc78a83..360463c 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -154,6 +154,7 @@ static void gimp_drawable_real_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
static GeglBuffer * gimp_drawable_real_get_buffer (GimpDrawable *drawable);
@@ -789,21 +790,16 @@ gimp_drawable_real_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_type,
gboolean push_undo)
{
GeglBuffer *dest_buffer;
- const Babl *format;
-
- format = gimp_image_get_format (dest_image,
- new_base_type,
- new_precision,
- gimp_drawable_has_alpha (drawable));
dest_buffer =
gegl_buffer_new (GEGL_RECTANGLE (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
- format);
+ new_format);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL, GEGL_ABYSS_NONE,
dest_buffer, NULL);
@@ -1262,6 +1258,7 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
const Babl *new_format;
@@ -1269,7 +1266,8 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable) ||
- new_precision != gimp_drawable_get_precision (drawable));
+ new_precision != gimp_drawable_get_precision (drawable) ||
+ convert_profile);
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
@@ -1285,6 +1283,7 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
new_precision,
layer_dither_type,
mask_dither_type,
+ convert_profile,
push_undo);
}
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 3a45bf3..2016d80 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -68,6 +68,7 @@ struct _GimpDrawableClass
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
void (* apply_buffer) (GimpDrawable *drawable,
GeglBuffer *buffer,
@@ -144,6 +145,7 @@ void gimp_drawable_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
void gimp_drawable_apply_buffer (GimpDrawable *drawable,
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 25ee110..8ddb4b9 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -94,7 +94,8 @@ static gboolean gimp_group_layer_is_position_locked (const GimpItem *item);
static GimpItem * gimp_group_layer_duplicate (GimpItem *item,
GType new_type);
static void gimp_group_layer_convert (GimpItem *item,
- GimpImage *dest_image);
+ GimpImage *dest_image,
+ GType old_type);
static void gimp_group_layer_translate (GimpItem *item,
gint offset_x,
gint offset_y,
@@ -142,6 +143,7 @@ static void gimp_group_layer_convert_type (GimpDrawable *drawabl
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
static const Babl * gimp_group_layer_get_format (GimpProjectable *projectable);
@@ -493,7 +495,8 @@ gimp_group_layer_duplicate (GimpItem *item,
static void
gimp_group_layer_convert (GimpItem *item,
- GimpImage *dest_image)
+ GimpImage *dest_image,
+ GType old_type)
{
GimpGroupLayerPrivate *private = GET_PRIVATE (item);
GList *list;
@@ -504,10 +507,11 @@ gimp_group_layer_convert (GimpItem *item,
{
GimpItem *child = list->data;
- GIMP_ITEM_GET_CLASS (child)->convert (child, dest_image);
+ GIMP_ITEM_GET_CLASS (child)->convert (child, dest_image,
+ G_TYPE_FROM_INSTANCE (child));
}
- GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
+ GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image, old_type);
}
static void
@@ -878,6 +882,7 @@ gimp_group_layer_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
GimpGroupLayer *group = GIMP_GROUP_LAYER (drawable);
@@ -921,6 +926,7 @@ gimp_group_layer_convert_type (GimpDrawable *drawable,
gimp_drawable_convert_type (GIMP_DRAWABLE (mask), dest_image,
GIMP_GRAY, new_precision,
layer_dither_type, mask_dither_type,
+ convert_profile,
push_undo);
}
}
diff --git a/app/core/gimpgrouplayerundo.c b/app/core/gimpgrouplayerundo.c
index 1df9dae..9703afa 100644
--- a/app/core/gimpgrouplayerundo.c
+++ b/app/core/gimpgrouplayerundo.c
@@ -128,7 +128,7 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
gimp_item_get_image (GIMP_ITEM (group)),
group_layer_undo->prev_type,
group_layer_undo->prev_precision,
- 0, 0,
+ 0, 0, FALSE,
FALSE);
group_layer_undo->prev_type = type;
diff --git a/app/core/gimpimage-convert-precision.c b/app/core/gimpimage-convert-precision.c
index 9d0e02d..a3ed0c8 100644
--- a/app/core/gimpimage-convert-precision.c
+++ b/app/core/gimpimage-convert-precision.c
@@ -134,6 +134,7 @@ gimp_image_convert_precision (GimpImage *image,
precision,
dither_type,
mask_dither_type,
+ FALSE,
TRUE);
if (progress)
diff --git a/app/core/gimpimage-convert-type.c b/app/core/gimpimage-convert-type.c
index 217ec20..1cc8e07 100644
--- a/app/core/gimpimage-convert-type.c
+++ b/app/core/gimpimage-convert-type.c
@@ -1021,7 +1021,7 @@ gimp_image_convert_type (GimpImage *image,
{
gimp_drawable_convert_type (GIMP_DRAWABLE (layer), image, new_type,
gimp_drawable_get_precision (GIMP_DRAWABLE (layer)),
- 0, 0,
+ 0, 0, FALSE,
TRUE);
}
}
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 1de871a..4a17812 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -133,7 +133,8 @@ static gboolean gimp_item_real_bounds (GimpItem *item,
static GimpItem * gimp_item_real_duplicate (GimpItem *item,
GType new_type);
static void gimp_item_real_convert (GimpItem *item,
- GimpImage *dest_image);
+ GimpImage *dest_image,
+ GType old_type);
static gboolean gimp_item_real_rename (GimpItem *item,
const gchar *new_name,
const gchar *undo_desc,
@@ -583,7 +584,8 @@ gimp_item_real_duplicate (GimpItem *item,
static void
gimp_item_real_convert (GimpItem *item,
- GimpImage *dest_image)
+ GimpImage *dest_image,
+ GType old_type)
{
gimp_item_set_image (item, dest_image);
}
@@ -990,16 +992,19 @@ gimp_item_convert (GimpItem *item,
GType new_type)
{
GimpItem *new_item;
+ GType old_type;
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (GET_PRIVATE (item)->image), NULL);
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);
+ old_type = G_TYPE_FROM_INSTANCE (item);
+
new_item = gimp_item_duplicate (item, new_type);
if (new_item)
- GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, dest_image);
+ GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, dest_image, old_type);
return new_item;
}
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index 8a567d2..878574e 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -62,7 +62,8 @@ struct _GimpItemClass
GimpItem * (* duplicate) (GimpItem *item,
GType new_type);
void (* convert) (GimpItem *item,
- GimpImage *dest_image);
+ GimpImage *dest_image,
+ GType old_type);
gboolean (* rename) (GimpItem *item,
const gchar *new_name,
const gchar *undo_desc,
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index e6a2ec5..b4c15f3 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -26,13 +26,17 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
#include "core-types.h"
+#include "config/gimpcoreconfig.h" /* FIXME profile convert config */
+
#include "gegl/gimp-gegl-apply-operation.h"
#include "gegl/gimp-gegl-nodes.h"
+#include "gimp.h" /* FIXME profile convert config */
#include "gimpboundary.h"
#include "gimpchannel-select.h"
#include "gimpcontext.h"
@@ -105,7 +109,8 @@ static GimpItemTree * gimp_layer_get_tree (GimpItem *item);
static GimpItem * gimp_layer_duplicate (GimpItem *item,
GType new_type);
static void gimp_layer_convert (GimpItem *item,
- GimpImage *dest_image);
+ GimpImage *dest_image,
+ GType old_type);
static gboolean gimp_layer_rename (GimpItem *item,
const gchar *new_name,
const gchar *undo_desc,
@@ -163,6 +168,7 @@ static void gimp_layer_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_type,
gboolean push_undo);
static void gimp_layer_invalidate_boundary (GimpDrawable *drawable);
static void gimp_layer_get_active_components (const GimpDrawable *drawable,
@@ -743,14 +749,18 @@ gimp_layer_duplicate (GimpItem *item,
static void
gimp_layer_convert (GimpItem *item,
- GimpImage *dest_image)
+ GimpImage *dest_image,
+ GType old_type)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpDrawable *drawable = GIMP_DRAWABLE (item);
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
+ GimpColorConfig *config = image->gimp->config->color_management;
GimpImageBaseType old_base_type;
GimpImageBaseType new_base_type;
GimpPrecision old_precision;
GimpPrecision new_precision;
+ gboolean convert_profile;
old_base_type = gimp_drawable_get_base_type (drawable);
new_base_type = gimp_image_get_base_type (dest_image);
@@ -758,19 +768,27 @@ gimp_layer_convert (GimpItem *item,
old_precision = gimp_drawable_get_precision (drawable);
new_precision = gimp_image_get_precision (dest_image);
+ convert_profile = (g_type_is_a (old_type, GIMP_TYPE_LAYER) &&
+ /* FIXME: this is the wrong check, need
+ * something like file import conversion config
+ */
+ (config->mode != GIMP_COLOR_MANAGEMENT_OFF));
+
if (old_base_type != new_base_type ||
- old_precision != new_precision)
+ old_precision != new_precision ||
+ convert_profile)
{
gimp_drawable_convert_type (drawable, dest_image,
new_base_type, new_precision,
0, 0,
+ convert_profile,
FALSE);
}
if (layer->mask)
gimp_item_set_image (GIMP_ITEM (layer->mask), dest_image);
- GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
+ GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image, old_type);
}
static gboolean
@@ -1005,6 +1023,7 @@ gimp_layer_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
GimpLayer *layer = GIMP_LAYER (drawable);
@@ -1043,6 +1062,7 @@ gimp_layer_convert_type (GimpDrawable *drawable,
gimp_drawable_convert_type (GIMP_DRAWABLE (layer->mask), dest_image,
GIMP_GRAY, new_precision,
layer_dither_type, mask_dither_type,
+ convert_profile,
push_undo);
}
}
diff --git a/app/core/gimplayermask.c b/app/core/gimplayermask.c
index cc6d740..f5dc8cd 100644
--- a/app/core/gimplayermask.c
+++ b/app/core/gimplayermask.c
@@ -56,6 +56,7 @@ static void gimp_layer_mask_convert_type (GimpDrawable *dr
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
@@ -168,6 +169,7 @@ gimp_layer_mask_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
new_format = gimp_babl_mask_format (new_precision);
@@ -178,6 +180,7 @@ gimp_layer_mask_convert_type (GimpDrawable *drawable,
new_precision,
layer_dither_type,
mask_dither_type,
+ convert_profile,
push_undo);
}
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index a0b4c0f..071991e 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -88,6 +88,7 @@ static void gimp_selection_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
static void gimp_selection_invalidate_boundary (GimpDrawable *drawable);
@@ -309,6 +310,7 @@ gimp_selection_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
new_format = gimp_babl_mask_format (new_precision);
@@ -319,6 +321,7 @@ gimp_selection_convert_type (GimpDrawable *drawable,
new_precision,
layer_dither_type,
mask_dither_type,
+ convert_profile,
push_undo);
}
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index 24a3219..9d2cf07 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -91,6 +91,7 @@ static void gimp_text_layer_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo);
static void gimp_text_layer_set_buffer (GimpDrawable *drawable,
gboolean push_undo,
@@ -318,6 +319,7 @@ gimp_text_layer_convert_type (GimpDrawable *drawable,
GimpPrecision new_precision,
gint layer_dither_type,
gint mask_dither_type,
+ gboolean convert_profile,
gboolean push_undo)
{
GimpTextLayer *layer = GIMP_TEXT_LAYER (drawable);
@@ -331,6 +333,7 @@ gimp_text_layer_convert_type (GimpDrawable *drawable,
new_precision,
layer_dither_type,
mask_dither_type,
+ convert_profile,
push_undo);
}
else
diff --git a/app/text/gimptextundo.c b/app/text/gimptextundo.c
index 815d1d1..56cbdde 100644
--- a/app/text/gimptextundo.c
+++ b/app/text/gimptextundo.c
@@ -273,7 +273,8 @@ gimp_text_undo_pop (GimpUndo *undo,
gimp_item_get_image (GIMP_ITEM (layer)),
gimp_babl_format_get_base_type (text_undo->format),
gimp_babl_format_get_precision (text_undo->format),
- 0, 0, FALSE);
+ 0, 0, FALSE,
+ FALSE);
text_undo->format = format;
}
break;
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index d9c98e1..d1d75ae 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -77,7 +77,8 @@ static gboolean gimp_vectors_bounds (GimpItem *item,
static GimpItem * gimp_vectors_duplicate (GimpItem *item,
GType new_type);
static void gimp_vectors_convert (GimpItem *item,
- GimpImage *dest_image);
+ GimpImage *dest_image,
+ GType old_type);
static void gimp_vectors_translate (GimpItem *item,
gint offset_x,
gint offset_y,
@@ -411,13 +412,14 @@ gimp_vectors_duplicate (GimpItem *item,
static void
gimp_vectors_convert (GimpItem *item,
- GimpImage *dest_image)
+ GimpImage *dest_image,
+ GType old_type)
{
gimp_item_set_size (item,
gimp_image_get_width (dest_image),
gimp_image_get_height (dest_image));
- GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
+ GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image, old_type);
}
static void
diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c
index e956fa8..aabfe08 100644
--- a/app/widgets/gimpchanneltreeview.c
+++ b/app/widgets/gimpchanneltreeview.c
@@ -269,7 +269,8 @@ gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
g_free (name);
if (src_image != image)
- GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, image);
+ GIMP_ITEM_GET_CLASS (new_item)->convert (new_item, image,
+ GIMP_TYPE_CHANNEL);
gimp_image_add_channel (image, GIMP_CHANNEL (new_item), parent, index, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]