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.
This commit is contained in:
Ell 2019-08-01 22:14:31 +03:00
parent 153cb33eec
commit 7a05d15f7e
1 changed files with 18 additions and 0 deletions

View File

@ -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)
{