~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/paint/gimpinkundo.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <string.h>
 
22
 
 
23
#include <glib-object.h>
 
24
 
 
25
#include "paint-types.h"
 
26
 
 
27
#include "gimpink.h"
 
28
#include "gimpink-blob.h"
 
29
#include "gimpinkundo.h"
 
30
 
 
31
 
 
32
static GObject * gimp_ink_undo_constructor  (GType                  type,
 
33
                                             guint                  n_params,
 
34
                                             GObjectConstructParam *params);
 
35
 
 
36
static void      gimp_ink_undo_pop          (GimpUndo              *undo,
 
37
                                             GimpUndoMode           undo_mode,
 
38
                                             GimpUndoAccumulator   *accum);
 
39
static void      gimp_ink_undo_free         (GimpUndo              *undo,
 
40
                                             GimpUndoMode           undo_mode);
 
41
 
 
42
 
 
43
G_DEFINE_TYPE (GimpInkUndo, gimp_ink_undo, GIMP_TYPE_PAINT_CORE_UNDO)
 
44
 
 
45
#define parent_class gimp_ink_undo_parent_class
 
46
 
 
47
 
 
48
static void
 
49
gimp_ink_undo_class_init (GimpInkUndoClass *klass)
 
50
{
 
51
  GObjectClass  *object_class = G_OBJECT_CLASS (klass);
 
52
  GimpUndoClass *undo_class   = GIMP_UNDO_CLASS (klass);
 
53
 
 
54
  object_class->constructor = gimp_ink_undo_constructor;
 
55
 
 
56
  undo_class->pop           = gimp_ink_undo_pop;
 
57
  undo_class->free          = gimp_ink_undo_free;
 
58
}
 
59
 
 
60
static void
 
61
gimp_ink_undo_init (GimpInkUndo *undo)
 
62
{
 
63
}
 
64
 
 
65
static GObject *
 
66
gimp_ink_undo_constructor (GType                  type,
 
67
                           guint                  n_params,
 
68
                           GObjectConstructParam *params)
 
69
{
 
70
  GObject     *object;
 
71
  GimpInkUndo *ink_undo;
 
72
  GimpInk     *ink;
 
73
 
 
74
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
75
 
 
76
  ink_undo = GIMP_INK_UNDO (object);
 
77
 
 
78
  g_assert (GIMP_IS_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core));
 
79
 
 
80
  ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
 
81
 
 
82
  if (ink->start_blob)
 
83
    ink_undo->last_blob = blob_duplicate (ink->start_blob);
 
84
 
 
85
  memcpy (ink_undo->dt_buffer, ink->dt_buffer,
 
86
          sizeof (ink_undo->dt_buffer));
 
87
 
 
88
  ink_undo->dt_index = ink->dt_index;
 
89
 
 
90
  memcpy (ink_undo->ts_buffer, ink->ts_buffer,
 
91
          sizeof (ink_undo->ts_buffer));
 
92
 
 
93
  ink_undo->ts_index = ink->ts_index;
 
94
 
 
95
  ink_undo->last_time = ink->last_time;
 
96
 
 
97
  ink_undo->init_velocity = ink->init_velocity;
 
98
 
 
99
  return object;
 
100
}
 
101
 
 
102
static void
 
103
gimp_ink_undo_pop (GimpUndo              *undo,
 
104
                   GimpUndoMode           undo_mode,
 
105
                   GimpUndoAccumulator   *accum)
 
106
{
 
107
  GimpInkUndo *ink_undo = GIMP_INK_UNDO (undo);
 
108
 
 
109
  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
 
110
 
 
111
  if (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core)
 
112
    {
 
113
      GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
 
114
      Blob    *tmp_blob;
 
115
      gint     tmp_int;
 
116
      gdouble  tmp_double;
 
117
      guint32  tmp_int_buf[DIST_SMOOTHER_BUFFER];
 
118
      gdouble  tmp_double_buf[DIST_SMOOTHER_BUFFER];
 
119
 
 
120
      tmp_blob = ink->last_blob;
 
121
      ink->last_blob = ink_undo->last_blob;
 
122
      ink_undo->last_blob = tmp_blob;
 
123
 
 
124
      memcpy (tmp_double_buf, ink->dt_buffer,
 
125
              sizeof (tmp_double_buf));
 
126
      memcpy (ink->dt_buffer, ink_undo->dt_buffer,
 
127
              sizeof (tmp_double_buf));
 
128
      memcpy (ink_undo->dt_buffer, tmp_double_buf,
 
129
              sizeof (tmp_double_buf));
 
130
 
 
131
      tmp_int = ink->dt_index;
 
132
      ink->dt_index = ink_undo->dt_index;
 
133
      ink_undo->dt_index = tmp_int;
 
134
 
 
135
      memcpy (tmp_int_buf, ink->ts_buffer,
 
136
              sizeof (tmp_int_buf));
 
137
      memcpy (ink->ts_buffer, ink_undo->ts_buffer,
 
138
              sizeof (tmp_int_buf));
 
139
      memcpy (ink_undo->ts_buffer, tmp_int_buf,
 
140
              sizeof (tmp_int_buf));
 
141
 
 
142
      tmp_int = ink->ts_index;
 
143
      ink->ts_index = ink_undo->ts_index;
 
144
      ink_undo->ts_index = tmp_int;
 
145
 
 
146
      tmp_double = ink->last_time;
 
147
      ink->last_time = ink_undo->last_time;
 
148
      ink_undo->last_time = tmp_double;
 
149
 
 
150
      tmp_int = ink->init_velocity;
 
151
      ink->init_velocity = ink_undo->init_velocity;
 
152
      ink_undo->init_velocity = tmp_int;
 
153
    }
 
154
}
 
155
 
 
156
static void
 
157
gimp_ink_undo_free (GimpUndo     *undo,
 
158
                    GimpUndoMode  undo_mode)
 
159
{
 
160
  GimpInkUndo *ink_undo = GIMP_INK_UNDO (undo);
 
161
 
 
162
  if (ink_undo->last_blob)
 
163
    {
 
164
      g_free (ink_undo->last_blob);
 
165
      ink_undo->last_blob = NULL;
 
166
    }
 
167
 
 
168
  GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
 
169
}