[gimp/gimp-2-10] app: optimize gimp_layer_invalidate_boundary()



commit 1c66573f4c96e59a986854310e74d29ec9eed7ea
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 3 20:25:40 2019 +0100

    app: optimize gimp_layer_invalidate_boundary()
    
    Don't mess with the image's mask if the layer is not attached or not
    visible.

 app/core/gimplayer.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 6e3144389e..ff6f40838c 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1425,24 +1425,23 @@ gimp_layer_convert_type (GimpDrawable     *drawable,
 static void
 gimp_layer_invalidate_boundary (GimpDrawable *drawable)
 {
-  GimpLayer   *layer = GIMP_LAYER (drawable);
-  GimpImage   *image;
-  GimpChannel *mask;
+  GimpLayer *layer = GIMP_LAYER (drawable);
 
-  if (! (image = gimp_item_get_image (GIMP_ITEM (layer))))
-    return;
-
-  /*  Turn the current selection off  */
-  gimp_image_selection_invalidate (image);
+  if (gimp_item_is_attached (GIMP_ITEM (drawable)) &&
+      gimp_item_is_visible (GIMP_ITEM (drawable)))
+    {
+      GimpImage   *image = gimp_item_get_image (GIMP_ITEM (drawable));
+      GimpChannel *mask  = gimp_image_get_mask (image);
 
-  /*  get the selection mask channel  */
-  mask = gimp_image_get_mask (image);
+      /*  Turn the current selection off  */
+      gimp_image_selection_invalidate (image);
 
-  /*  Only bother with the bounds if there is a selection  */
-  if (! gimp_channel_is_empty (mask))
-    {
-      mask->bounds_known   = FALSE;
-      mask->boundary_known = FALSE;
+      /*  Only bother with the bounds if there is a selection  */
+      if (! gimp_channel_is_empty (mask))
+        {
+          mask->bounds_known   = FALSE;
+          mask->boundary_known = FALSE;
+        }
     }
 
   if (gimp_layer_is_floating_sel (layer))


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