app: skip cache and format conversion when merging a drawable filter
In gimp_drawable_merge_filter(), disable the filter applicator's
cache and output-format conversion nodes before processing the
uncached region of the filter, so that the result is written
directly to the drawable's buffer.
(cherry picked from commit 733a6ec01c)
This commit is contained in:
@ -113,13 +113,15 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpApplicator *applicator;
|
||||
gboolean applicator_cache = FALSE;
|
||||
const Babl *applicator_output_format = NULL;
|
||||
GeglBuffer *undo_buffer;
|
||||
GeglRectangle undo_rect;
|
||||
GeglBuffer *cache = NULL;
|
||||
GeglRectangle *rects = NULL;
|
||||
gint n_rects = 0;
|
||||
GeglBuffer *cache = NULL;
|
||||
GeglRectangle *rects = NULL;
|
||||
gint n_rects = 0;
|
||||
GeglRectangle rect;
|
||||
gboolean success = TRUE;
|
||||
gboolean success = TRUE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_FILTER (filter), FALSE);
|
||||
@ -149,6 +151,16 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||
*/
|
||||
cache = gimp_applicator_get_cache_buffer (applicator,
|
||||
&rects, &n_rects);
|
||||
|
||||
/* skip the cache and output-format conversion while processing
|
||||
* the remaining area, so that the result is written directly to
|
||||
* the drawable's buffer.
|
||||
*/
|
||||
applicator_cache = gimp_applicator_get_cache (applicator);
|
||||
applicator_output_format = gimp_applicator_get_output_format (applicator);
|
||||
|
||||
gimp_applicator_set_cache (applicator, FALSE);
|
||||
gimp_applicator_set_output_format (applicator, NULL);
|
||||
}
|
||||
|
||||
gimp_gegl_rectangle_align_to_tile_grid (
|
||||
@ -206,6 +218,12 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||
g_free (rects);
|
||||
}
|
||||
|
||||
if (applicator)
|
||||
{
|
||||
gimp_applicator_set_cache (applicator, applicator_cache);
|
||||
gimp_applicator_set_output_format (applicator, applicator_output_format);
|
||||
}
|
||||
|
||||
gimp_drawable_update (drawable,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
|
||||
@ -27,8 +27,6 @@
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gegl/gimpapplicator.h"
|
||||
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-operation.h"
|
||||
#include "gimpdrawablefilter.h"
|
||||
@ -45,7 +43,6 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
|
||||
GeglNode *operation)
|
||||
{
|
||||
GimpDrawableFilter *filter;
|
||||
GimpApplicator *applicator;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
||||
@ -59,10 +56,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
|
||||
return;
|
||||
}
|
||||
|
||||
filter = gimp_drawable_filter_new (drawable, undo_desc, operation, NULL);
|
||||
applicator = gimp_filter_get_applicator (GIMP_FILTER (filter));
|
||||
|
||||
gimp_applicator_set_cache (applicator, FALSE);
|
||||
filter = gimp_drawable_filter_new (drawable, undo_desc, operation, NULL);
|
||||
|
||||
gimp_drawable_filter_apply (filter, NULL);
|
||||
gimp_drawable_filter_commit (filter, progress, TRUE);
|
||||
|
||||
@ -494,6 +494,14 @@ gimp_applicator_set_output_format (GimpApplicator *applicator,
|
||||
}
|
||||
}
|
||||
|
||||
const Babl *
|
||||
gimp_applicator_get_output_format (GimpApplicator *applicator)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_APPLICATOR (applicator), NULL);
|
||||
|
||||
return applicator->output_format;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_applicator_set_cache (GimpApplicator *applicator,
|
||||
gboolean enable)
|
||||
@ -519,6 +527,14 @@ gimp_applicator_set_cache (GimpApplicator *applicator,
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_applicator_get_cache (GimpApplicator *applicator)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_APPLICATOR (applicator), FALSE);
|
||||
|
||||
return applicator->cache_enabled;
|
||||
}
|
||||
|
||||
gboolean gegl_buffer_list_valid_rectangles (GeglBuffer *buffer,
|
||||
GeglRectangle **rectangles,
|
||||
gint *n_rectangles);
|
||||
|
||||
@ -121,9 +121,11 @@ void gimp_applicator_set_affect (GimpApplicator *applicator
|
||||
|
||||
void gimp_applicator_set_output_format (GimpApplicator *applicator,
|
||||
const Babl *format);
|
||||
const Babl * gimp_applicator_get_output_format (GimpApplicator *applicator);
|
||||
|
||||
void gimp_applicator_set_cache (GimpApplicator *applicator,
|
||||
gboolean enable);
|
||||
gboolean gimp_applicator_get_cache (GimpApplicator *applicator);
|
||||
GeglBuffer * gimp_applicator_get_cache_buffer (GimpApplicator *applicator,
|
||||
GeglRectangle **rectangles,
|
||||
gint *n_rectangles);
|
||||
|
||||
Reference in New Issue
Block a user