[gimp/gimp-2-10] app: guarantee fully-COWed copies in more cases in paint code
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: guarantee fully-COWed copies in more cases in paint code
- Date: Tue, 30 Jul 2019 17:33:28 +0000 (UTC)
commit 29aede6722c6fd4c0ea375d53bf401162c976319
Author: Ell <ell_se yahoo com>
Date: Tue Jul 30 20:27:11 2019 +0300
app: guarantee fully-COWed copies in more cases in paint code
(cherry picked from commit fb679f9efa08ad49f17749d9da8a4a78960a2d2b)
app/core/gimpdrawable.c | 59 +++++++++++++++++++++++------------------------
app/paint/gimppaintcore.c | 11 +++++++--
2 files changed, 38 insertions(+), 32 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index cd85c5c33e..434f93bdad 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -57,11 +57,8 @@
#include "gimp-intl.h"
-#define PAINT_COPY_CHUNK_WIDTH 128
-#define PAINT_COPY_CHUNK_HEIGHT 128
-
-#define PAINT_UPDATE_CHUNK_WIDTH 32
-#define PAINT_UPDATE_CHUNK_HEIGHT 32
+#define PAINT_UPDATE_CHUNK_WIDTH 32
+#define PAINT_UPDATE_CHUNK_HEIGHT 32
enum
@@ -1076,48 +1073,50 @@ gimp_drawable_update (GimpDrawable *drawable,
{
GeglRectangle rect;
- rect.x = floor ((gdouble) x / PAINT_COPY_CHUNK_WIDTH) * PAINT_COPY_CHUNK_WIDTH;
- rect.y = floor ((gdouble) y / PAINT_COPY_CHUNK_HEIGHT) * PAINT_COPY_CHUNK_HEIGHT;
- rect.width = ceil ((gdouble) (x + width) / PAINT_COPY_CHUNK_WIDTH) * PAINT_COPY_CHUNK_WIDTH -
rect.x;
- rect.height = ceil ((gdouble) (y + height) / PAINT_COPY_CHUNK_HEIGHT) * PAINT_COPY_CHUNK_HEIGHT -
rect.y;
-
if (gegl_rectangle_intersect (
&rect,
- &rect,
+ GEGL_RECTANGLE (x, y, width, height),
GEGL_RECTANGLE (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)))))
{
+ GeglRectangle aligned_rect;
+
+ gegl_rectangle_align_to_buffer (&aligned_rect, &rect,
+ gimp_drawable_get_buffer (drawable),
+ GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
+
if (drawable->private->paint_copy_region)
{
cairo_region_union_rectangle (
drawable->private->paint_copy_region,
- (const cairo_rectangle_int_t *) &rect);
+ (const cairo_rectangle_int_t *) &aligned_rect);
}
else
{
drawable->private->paint_copy_region =
cairo_region_create_rectangle (
- (const cairo_rectangle_int_t *) &rect);
+ (const cairo_rectangle_int_t *) &aligned_rect);
}
- rect.x = floor ((gdouble) x / PAINT_UPDATE_CHUNK_WIDTH) *
PAINT_UPDATE_CHUNK_WIDTH;
- rect.y = floor ((gdouble) y / PAINT_UPDATE_CHUNK_HEIGHT) *
PAINT_UPDATE_CHUNK_HEIGHT;
- rect.width = ceil ((gdouble) (x + width) / PAINT_UPDATE_CHUNK_WIDTH) *
PAINT_UPDATE_CHUNK_WIDTH - rect.x;
- rect.height = ceil ((gdouble) (y + height) / PAINT_UPDATE_CHUNK_HEIGHT) *
PAINT_UPDATE_CHUNK_HEIGHT - rect.y;
-
- if (drawable->private->paint_update_region)
- {
- cairo_region_union_rectangle (
- drawable->private->paint_update_region,
- (const cairo_rectangle_int_t *) &rect);
- }
- else
- {
- drawable->private->paint_update_region =
- cairo_region_create_rectangle (
- (const cairo_rectangle_int_t *) &rect);
- }
+ gegl_rectangle_align (&aligned_rect, &rect,
+ GEGL_RECTANGLE (0, 0,
+ PAINT_UPDATE_CHUNK_WIDTH,
+ PAINT_UPDATE_CHUNK_HEIGHT),
+ GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
+
+ if (drawable->private->paint_update_region)
+ {
+ cairo_region_union_rectangle (
+ drawable->private->paint_update_region,
+ (const cairo_rectangle_int_t *) &aligned_rect);
+ }
+ else
+ {
+ drawable->private->paint_update_region =
+ cairo_region_create_rectangle (
+ (const cairo_rectangle_int_t *) &aligned_rect);
+ }
}
}
}
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index cbe369406a..c497f6c785 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -567,11 +567,18 @@ gimp_paint_core_cancel (GimpPaintCore *core,
gimp_item_get_height (GIMP_ITEM (drawable)),
&x, &y, &width, &height))
{
+ GeglRectangle rect;
+
+ gegl_rectangle_align_to_buffer (&rect,
+ GEGL_RECTANGLE (x, y, width, height),
+ gimp_drawable_get_buffer (drawable),
+ GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
+
gimp_gegl_buffer_copy (core->undo_buffer,
- GEGL_RECTANGLE (x, y, width, height),
+ &rect,
GEGL_ABYSS_NONE,
gimp_drawable_get_buffer (drawable),
- GEGL_RECTANGLE (x, y, width, height));
+ &rect);
}
g_clear_object (&core->undo_buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]