[gimp/gimp-2-10] plug-ins: also omit hidden layer groups in PDF export.



commit b17b33e2e2a3f4312560c513c41563f15d17af40
Author: Jehan <jehan girinstud io>
Date:   Wed Jan 1 18:40:52 2020 +0100

    plug-ins: also omit hidden layer groups in PDF export.
    
    When the "Omit hidden layers and layers with zero opacity" option is
    set, this property was only checked on non-group layers. So if we had
    non-hidden layers inside hidden layer groups, they ended up exported,
    which is not the expected behavior.
    
    See https://gitlab.gnome.org/GNOME/gimp/issues/4425#note_675350
    
    (cherry picked from commit 24a0b0c53a91ec62144895badc121a5e3ab930ca)

 plug-ins/common/file-pdf-save.c | 128 ++++++++++++++++++++--------------------
 1 file changed, 64 insertions(+), 64 deletions(-)
---
diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c
index 42c073d400..954f1b4411 100644
--- a/plug-ins/common/file-pdf-save.c
+++ b/plug-ins/common/file-pdf-save.c
@@ -1673,13 +1673,19 @@ draw_layer (gint32       *layers,
             const gchar  *name,
             GError      **error)
 {
-  gint32 layer_ID;
+  gint32  layer_ID;
+  gdouble opacity;
 
   if (optimize.reverse_order && optimize.layers_as_pages)
     layer_ID = layers [j];
   else
     layer_ID = layers [n_layers - j - 1];
 
+  opacity = gimp_layer_get_opacity (layer_ID) / 100.0;
+  if ((! gimp_item_get_visible (layer_ID) || opacity == 0.0) &&
+      optimize.ignore_hidden)
+    return TRUE;
+
   if (gimp_item_is_group (layer_ID))
     {
       gint *children;
@@ -1702,86 +1708,80 @@ draw_layer (gint32       *layers,
     {
       cairo_surface_t *mask_image = NULL;
       gint32           mask_ID    = -1;
-      gdouble          opacity;
+      gint             x, y;
 
-      opacity = gimp_layer_get_opacity (layer_ID) / 100.0;
+      mask_ID = gimp_layer_get_mask (layer_ID);
+      if (mask_ID != -1)
+        {
+          mask_image = get_cairo_surface (mask_ID, TRUE, error);
 
-      if ((gimp_item_get_visible (layer_ID) && opacity > 0.0) ||
-          ! optimize.ignore_hidden)
+          if (*error)
+            return FALSE;
+        }
+
+      gimp_drawable_offsets (layer_ID, &x, &y);
+
+      if (! gimp_item_is_text_layer (layer_ID))
         {
-          gint x, y;
+          /* For raster layers */
+          GimpRGB  layer_color;
+          gboolean single_color = FALSE;
 
-          mask_ID = gimp_layer_get_mask (layer_ID);
-          if (mask_ID != -1)
-            {
-              mask_image = get_cairo_surface (mask_ID, TRUE, error);
+          layer_color = get_layer_color (layer_ID, &single_color);
 
-              if (*error)
-                return FALSE;
-            }
-          gimp_drawable_offsets (layer_ID, &x, &y);
+          cairo_rectangle (cr, x, y,
+                           gimp_drawable_width (layer_ID),
+                           gimp_drawable_height (layer_ID));
 
-          if (! gimp_item_is_text_layer (layer_ID))
+          if (optimize.vectorize && single_color)
             {
-              /* For raster layers */
-
-              GimpRGB  layer_color;
-              gboolean single_color = FALSE;
-
-              layer_color = get_layer_color (layer_ID, &single_color);
-
-              cairo_rectangle (cr, x, y,
-                               gimp_drawable_width (layer_ID),
-                               gimp_drawable_height (layer_ID));
-
-              if (optimize.vectorize && single_color)
-                {
-                  cairo_set_source_rgba (cr,
-                                         layer_color.r,
-                                         layer_color.g,
-                                         layer_color.b,
-                                         layer_color.a * opacity);
-                  if (mask_ID != -1)
-                    cairo_mask_surface (cr, mask_image, x, y);
-                  else
-                    cairo_fill (cr);
-                }
+              cairo_set_source_rgba (cr,
+                                     layer_color.r,
+                                     layer_color.g,
+                                     layer_color.b,
+                                     layer_color.a * opacity);
+              if (mask_ID != -1)
+                cairo_mask_surface (cr, mask_image, x, y);
               else
-                {
-                  cairo_surface_t *layer_image;
+                cairo_fill (cr);
+            }
+          else
+            {
+              cairo_surface_t *layer_image;
 
-                  layer_image = get_cairo_surface (layer_ID, FALSE, error);
+              layer_image = get_cairo_surface (layer_ID, FALSE, error);
 
-                  if (*error)
-                    return FALSE;
+              if (*error)
+                return FALSE;
 
-                  cairo_clip (cr);
+              cairo_clip (cr);
 
-                  cairo_set_source_surface (cr, layer_image, x, y);
-                  cairo_push_group (cr);
-                  cairo_paint_with_alpha (cr, opacity);
-                  cairo_pop_group_to_source (cr);
+              cairo_set_source_surface (cr, layer_image, x, y);
+              cairo_push_group (cr);
+              cairo_paint_with_alpha (cr, opacity);
+              cairo_pop_group_to_source (cr);
 
-                  if (mask_ID != -1)
-                    cairo_mask_surface (cr, mask_image, x, y);
-                  else
-                    cairo_paint (cr);
+              if (mask_ID != -1)
+                cairo_mask_surface (cr, mask_image, x, y);
+              else
+                cairo_paint (cr);
 
-                  cairo_reset_clip (cr);
+              cairo_reset_clip (cr);
 
-                  cairo_surface_destroy (layer_image);
-                }
-            }
-          else
-            {
-              /* For text layers */
-              drawText (layer_ID, opacity, cr, x_res, y_res);
+              cairo_surface_destroy (layer_image);
             }
-          /* draw new page if "layers as pages" option is checked */
-          if (optimize.layers_as_pages &&
-              g_strcmp0 (name, SAVE2_PROC) == 0)
-            cairo_show_page (cr);
         }
+      else
+        {
+          /* For text layers */
+          drawText (layer_ID, opacity, cr, x_res, y_res);
+        }
+
+      /* draw new page if "layers as pages" option is checked */
+      if (optimize.layers_as_pages &&
+          g_strcmp0 (name, SAVE2_PROC) == 0)
+        cairo_show_page (cr);
+
       /* We are done with the layer - time to free some resources */
       if (mask_ID != -1)
         cairo_surface_destroy (mask_image);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]