Commit d0df7dae authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/core/gimpmaskundo.c implement GimpObject::get_memsize() instead of

2007-01-31  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpmaskundo.c
	* app/core/gimpitempropundo.c: implement GimpObject::get_memsize()
	instead of fiddling with undo->size.


svn path=/trunk/; revision=21828
parent ff997b36
2007-01-31 Michael Natterer <mitch@gimp.org>
* app/core/gimpmaskundo.c
* app/core/gimpitempropundo.c: implement GimpObject::get_memsize()
instead of fiddling with undo->size.
2007-01-31 Michael Natterer <mitch@gimp.org>
 
* app/core/gimpimage-undo-push.[ch]
......@@ -22,8 +22,6 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "gimpitem.h"
......@@ -34,6 +32,9 @@ static GObject * gimp_item_prop_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static gint64 gimp_item_prop_undo_get_memsize (GimpObject *object,
gint64 *gui_size);
static void gimp_item_prop_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
......@@ -49,13 +50,16 @@ G_DEFINE_TYPE (GimpItemPropUndo, gimp_item_prop_undo, GIMP_TYPE_ITEM_UNDO)
static void
gimp_item_prop_undo_class_init (GimpItemPropUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_item_prop_undo_constructor;
object_class->constructor = gimp_item_prop_undo_constructor;
gimp_object_class->get_memsize = gimp_item_prop_undo_get_memsize;
undo_class->pop = gimp_item_prop_undo_pop;
undo_class->free = gimp_item_prop_undo_free;
undo_class->pop = gimp_item_prop_undo_pop;
undo_class->free = gimp_item_prop_undo_free;
}
static void
......@@ -82,7 +86,6 @@ gimp_item_prop_undo_constructor (GType type,
{
case GIMP_UNDO_ITEM_RENAME:
item_prop_undo->name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
GIMP_UNDO (object)->size += strlen (item_prop_undo->name) + 1;
break;
case GIMP_UNDO_ITEM_DISPLACE:
......@@ -106,6 +109,20 @@ gimp_item_prop_undo_constructor (GType type,
return object;
}
static gint64
gimp_item_prop_undo_get_memsize (GimpObject *object,
gint64 *gui_size)
{
GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (object);
gint64 memsize = 0;
if (item_prop_undo->name)
memsize += strlen (item_prop_undo->name) + 1;
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
static void
gimp_item_prop_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
......@@ -122,13 +139,9 @@ gimp_item_prop_undo_pop (GimpUndo *undo,
{
gchar *name;
undo->size -= strlen (item_prop_undo->name) + 1;
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
gimp_object_take_name (GIMP_OBJECT (item), item_prop_undo->name);
item_prop_undo->name = name;
undo->size += strlen (item_prop_undo->name) + 1;
}
break;
......
......@@ -27,7 +27,6 @@
#include "paint-funcs/paint-funcs.h"
#include "gimpimage.h"
#include "gimpchannel.h"
#include "gimpmaskundo.h"
......@@ -36,6 +35,9 @@ static GObject * gimp_mask_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static gint64 gimp_mask_undo_get_memsize (GimpObject *object,
gint64 *gui_size);
static void gimp_mask_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
......@@ -51,13 +53,16 @@ G_DEFINE_TYPE (GimpMaskUndo, gimp_mask_undo, GIMP_TYPE_ITEM_UNDO)
static void
gimp_mask_undo_class_init (GimpMaskUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_mask_undo_constructor;
object_class->constructor = gimp_mask_undo_constructor;
gimp_object_class->get_memsize = gimp_mask_undo_get_memsize;
undo_class->pop = gimp_mask_undo_pop;
undo_class->free = gimp_mask_undo_free;
undo_class->pop = gimp_mask_undo_pop;
undo_class->free = gimp_mask_undo_free;
}
static void
......@@ -99,14 +104,25 @@ gimp_mask_undo_constructor (GType type,
0, 0, x2 - x1, y2 - y1, TRUE);
copy_region (&srcPR, &destPR);
GIMP_UNDO (object)->size +=
tile_manager_get_memsize (mask_undo->tiles, FALSE);
}
return object;
}
static gint64
gimp_mask_undo_get_memsize (GimpObject *object,
gint64 *gui_size)
{
GimpMaskUndo *mask_undo = GIMP_MASK_UNDO (object);
gint64 memsize = 0;
if (mask_undo->tiles)
memsize += tile_manager_get_memsize (mask_undo->tiles, FALSE);
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
static void
gimp_mask_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
......@@ -122,9 +138,6 @@ gimp_mask_undo_pop (GimpUndo *undo,
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
if (mask_undo->tiles)
undo->size -= tile_manager_get_memsize (mask_undo->tiles, FALSE);
if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2))
{
guchar empty = 0;
......@@ -195,9 +208,6 @@ gimp_mask_undo_pop (GimpUndo *undo,
0, 0,
GIMP_ITEM (channel)->width,
GIMP_ITEM (channel)->height);
if (mask_undo->tiles)
undo->size += tile_manager_get_memsize (mask_undo->tiles, FALSE);
}
static void
......
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