~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/base/tile.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
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
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
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.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
33
32
/*  Uncomment for verbose debugging on copy-on-write logic  */
34
33
/*  #define TILE_DEBUG  */
35
34
 
36
 
/*  Uncomment to enable global counters to profile the tile system. */
37
 
/*  #define TILE_PROFILING */
38
 
 
39
 
 
40
35
/*  This is being used from tile-swap, but just for debugging purposes.  */
41
36
static gint tile_ref_count    = 0;
42
37
 
47
42
static gint tile_share_count  = 0;
48
43
static gint tile_active_count = 0;
49
44
 
50
 
static gint tile_exist_peak   = 0;
51
 
static gint tile_exist_count  = 0;
 
45
gint tile_exist_peak          = 0;
 
46
gint tile_exist_count         = 0;
52
47
 
53
48
#endif
54
49
 
86
81
 
87
82
  if (tile->ref_count == 1)
88
83
    {
89
 
      if (tile->listhead)
90
 
        {
91
 
          /* remove from cache, move to main store */
92
 
          tile_cache_flush (tile);
93
 
        }
 
84
      /* remove from cache, move to main store */
 
85
      tile_cache_flush (tile);
94
86
 
95
87
#ifdef TILE_PROFILING
96
88
      tile_active_count++;
172
164
 
173
165
#ifdef TILE_PROFILING
174
166
  tile_exist_count++;
 
167
 
175
168
  if (tile_exist_count > tile_exist_peak)
176
169
    tile_exist_peak = tile_exist_count;
177
170
#endif
190
183
      g_warning ("tried to destroy an attached tile");
191
184
      return;
192
185
    }
 
186
 
193
187
  if (tile->data)
194
188
    {
195
189
      g_free (tile->data);
196
190
      tile->data = NULL;
 
191
 
 
192
#ifdef TILE_PROFILING
 
193
      tile_exist_count--;
 
194
#endif
197
195
    }
 
196
 
198
197
  if (tile->rowhint)
199
198
    {
200
199
      g_slice_free1 (sizeof (TileRowHint) * TILE_HEIGHT, tile->rowhint);
201
200
      tile->rowhint = NULL;
202
201
    }
 
202
 
 
203
  /* must flush before deleting swap */
 
204
  tile_cache_flush (tile);
 
205
 
203
206
  if (tile->swap_offset != -1)
204
207
    {
205
208
      /* If the tile is on disk, then delete its
207
210
       */
208
211
      tile_swap_delete (tile);
209
212
    }
210
 
  if (tile->listhead)
211
 
    tile_cache_flush (tile);
212
213
 
213
214
  g_slice_free (Tile, tile);
214
215
 
215
216
#ifdef TILE_PROFILING
216
217
  tile_count--;
217
 
 
218
 
  tile_exist_count--;
219
218
#endif
220
219
}
221
220
 
295
294
  TileLink  *tmp;
296
295
 
297
296
#ifdef TILE_DEBUG
298
 
  g_printerr ("tile_detach: %p ~> (%p,%d) r%d *%d\n",
 
297
  g_printerr ("tile_detach: %p ~> (%p,%d) r%d *%u\n",
299
298
              tile, tm, tile_num, tile->ref_count, tile->share_count);
300
299
#endif
301
300