[gimp/gimp-2-10] app: implement GimpDrawable::get_bounding_box() for GimpLayer



commit ea27923868a8b8113f5872ca1b546fa4ad1ebfe2
Author: Ell <ell_se yahoo com>
Date:   Thu Aug 1 22:14:31 2019 +0300

    app: implement GimpDrawable::get_bounding_box() for GimpLayer
    
    Implement GimpDrawable::get_bounding_box() for GimpLayer, by
    returning the bounding box of its source node.  If the layer has a
    mask, we simply return its logical boundary, since the layer can't
    extend past the mask.
    
    (cherry picked from commit 7a05d15f7e021161b7635ab9478a2eeb45ad0b26)

 app/core/gimplayer.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index e966634a60..62a4c86248 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -201,6 +201,8 @@ static void    gimp_layer_set_buffer            (GimpDrawable       *drawable,
                                                  const gchar        *undo_desc,
                                                  GeglBuffer         *buffer,
                                                  const GeglRectangle *bounds);
+static GeglRectangle
+               gimp_layer_get_bounding_box      (GimpDrawable       *drawable);
 
 static GimpColorProfile *
                gimp_layer_get_color_profile     (GimpColorManaged   *managed);
@@ -460,6 +462,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
   drawable_class->get_active_components = gimp_layer_get_active_components;
   drawable_class->get_active_mask       = gimp_layer_get_active_mask;
   drawable_class->set_buffer            = gimp_layer_set_buffer;
+  drawable_class->get_bounding_box      = gimp_layer_get_bounding_box;
 
   klass->opacity_changed              = NULL;
   klass->mode_changed                 = NULL;
@@ -1499,6 +1502,17 @@ gimp_layer_set_buffer (GimpDrawable        *drawable,
     }
 }
 
+static GeglRectangle
+gimp_layer_get_bounding_box (GimpDrawable *drawable)
+{
+  GimpLayer *layer = GIMP_LAYER (drawable);
+
+  if (gimp_layer_get_mask (layer))
+    return GIMP_DRAWABLE_CLASS (parent_class)->get_bounding_box (drawable);
+
+  return gegl_node_get_bounding_box (gimp_drawable_get_source_node (drawable));
+}
+
 static GimpColorProfile *
 gimp_layer_get_color_profile (GimpColorManaged *managed)
 {
@@ -1866,6 +1880,8 @@ gimp_layer_add_mask (GimpLayer      *layer,
       gimp_layer_update_mode_node (layer);
     }
 
+  gimp_drawable_update_bounding_box (GIMP_DRAWABLE (layer));
+
   if (gimp_layer_get_apply_mask (layer) ||
       gimp_layer_get_show_mask (layer))
     {
@@ -2183,6 +2199,8 @@ gimp_layer_apply_mask (GimpLayer         *layer,
       gimp_layer_update_mode_node (layer);
     }
 
+  gimp_drawable_update_bounding_box (GIMP_DRAWABLE (layer));
+
   /*  If applying actually changed the view  */
   if (view_changed)
     {


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