made tile_ref_count a static variable and added a function to access it.

2007-02-22  Sven Neumann  <sven@gimp.org>

	* app/base/tile.[ch]: made tile_ref_count a static variable and
	added a function to access it.  Declared other (unused) global
	counters as static variables and moved them into #ifdefs.

	* app/base/tile-swap.c: use the function instead of declaring
	tile_ref_count as extern.

	* app/base/tile-manager.c
	* app/base/pixel-surround.c: cosmetics.


svn path=/trunk/; revision=21975
This commit is contained in:
Sven Neumann 2007-02-22 22:28:24 +00:00 committed by Sven Neumann
parent cc3879beca
commit 3f7c188f59
6 changed files with 69 additions and 20 deletions

View File

@ -1,3 +1,15 @@
2007-02-22 Sven Neumann <sven@gimp.org>
* app/base/tile.[ch]: made tile_ref_count a static variable and
added a function to access it. Declared other (unused) global
counters as static variables and moved them into #ifdefs.
* app/base/tile-swap.c: use the function instead of declaring
tile_ref_count as extern.
* app/base/tile-manager.c
* app/base/pixel-surround.c: cosmetics.
2007-02-23 Tor Lillqvist <tml@novell.com>
* configure.in: Fix logic error in saving and restoring CPPFLAGS

View File

@ -98,7 +98,7 @@ pixel_surround_lock (PixelSurround *ps,
i % TILE_WIDTH,
j % TILE_HEIGHT);
for (k = buff; k < buff+ps->bpp; ++k, ++ptr)
for (k = buff; k < buff + ps->bpp; ++k, ++ptr)
*ptr = *k;
tile_release (tile, FALSE);

View File

@ -149,7 +149,7 @@ tile_manager_get (TileManager *tm,
if ((tile_num < 0) || (tile_num >= ntiles))
return NULL;
if (!tm->tiles)
if (! tm->tiles)
{
tm->tiles = g_new (Tile *, ntiles);
tiles = tm->tiles;

View File

@ -174,12 +174,11 @@ tile_swap_exit1 (gpointer key,
gpointer value,
gpointer data)
{
extern gint tile_ref_count;
SwapFile *swap_file;
DefSwapFile *def_swap_file;
if (tile_ref_count != 0)
g_warning ("tile ref count balance: %d\n", tile_ref_count);
if (tile_global_refcount () != 0)
g_warning ("tile ref count balance: %d\n", tile_global_refcount ());
swap_file = value;
if (swap_file->swap_func == tile_swap_default)

View File

@ -32,15 +32,34 @@
/* Uncomment for verbose debugging on copy-on-write logic */
/* #define TILE_DEBUG */
/* Uncomment to enable global counters to profile the tile system. */
/* #define TILE_PROFILING */
/* Sanity checks on tile hinting code */
/* #define HINTS_SANITY */
/* This is being used from tile-swap, but just for debugging purposes. */
static gint tile_ref_count = 0;
#ifdef TILE_PROFILING
static gint tile_count = 0;
static gint tile_share_count = 0;
static gint tile_active_count = 0;
#ifdef HINTS_SANITY
static gint tile_exist_peak = 0;
static gint tile_exist_count = 0;
#endif
#endif
static void tile_destroy (Tile *tile);
gint tile_count = 0;
void
tile_sanitize_rowhints (Tile *tile)
{
@ -58,7 +77,10 @@ tile_get_rowhint (Tile *tile,
return tile->rowhint[yoff];
}
else
g_error("GET_ROWHINT OUT OF RANGE");
{
g_error ("GET_ROWHINT OUT OF RANGE");
}
return TILEROWHINT_OUTOFRANGE;
#else
return tile->rowhint[yoff];
@ -103,17 +125,10 @@ tile_init (Tile *tile,
tile->listhead = NULL;
tile->rowhint = NULL;
#ifdef TILE_PROFILING
tile_count++;
}
gint tile_ref_count = 0;
gint tile_share_count = 0;
gint tile_active_count = 0;
#ifdef HINTS_SANITY
gint tile_exist_peak = 0;
gint tile_exist_count = 0;
#endif
}
void
tile_lock (Tile *tile)
@ -133,8 +148,12 @@ tile_lock (Tile *tile)
/* remove from cache, move to main store */
tile_cache_flush (tile);
}
#ifdef TILE_PROFILING
tile_active_count++;
#endif
}
if (tile->data == NULL)
{
/* There is no data, so the tile must be swapped out */
@ -173,15 +192,15 @@ tile_release (Tile *tile,
if (tile->rowhint)
{
for (y = 0; y < tile->eheight; y++)
{
tile->rowhint[y] = TILEROWHINT_UNKNOWN;
}
tile->rowhint[y] = TILEROWHINT_UNKNOWN;
}
}
if (tile->ref_count == 0)
{
#ifdef TILE_PROFILING
tile_active_count--;
#endif
if (tile->share_count == 0)
{
@ -208,11 +227,13 @@ tile_alloc (Tile *tile)
*/
tile->data = g_new (guchar, tile->size);
#ifdef TILE_PROFILING
#ifdef HINTS_SANITY
tile_exist_count++;
if (tile_exist_count > tile_exist_peak)
tile_exist_peak = tile_exist_count;
#endif
#endif
}
static void
@ -250,11 +271,14 @@ tile_destroy (Tile *tile)
g_free (tile);
#ifdef TILE_PROFILING
tile_count--;
#ifdef HINTS_SANITY
tile_exist_count--;
#endif
#endif
}
gint
@ -310,7 +334,10 @@ tile_attach (Tile *tile,
}
tile->share_count++;
#ifdef TILE_PROFILING
tile_share_count++;
#endif
#ifdef TILE_DEBUG
g_printerr ("tile_attach: %p -> (%p,%d) *%d\n",
@ -357,7 +384,10 @@ tile_detach (Tile *tile,
*link = tmp->next;
g_free (tmp);
#ifdef TILE_PROFILING
tile_share_count--;
#endif
tile->share_count--;
if (tile->share_count == 0 && tile->ref_count == 0)
@ -373,3 +403,9 @@ tile_data_pointer (Tile *tile,
return (gpointer) (tile->data + offset * tile->bpp);
}
gint
tile_global_refcount (void)
{
return tile_ref_count;
}

View File

@ -85,6 +85,8 @@ void * tile_data_pointer (Tile *tile,
gint xoff,
gint yoff);
gint tile_global_refcount (void);
/* tile_attach attaches a tile to a tile manager: this function
* increments the tile's share count and inserts a tilelink into the
* tile's link list. tile_detach reverses the process.