[gimp] app: implement GimpDrawable::get_bounding_box() for GimpLayer



commit 7a05d15f7e021161b7635ab9478a2eeb45ad0b26
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.

 app/core/gimplayer.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 0fc36779c5..665e018b51 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -202,6 +202,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);
@@ -462,6 +464,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;
@@ -1528,6 +1531,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)
 {
@@ -1914,6 +1928,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))
     {
@@ -2232,6 +2248,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]