Commit ac1c6d78 authored by Michael Natterer's avatar Michael Natterer 😴

app: add progress reporting to gimp_drawable_convert_type()

so it doesn't sit there appearing to do nothing while converting an
image with profile to gamma/linear.
parent 4e04e2ff
......@@ -143,7 +143,8 @@ static void gimp_channel_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
static void gimp_channel_invalidate_boundary (GimpDrawable *drawable);
static void gimp_channel_get_active_components (const GimpDrawable *drawable,
gboolean *active);
......@@ -556,7 +557,7 @@ gimp_channel_convert (GimpItem *item,
gimp_drawable_convert_type (drawable, dest_image, GIMP_GRAY,
gimp_image_get_precision (dest_image),
0, 0, FALSE,
FALSE);
FALSE, NULL);
}
if (gimp_drawable_has_alpha (drawable))
......@@ -899,7 +900,8 @@ gimp_channel_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
GeglBuffer *dest_buffer;
......
......@@ -155,7 +155,8 @@ static void gimp_drawable_real_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
static GeglBuffer * gimp_drawable_real_get_buffer (GimpDrawable *drawable);
static void gimp_drawable_real_set_buffer (GimpDrawable *drawable,
......@@ -791,7 +792,8 @@ gimp_drawable_real_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_type,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
GeglBuffer *dest_buffer;
......@@ -1259,7 +1261,8 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
const Babl *new_format;
......@@ -1268,6 +1271,7 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable) ||
new_precision != gimp_drawable_get_precision (drawable) ||
convert_profile);
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
......@@ -1284,7 +1288,11 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
layer_dither_type,
mask_dither_type,
convert_profile,
push_undo);
push_undo,
progress);
if (progress)
gimp_progress_set_value (progress, 1.0);
}
void
......
......@@ -69,7 +69,8 @@ struct _GimpDrawableClass
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
void (* apply_buffer) (GimpDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_region,
......@@ -146,7 +147,8 @@ void gimp_drawable_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
void gimp_drawable_apply_buffer (GimpDrawable *drawable,
GeglBuffer *buffer,
......
......@@ -144,7 +144,8 @@ static void gimp_group_layer_convert_type (GimpDrawable *drawabl
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
static const Babl * gimp_group_layer_get_format (GimpProjectable *projectable);
static GeglNode * gimp_group_layer_get_graph (GimpProjectable *projectable);
......@@ -883,7 +884,8 @@ gimp_group_layer_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
GimpGroupLayer *group = GIMP_GROUP_LAYER (drawable);
GimpGroupLayerPrivate *private = GET_PRIVATE (drawable);
......@@ -927,7 +929,7 @@ gimp_group_layer_convert_type (GimpDrawable *drawable,
GIMP_GRAY, new_precision,
layer_dither_type, mask_dither_type,
convert_profile,
push_undo);
push_undo, progress);
}
}
......
......@@ -129,7 +129,7 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
group_layer_undo->prev_type,
group_layer_undo->prev_precision,
0, 0, FALSE,
FALSE);
FALSE, NULL);
group_layer_undo->prev_type = type;
group_layer_undo->prev_precision = precision;
......
......@@ -37,6 +37,7 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpprogress.h"
#include "gimpsubprogress.h"
#include "text/gimptextlayer.h"
......@@ -56,7 +57,8 @@ gimp_image_convert_precision (GimpImage *image,
const Babl *new_format;
GList *all_drawables;
GList *list;
const gchar *undo_desc = NULL;
const gchar *undo_desc = NULL;
GimpProgress *sub_progress = NULL;
gint nth_drawable, n_drawables;
g_return_if_fail (GIMP_IS_IMAGE (image));
......@@ -70,6 +72,9 @@ gimp_image_convert_precision (GimpImage *image,
n_drawables = g_list_length (all_drawables) + 1 /* + selection */;
if (progress)
sub_progress = gimp_sub_progress_new (progress);
switch (precision)
{
case GIMP_PRECISION_U8_LINEAR:
......@@ -141,17 +146,17 @@ gimp_image_convert_precision (GimpImage *image,
else
dither_type = layer_dither_type;
if (sub_progress)
gimp_sub_progress_set_step (GIMP_SUB_PROGRESS (sub_progress),
nth_drawable, n_drawables);
gimp_drawable_convert_type (drawable, image,
gimp_drawable_get_base_type (drawable),
precision,
dither_type,
mask_dither_type,
old_profile != NULL,
TRUE);
if (progress)
gimp_progress_set_value (progress,
(gdouble) nth_drawable / (gdouble) n_drawables);
TRUE, sub_progress);
}
g_list_free (all_drawables);
......@@ -187,6 +192,10 @@ gimp_image_convert_precision (GimpImage *image,
GimpChannel *mask = gimp_image_get_mask (image);
GeglBuffer *buffer;
if (sub_progress)
gimp_sub_progress_set_step (GIMP_SUB_PROGRESS (sub_progress),
nth_drawable, n_drawables);
gimp_image_undo_push_mask_precision (image, NULL, mask);
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
......@@ -203,9 +212,8 @@ gimp_image_convert_precision (GimpImage *image,
nth_drawable++;
if (progress)
gimp_progress_set_value (progress,
(gdouble) nth_drawable / (gdouble) n_drawables);
if (sub_progress)
gimp_progress_set_value (sub_progress, 1.0);
}
gimp_image_undo_group_end (image);
......@@ -213,6 +221,9 @@ gimp_image_convert_precision (GimpImage *image,
gimp_image_precision_changed (image);
g_object_thaw_notify (G_OBJECT (image));
if (sub_progress)
g_object_unref (sub_progress);
if (progress)
gimp_progress_end (progress);
}
......@@ -1022,7 +1022,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, FALSE,
TRUE);
TRUE, NULL);
}
}
......
......@@ -174,7 +174,8 @@ static void gimp_layer_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_type,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
static void gimp_layer_invalidate_boundary (GimpDrawable *drawable);
static void gimp_layer_get_active_components (const GimpDrawable *drawable,
gboolean *active);
......@@ -812,7 +813,7 @@ gimp_layer_convert (GimpItem *item,
new_base_type, new_precision,
0, 0,
convert_profile,
FALSE);
FALSE, NULL);
}
if (layer->mask)
......@@ -1067,7 +1068,8 @@ gimp_layer_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
GimpLayer *layer = GIMP_LAYER (drawable);
GeglBuffer *src_buffer;
......@@ -1161,7 +1163,7 @@ gimp_layer_convert_type (GimpDrawable *drawable,
gimp_gegl_convert_color_profile (src_buffer, NULL, src_profile,
dest_buffer, NULL, dest_profile,
GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
TRUE, NULL);
TRUE, progress);
}
else
{
......@@ -1183,7 +1185,7 @@ gimp_layer_convert_type (GimpDrawable *drawable,
GIMP_GRAY, new_precision,
layer_dither_type, mask_dither_type,
convert_profile,
push_undo);
push_undo, NULL);
}
}
......
......@@ -57,7 +57,8 @@ static void gimp_layer_mask_convert_type (GimpDrawable *dr
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
G_DEFINE_TYPE (GimpLayerMask, gimp_layer_mask, GIMP_TYPE_CHANNEL)
......@@ -170,7 +171,8 @@ gimp_layer_mask_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
new_format = gimp_babl_mask_format (new_precision);
......@@ -181,7 +183,8 @@ gimp_layer_mask_convert_type (GimpDrawable *drawable,
layer_dither_type,
mask_dither_type,
convert_profile,
push_undo);
push_undo,
progress);
}
GimpLayerMask *
......
......@@ -89,7 +89,8 @@ static void gimp_selection_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
static void gimp_selection_invalidate_boundary (GimpDrawable *drawable);
static gboolean gimp_selection_boundary (GimpChannel *channel,
......@@ -311,7 +312,8 @@ gimp_selection_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
new_format = gimp_babl_mask_format (new_precision);
......@@ -322,7 +324,8 @@ gimp_selection_convert_type (GimpDrawable *drawable,
layer_dither_type,
mask_dither_type,
convert_profile,
push_undo);
push_undo,
progress);
}
static void
......
......@@ -92,7 +92,8 @@ static void gimp_text_layer_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo);
gboolean push_undo,
GimpProgress *progress);
static void gimp_text_layer_set_buffer (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
......@@ -320,7 +321,8 @@ gimp_text_layer_convert_type (GimpDrawable *drawable,
gint layer_dither_type,
gint mask_dither_type,
gboolean convert_profile,
gboolean push_undo)
gboolean push_undo,
GimpProgress *progress)
{
GimpTextLayer *layer = GIMP_TEXT_LAYER (drawable);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
......@@ -334,7 +336,8 @@ gimp_text_layer_convert_type (GimpDrawable *drawable,
layer_dither_type,
mask_dither_type,
convert_profile,
push_undo);
push_undo,
progress);
}
else
{
......
......@@ -274,7 +274,7 @@ gimp_text_undo_pop (GimpUndo *undo,
gimp_babl_format_get_base_type (text_undo->format),
gimp_babl_format_get_precision (text_undo->format),
0, 0, FALSE,
FALSE);
FALSE, NULL);
text_undo->format = format;
}
break;
......
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