Issue #15004: empty pass-through groups have no size, making it…

… impossible to use them like adjustment layers without additional step.

Even without the "adjustment layer" look-alike use case, this is wrong,
because an effect on an adjustment layer will be only applied on the
area contained in child layers, whereas by definition, a pass-through
layer would use the below render as input, and therefore its output
could be bigger than its child layers box.

I could find commit aa9ae1c65c as a culprit commit, and reverting it
would in fact also fix this issue, though by doing this, we'd regress on
the issue #4634 (I tested with one of the contributed XCF and can indeed
reproduce the bug).

Instead I return the unioned bounding box of the node, and of the
computed one. I do not feel like it's optimal, but this feels like a
complicated issue. It looks to me like there might be another deeper
issue in how both these bounding boxes are computed (not optimally!).

In any case, it also makes empty pass-through groups now usable to apply
directly an effect on the whole below render, as a side effect.
This commit is contained in:
Jehan 2025-10-07 21:26:21 +02:00
parent f5b94bdc03
commit 85d381bd0c

View file

@ -1230,7 +1230,22 @@ gimp_group_layer_get_bounding_box (GimpLayer *layer)
{
GimpGroupLayerPrivate *private = GET_PRIVATE (layer);
/* for pass-through groups, use the group's calculated bounding box, instead
/* With #4634 were reported to us cases where the get_bounding_box()
* was smaller than the calculated bounding box. But we also had the
* opposite case, which is that the get_bounding_box() value was
* bigger than the computed bounding_box (e.g. when having a
* pass-through group layer with a single transparent layer, smaller
* than the canvas: applying an effect only affects this layer,
* whereas the actual render of the layer group contains the below
* layers). Cf. #15004.
*
* XXX It feels like the parent's get_bounding_box() implementation
* (which gets the source node bounding box) is bugged and should not
* return what it does. This should likely be looked closer into.
* For now, I get the union bounding box of both these results.
*
* Older explanation for #4634:
* for pass-through groups, use the group's calculated bounding box, instead
* of the source-node's bounding box, since we don't update the bounding box
* on all events that may affect the latter, and since it includes the
* bounding box of the backdrop. this means we can't attach filters that may
@ -1239,9 +1254,17 @@ gimp_group_layer_get_bounding_box (GimpLayer *layer)
* through groups makes little sense anyway.
*/
if (private->pass_through)
return private->bounding_box;
{
GeglRectangle rect = GIMP_LAYER_CLASS (parent_class)->get_bounding_box (layer);
gegl_rectangle_bounding_box (&rect, &private->bounding_box, &rect);
return rect;
}
else
return GIMP_LAYER_CLASS (parent_class)->get_bounding_box (layer);
{
return GIMP_LAYER_CLASS (parent_class)->get_bounding_box (layer);
}
}
static void