core: Apply noninteractive filters direct to drawable

When the user checks "Merge Filters" on interactive filters,
we move the filter to the bottom of the stack so it applies
directly onto the drawable (instead of merging the entire filter
stack).
However, we did not do this reordering for non-interactive filters,
resulting in incorrect output. This patch applies the same logic
so that when you apply a filter like Invert, it affects the drawable
only and does not cause problems for any existing NDE filters.
This commit is contained in:
Alx Sa 2025-01-04 19:04:11 +00:00
parent 65d4ec7ea4
commit 5e3047c70d
1 changed files with 12 additions and 1 deletions

View File

@ -32,8 +32,10 @@
#include "operations/gimp-operation-config.h"
#include "operations/gimpoperationsettings.h"
#include "gimpdrawable.h"
#include "gimpcontainer.h"
#include "gimpdrawable-filters.h"
#include "gimpdrawable-operation.h"
#include "gimpdrawable.h"
#include "gimpdrawablefilter.h"
#include "gimpprogress.h"
#include "gimpsettings.h"
@ -60,6 +62,7 @@ gimp_drawable_apply_operation_with_config (GimpDrawable *drawable,
GObject *config)
{
GimpDrawableFilter *filter;
GimpContainer *filter_stack;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
@ -89,6 +92,14 @@ gimp_drawable_apply_operation_with_config (GimpDrawable *drawable,
}
gimp_drawable_filter_apply (filter, NULL);
/* For destructive filters, we want them to apply directly on the
* drawable rather than merge down onto existing NDE filters */
filter_stack = gimp_drawable_get_filters (drawable);
if (filter_stack)
gimp_container_reorder (filter_stack, GIMP_OBJECT (filter),
gimp_container_get_n_children (filter_stack) - 1);
gimp_drawable_filter_commit (filter, FALSE, progress, TRUE);
g_object_unref (filter);