From c44941ae280b380e85cd73d7552ec3f9bdbd32fa Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 2 Apr 2024 16:36:46 +0000 Subject: [PATCH] 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. --- app/core/gimpgrouplayer.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c index a0c3959eba..370d28e595 100644 --- a/app/core/gimpgrouplayer.c +++ b/app/core/gimpgrouplayer.c @@ -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)) {