From 85d381bd0cd4e85aab80468fe17b2d606c2efb41 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 7 Oct 2025 21:26:21 +0200 Subject: [PATCH] =?UTF-8?q?Issue=20#15004:=20empty=20pass-through=20groups?= =?UTF-8?q?=20have=20no=20size,=20making=20it=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … 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. --- app/core/gimpgrouplayer.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c index 3fcf7e26ae..c5e3743702 100644 --- a/app/core/gimpgrouplayer.c +++ b/app/core/gimpgrouplayer.c @@ -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