[gimp/gimp-2-10] app: align drawable undo rectangle to tile grid
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: align drawable undo rectangle to tile grid
- Date: Sun, 2 Dec 2018 08:12:05 +0000 (UTC)
commit 782d54a615f3e8e841218eb46c2c9330dad67582
Author: Ell <ell_se yahoo com>
Date: Sun Dec 2 02:36:17 2018 -0500
app: align drawable undo rectangle to tile grid
When creating a drawable undo from the drawable's buffer, align the
copied rectangle to the buffer's tile grid, so that all the copied
tiles are COWed, saving memory and gaining speed.
Add applied_x and applied_y fields to GimpDrawableUndo, specifying
the position at which to apply the applied_buffer, so that we apply
it in the right place, even if the undo rect has changed due to
alignment.
(cherry picked from commit bb9dd049fb570353a7fc40e3af7d887d3a6be580)
app/core/gimpdrawable.c | 36 +++++++++++++++++++++++++++++++++---
app/core/gimpdrawableundo.h | 2 ++
app/core/gimpimage-fade.c | 6 ++----
3 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index cb4dd55713..262d67ea5c 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -43,9 +43,11 @@
#include "gimpdrawable-private.h"
#include "gimpdrawable-shadow.h"
#include "gimpdrawable-transform.h"
+#include "gimpdrawableundo.h"
#include "gimpfilterstack.h"
#include "gimpimage.h"
#include "gimpimage-colormap.h"
+#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpmarshal.h"
#include "gimppickable.h"
@@ -859,14 +861,32 @@ gimp_drawable_real_push_undo (GimpDrawable *drawable,
gint width,
gint height)
{
+ GimpImage *image;
+ GimpDrawableUndo *undo;
+ gint applied_x = x;
+ gint applied_y = y;
+
if (! buffer)
{
+ GeglBuffer *drawable_buffer = gimp_drawable_get_buffer (drawable);
+ GeglRectangle drawable_rect;
+
+ gimp_gegl_rectangle_align_to_tile_grid (
+ &drawable_rect,
+ GEGL_RECTANGLE (x, y, width, height),
+ drawable_buffer);
+
+ x = drawable_rect.x;
+ y = drawable_rect.y;
+ width = drawable_rect.width;
+ height = drawable_rect.height;
+
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
gimp_drawable_get_format (drawable));
gimp_gegl_buffer_copy (
- gimp_drawable_get_buffer (drawable),
- GEGL_RECTANGLE (x, y, width, height), GEGL_ABYSS_NONE,
+ drawable_buffer,
+ &drawable_rect, GEGL_ABYSS_NONE,
buffer,
GEGL_RECTANGLE (0, 0, 0, 0));
}
@@ -875,10 +895,20 @@ gimp_drawable_real_push_undo (GimpDrawable *drawable,
g_object_ref (buffer);
}
- gimp_image_undo_push_drawable (gimp_item_get_image (GIMP_ITEM (drawable)),
+ image = gimp_item_get_image (GIMP_ITEM (drawable));
+
+ gimp_image_undo_push_drawable (image,
undo_desc, drawable,
buffer, x, y);
+ undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
+
+ if (undo)
+ {
+ undo->applied_x = applied_x;
+ undo->applied_y = applied_y;
+ }
+
g_object_unref (buffer);
}
diff --git a/app/core/gimpdrawableundo.h b/app/core/gimpdrawableundo.h
index d87fd1f4c4..9e67327273 100644
--- a/app/core/gimpdrawableundo.h
+++ b/app/core/gimpdrawableundo.h
@@ -43,6 +43,8 @@ struct _GimpDrawableUndo
/* stuff for "Fade" */
GeglBuffer *applied_buffer;
+ gint applied_x;
+ gint applied_y;
GimpLayerMode paint_mode;
GimpLayerColorSpace blend_space;
GimpLayerColorSpace composite_space;
diff --git a/app/core/gimpimage-fade.c b/app/core/gimpimage-fade.c
index 6fd60ea749..462d03126d 100644
--- a/app/core/gimpimage-fade.c
+++ b/app/core/gimpimage-fade.c
@@ -58,9 +58,7 @@ gimp_image_fade (GimpImage *image,
gimp_image_undo (image);
gimp_drawable_apply_buffer (drawable, buffer,
- GEGL_RECTANGLE (0, 0,
- gegl_buffer_get_width (undo->buffer),
- gegl_buffer_get_height (undo->buffer)),
+ gegl_buffer_get_extent (buffer),
TRUE,
gimp_object_get_name (undo),
gimp_context_get_opacity (context),
@@ -69,7 +67,7 @@ gimp_image_fade (GimpImage *image,
GIMP_LAYER_COLOR_SPACE_AUTO,
gimp_layer_mode_get_paint_composite_mode (
gimp_context_get_paint_mode (context)),
- NULL, undo->x, undo->y);
+ NULL, undo->applied_x, undo->applied_y);
g_object_unref (buffer);
g_object_unref (undo);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]