mirror of https://github.com/GNOME/gimp.git
Optionally make a copy of the drawable's tiles in GimpDrawableModUndo
instead of simply reffing drawable->tiles. Add boolean property "copy-tiles" and a boolean parameter to gimp_image_undo_push_drawable_mod() to control the new feature. However, pass FALSE in gimp_drawable_real_set_tiles() (which currently is the undo's only user)
This commit is contained in:
parent
2f22dc8c24
commit
8688037a58
|
@ -783,7 +783,7 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
|
|||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_drawable_mod (gimp_item_get_image (item), undo_desc,
|
||||
drawable);
|
||||
drawable, FALSE);
|
||||
|
||||
/* ref new before unrefing old, they might be the same */
|
||||
tile_manager_ref (tiles);
|
||||
|
|
|
@ -21,25 +21,44 @@
|
|||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "base/pixel-region.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "paint-funcs/paint-funcs.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawablemodundo.h"
|
||||
|
||||
|
||||
static GObject * gimp_drawable_mod_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_COPY_TILES
|
||||
};
|
||||
|
||||
static gint64 gimp_drawable_mod_undo_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
|
||||
static void gimp_drawable_mod_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_drawable_mod_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
static GObject * gimp_drawable_mod_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_drawable_mod_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_drawable_mod_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
static gint64 gimp_drawable_mod_undo_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
|
||||
static void gimp_drawable_mod_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_drawable_mod_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDrawableModUndo, gimp_drawable_mod_undo, GIMP_TYPE_ITEM_UNDO)
|
||||
|
@ -55,11 +74,19 @@ gimp_drawable_mod_undo_class_init (GimpDrawableModUndoClass *klass)
|
|||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_drawable_mod_undo_constructor;
|
||||
object_class->set_property = gimp_drawable_mod_undo_set_property;
|
||||
object_class->get_property = gimp_drawable_mod_undo_get_property;
|
||||
|
||||
gimp_object_class->get_memsize = gimp_drawable_mod_undo_get_memsize;
|
||||
|
||||
undo_class->pop = gimp_drawable_mod_undo_pop;
|
||||
undo_class->free = gimp_drawable_mod_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_COPY_TILES,
|
||||
g_param_spec_boolean ("copy-tiles", NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -67,6 +94,46 @@ gimp_drawable_mod_undo_init (GimpDrawableModUndo *undo)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_mod_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpDrawableModUndo *drawable_mod_undo = GIMP_DRAWABLE_MOD_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_COPY_TILES:
|
||||
drawable_mod_undo->copy_tiles = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_mod_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpDrawableModUndo *drawable_mod_undo = GIMP_DRAWABLE_MOD_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_COPY_TILES:
|
||||
g_value_set_boolean (value, drawable_mod_undo->copy_tiles);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_drawable_mod_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
|
@ -74,6 +141,7 @@ gimp_drawable_mod_undo_constructor (GType type,
|
|||
{
|
||||
GObject *object;
|
||||
GimpDrawableModUndo *drawable_mod_undo;
|
||||
GimpItem *item;
|
||||
GimpDrawable *drawable;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
@ -82,12 +150,33 @@ gimp_drawable_mod_undo_constructor (GType type,
|
|||
|
||||
g_assert (GIMP_IS_DRAWABLE (GIMP_ITEM_UNDO (object)->item));
|
||||
|
||||
drawable = GIMP_DRAWABLE (GIMP_ITEM_UNDO (object)->item);
|
||||
item = GIMP_ITEM_UNDO (object)->item;
|
||||
drawable = GIMP_DRAWABLE (item);
|
||||
|
||||
drawable_mod_undo->tiles = tile_manager_ref (gimp_drawable_get_tiles (drawable));
|
||||
drawable_mod_undo->type = gimp_drawable_type (drawable);
|
||||
if (drawable_mod_undo->copy_tiles)
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
gint width = gimp_item_get_width (item);
|
||||
gint height = gimp_item_get_height (item);
|
||||
|
||||
gimp_item_get_offset (GIMP_ITEM (drawable),
|
||||
drawable_mod_undo->tiles =
|
||||
tile_manager_new (width, height,
|
||||
gimp_drawable_bytes (drawable));
|
||||
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
|
||||
0, 0, width, height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_mod_undo->tiles,
|
||||
0, 0, width, height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawable_mod_undo->tiles =
|
||||
tile_manager_ref (gimp_drawable_get_tiles (drawable));
|
||||
}
|
||||
|
||||
drawable_mod_undo->type = gimp_drawable_type (drawable);
|
||||
|
||||
gimp_item_get_offset (item,
|
||||
&drawable_mod_undo->offset_x,
|
||||
&drawable_mod_undo->offset_y);
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ struct _GimpDrawableModUndo
|
|||
GimpItemUndo parent_instance;
|
||||
|
||||
TileManager *tiles;
|
||||
gboolean copy_tiles;
|
||||
GimpImageType type;
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
|
|
@ -254,7 +254,8 @@ gimp_image_undo_push_drawable (GimpImage *image,
|
|||
GimpUndo *
|
||||
gimp_image_undo_push_drawable_mod (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
GimpDrawable *drawable)
|
||||
GimpDrawable *drawable,
|
||||
gboolean copy_tiles)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||
|
@ -263,7 +264,8 @@ gimp_image_undo_push_drawable_mod (GimpImage *image,
|
|||
return gimp_image_undo_push (image, GIMP_TYPE_DRAWABLE_MOD_UNDO,
|
||||
GIMP_UNDO_DRAWABLE_MOD, undo_desc,
|
||||
GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
|
||||
"item", drawable,
|
||||
"item", drawable,
|
||||
"copy-tiles", copy_tiles,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,8 @@ GimpUndo * gimp_image_undo_push_drawable (GimpImage *image,
|
|||
gint height);
|
||||
GimpUndo * gimp_image_undo_push_drawable_mod (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
GimpDrawable *drawable);
|
||||
GimpDrawable *drawable,
|
||||
gboolean copy_tiles);
|
||||
|
||||
|
||||
/* mask undo */
|
||||
|
|
Loading…
Reference in New Issue