Issue #16010: do not mind buffers with non-0 offsets in the case of group layers.

In fact, the previous commit was unneeded and we could have done without
reverting the old commit. On the other hand, a buffer using another
buffer as "source" may be nicer in memory.

But the previous commit alone was not right as group boundaries were
wrong. In fact, right now, we can see that group boundaries are computed
using only the children layers (except for pass-through of course), not
including any effects they might have. And the buffer passed to
gimp_drawable_set_buffer_full() was the projection's buffer itself — it
was shared, which was also why copying at setting time was wrong —, in
the case of a group layer. That means that when we translated to (0, 0)
offset, either we would have moved the render to the wrong place, or
moved the boundaries to the wrong place.
The offset needs to stay what it is, even when it's not (0, 0), for
group layers.

Another alternative fix would be instead to fix layer groups' boundaries
to encompass the full projection's render. But I just went with this
special-casing of group layers instead.
This commit is contained in:
Jehan 2026-03-24 20:41:53 +01:00
parent af44043108
commit 7f67536f1a

View file

@ -48,6 +48,7 @@
#include "gimpdrawablefilter.h"
#include "gimpdrawablefiltermask.h"
#include "gimpfilterstack.h"
#include "gimpgrouplayer.h"
#include "gimpimage.h"
#include "gimpimage-colormap.h"
#include "gimpimage-undo-push.h"
@ -1033,13 +1034,18 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
old_has_alpha = gimp_drawable_has_alpha (drawable);
}
if (extent->x != 0 || extent->y != 0)
if (! GIMP_IS_GROUP_LAYER (drawable) && (extent->x != 0 || extent->y != 0))
{
/* Drawable buffers are always stored with a (0, 0) origin. When
* setting a buffer with a different origin, we will assume we
* instead want to update the offset a bit.
* This may happen for instance when merging filters which may
* render in negative coordinates.
*
* The only exception to this is group layers. Group layer's
* boundaries will be determined by children layers, but the
* render may extend outside the boundaries (if children have
* effects).
*/
buffer = g_object_new (GEGL_TYPE_BUFFER,
"source", buffer,
@ -1061,7 +1067,10 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
"buffer", gimp_drawable_get_buffer (drawable),
NULL);
gimp_item_set_offset (item, bounds->x + extent->x, bounds->y + extent->y);
if (GIMP_IS_GROUP_LAYER (drawable))
gimp_item_set_offset (item, bounds->x, bounds->y);
else
gimp_item_set_offset (item, bounds->x + extent->x, bounds->y + extent->y);
gimp_item_set_size (item,
bounds->width ? bounds->width :
gegl_buffer_get_width (buffer),