Commit 8142fe4d authored by Ell's avatar Ell

app: In GimpHistogram, align copied buffer region to tile rect

In gimp_histogram_calculate_async(), align the copied region of the
drawable and mask buffers to the tile grid, so that all copied
tiles are COWed.

(cherry picked from commit d56d663e)
parent 23cc540f
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "gegl/gimp-babl.h" #include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-loops.h" #include "gegl/gimp-gegl-loops.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp-atomic.h" #include "gimp-atomic.h"
#include "gimp-parallel.h" #include "gimp-parallel.h"
...@@ -311,6 +312,7 @@ gimp_histogram_calculate_async (GimpHistogram *histogram, ...@@ -311,6 +312,7 @@ gimp_histogram_calculate_async (GimpHistogram *histogram,
const GeglRectangle *mask_rect) const GeglRectangle *mask_rect)
{ {
CalculateContext *context; CalculateContext *context;
GeglRectangle rect;
g_return_val_if_fail (GIMP_IS_HISTOGRAM (histogram), NULL); g_return_val_if_fail (GIMP_IS_HISTOGRAM (histogram), NULL);
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL); g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
...@@ -319,14 +321,16 @@ gimp_histogram_calculate_async (GimpHistogram *histogram, ...@@ -319,14 +321,16 @@ gimp_histogram_calculate_async (GimpHistogram *histogram,
if (histogram->priv->calculate_async) if (histogram->priv->calculate_async)
gimp_async_cancel_and_wait (histogram->priv->calculate_async); gimp_async_cancel_and_wait (histogram->priv->calculate_async);
gimp_gegl_rectangle_align_to_tile_grid (&rect, buffer_rect, buffer);
context = g_slice_new0 (CalculateContext); context = g_slice_new0 (CalculateContext);
context->histogram = histogram; context->histogram = histogram;
context->buffer = gegl_buffer_new (buffer_rect, context->buffer = gegl_buffer_new (&rect,
gegl_buffer_get_format (buffer)); gegl_buffer_get_format (buffer));
context->buffer_rect = *buffer_rect; context->buffer_rect = *buffer_rect;
gimp_gegl_buffer_copy (buffer, buffer_rect, GEGL_ABYSS_NONE, gimp_gegl_buffer_copy (buffer, &rect, GEGL_ABYSS_NONE,
context->buffer, NULL); context->buffer, NULL);
if (mask) if (mask)
...@@ -336,10 +340,11 @@ gimp_histogram_calculate_async (GimpHistogram *histogram, ...@@ -336,10 +340,11 @@ gimp_histogram_calculate_async (GimpHistogram *histogram,
else else
context->mask_rect = *gegl_buffer_get_extent (mask); context->mask_rect = *gegl_buffer_get_extent (mask);
context->mask = gegl_buffer_new (&context->mask_rect, gimp_gegl_rectangle_align_to_tile_grid (&rect, &context->mask_rect, mask);
gegl_buffer_get_format (mask));
context->mask = gegl_buffer_new (&rect, gegl_buffer_get_format (mask));
gimp_gegl_buffer_copy (mask, &context->mask_rect, GEGL_ABYSS_NONE, gimp_gegl_buffer_copy (mask, &rect, GEGL_ABYSS_NONE,
context->mask, NULL); context->mask, NULL);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment