core: Resize filters with group layers

Resolves #11054

NDE Filters clip to the size of the layer when
applied. Group layers get their dimensions from
the largest layers under them, so an empty
layer has dimensions of 0 by 0. This means a
filter applied when the layer group is empty will
be clipped to 0 by 0 as well.
This patch adds code to refresh the filter's crop
whenever the group layer is resized by a
layer being added or removed.
This commit is contained in:
Alx Sa 2024-04-02 16:36:46 +00:00
parent 70886e554f
commit c44941ae28

View file

@ -33,7 +33,9 @@
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-loops.h"
#include "gimpchannel.h"
#include "gimpdrawable-filters.h"
#include "gimpdrawablefilter.h"
#include "gimpgrouplayer.h"
#include "gimpgrouplayerundo.h"
#include "gimpimage.h"
@ -1956,6 +1958,7 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
gboolean size_changed;
gboolean resize_mask;
GList *list;
GimpContainer *filters;
old_bounds.x = gimp_item_get_offset_x (item);
old_bounds.y = gimp_item_get_offset_y (item);
@ -2090,6 +2093,29 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
if (resize_mask && ! private->transforming)
gimp_group_layer_update_mask_size (group);
/* Update the crop of any filters */
if (size_changed)
{
filters = gimp_drawable_get_filters (GIMP_DRAWABLE (group));
for (list = GIMP_LIST (filters)->queue->tail;
list; list = g_list_previous (list))
{
if (GIMP_IS_DRAWABLE_FILTER (list->data))
{
GimpDrawableFilter *filter = list->data;
GimpChannel *filter_mask;
filter_mask = gimp_drawable_filter_get_mask (filter);
/* Don't resize partial layer effects */
if (gimp_channel_is_empty (filter_mask))
gimp_drawable_filter_refresh_crop (filter, &bounding_box);
}
}
if (list)
g_list_free (list);
}
/* if we show the mask, invalidate the new mask area */
if (resize_mask && gimp_layer_get_show_mask (layer))
{