plug-ins: improve a bit PDF export progression.

Subdivise progression steps inside layer groups.

It is not perfect yet as it would not handle perfectly weird edge cases
where you have for instance a lot of layers in a top layer group with
only many other top layers. But it would still handle it better than
before. Ideally we should simply count all non-group "leaf" layers in
the layer tree and use this as the number of steps. In other words, we
should do a first pass through the whole layer tree.
This commit is contained in:
Jehan 2021-02-15 22:21:30 +01:00
parent 708bdf325a
commit e88107153c
1 changed files with 20 additions and 7 deletions

View File

@ -284,6 +284,9 @@ static gboolean draw_layer (GimpLayer **layers,
gdouble x_res, gdouble x_res,
gdouble y_res, gdouble y_res,
const gchar *name, const gchar *name,
gboolean show_progress,
gdouble progress_start,
gdouble progress_end,
GError **error); GError **error);
@ -855,14 +858,14 @@ pdf_save_image (GimpProcedure *procedure,
/* Now, we should loop over the layers of each image */ /* Now, we should loop over the layers of each image */
for (j = 0; j < n_layers; j++) for (j = 0; j < n_layers; j++)
{ {
if (show_progress)
/* Progression is showed per image, and would restart at 0
* if you open several images.
*/
gimp_progress_update ((gdouble) j / n_layers);
if (! draw_layer (layers, n_layers, j, cr, x_res, y_res, if (! draw_layer (layers, n_layers, j, cr, x_res, y_res,
gimp_procedure_get_name (procedure), gimp_procedure_get_name (procedure),
show_progress,
/* Progression is showed per image, and would restart at 0
* if you open several images.
*/
(gdouble) j / n_layers,
(gdouble) (j + 1) / n_layers,
&error)) &error))
{ {
/* free the resources */ /* free the resources */
@ -1916,6 +1919,9 @@ draw_layer (GimpLayer **layers,
gdouble x_res, gdouble x_res,
gdouble y_res, gdouble y_res,
const gchar *name, const gchar *name,
gboolean show_progress,
gdouble progress_start,
gdouble progress_end,
GError **error) GError **error)
{ {
GimpLayer *layer; GimpLayer *layer;
@ -1941,7 +1947,11 @@ draw_layer (GimpLayer **layers,
for (i = 0; i < children_num; i++) for (i = 0; i < children_num; i++)
{ {
if (! draw_layer ((GimpLayer **) children, children_num, i, if (! draw_layer ((GimpLayer **) children, children_num, i,
cr, x_res, y_res, name, error)) cr, x_res, y_res, name,
show_progress,
progress_start + i * (progress_end - progress_start) / children_num,
progress_end,
error))
{ {
g_free (children); g_free (children);
return FALSE; return FALSE;
@ -1955,6 +1965,9 @@ draw_layer (GimpLayer **layers,
GimpLayerMask *mask = NULL; GimpLayerMask *mask = NULL;
gint x, y; gint x, y;
if (show_progress)
gimp_progress_update (progress_start);
mask = gimp_layer_get_mask (layer); mask = gimp_layer_get_mask (layer);
if (mask) if (mask)
{ {