Commit 32058a45 authored by scott's avatar scott
Browse files

More tile-related stuff.

--sg
parent ab813346
Sat Jul 11 12:20:50 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* app/paint_funcs.c (copy_region): Added missing tile_release
call.
* app/tile.c app/tile_cache.c: Added some sanity checks and
debugging stuff.
Sat Jul 11 16:59:22 BST 1998 Adam D. Moss <adam@gimp.org>
* app/paint_funcs.c: Shaved about 25% off the time spent in
......
......@@ -107,7 +107,11 @@ tile_cache_insert (Tile *tile)
*/
while ((cur_cache_size + max_tile_size) > max_cache_size)
{
if (!tile_cache_zorch_next()) goto out;
if (!tile_cache_zorch_next())
{
g_warning ("cache: unable to find room for a tile");
goto out;
}
}
/* Note the increase in the number of bytes the cache
......@@ -226,6 +230,8 @@ tile_cache_zorch_next ()
{
Tile *tile;
/* printf("cache zorch: %u/%u\n", cur_cache_size, cur_cache_dirty); */
if (clean_list.first) tile = clean_list.first;
else if (dirty_list.first) tile = dirty_list.first;
else return FALSE;
......
......@@ -62,6 +62,8 @@ tile_init (Tile *tile,
}
int tile_ref_count = 0;
int tile_share_count = 0;
int tile_active_count = 0;
void
tile_lock (Tile *tile)
......@@ -88,6 +90,7 @@ tile_lock (Tile *tile)
/* There is no data, so the tile must be swapped out */
tile_swap_in (tile);
}
tile_active_count ++;
}
TILE_MUTEX_UNLOCK (tile);
......@@ -133,6 +136,7 @@ tile_release (Tile *tile, int dirty)
tile cache */
tile_cache_insert (tile);
}
tile_active_count--;
}
TILE_MUTEX_UNLOCK (tile);
......@@ -142,17 +146,26 @@ void
tile_alloc (Tile *tile)
{
if (tile->data)
goto out;
return;
/* Allocate the data for the tile.
*/
tile->data = g_new (guchar, tile_size (tile));
out:
}
static void
tile_destroy (Tile *tile)
{
if (tile->ref_count)
{
g_warning ("tried to destroy a ref'd tile");
return;
}
if (tile->share_count)
{
g_warning ("tried to destroy an attached tile");
return;
}
if (tile->data)
{
g_free (tile->data);
......@@ -196,6 +209,7 @@ tile_attach (Tile *tile, void *tm, int tile_num)
tile_manager_validate ((TileManager*) tile->tlink->tm, tile);
}
tile->share_count++;
tile_share_count++;
#ifdef TILE_DEBUG
g_print("tile_attach: %p -> (%p,%d) *%d\n", tile, tm, tile_num, tile->share_count);
#endif
......@@ -232,6 +246,7 @@ tile_detach (Tile *tile, void *tm, int tile_num)
*link = tmp->next;
g_free (tmp);
tile_share_count--;
tile->share_count--;
if (tile->share_count == 0 && tile->ref_count == 0)
......
......@@ -2615,7 +2615,8 @@ copy_region (PixelRegion *src,
tile_manager_map_tile (dest->tiles,
xstepper, ystepper, 0,
src_tile);
tile_release (src_tile, FALSE);
}
}
#if defined (TILE_DEBUG)
......
......@@ -2615,7 +2615,8 @@ copy_region (PixelRegion *src,
tile_manager_map_tile (dest->tiles,
xstepper, ystepper, 0,
src_tile);
tile_release (src_tile, FALSE);
}
}
#if defined (TILE_DEBUG)
......
......@@ -62,6 +62,8 @@ tile_init (Tile *tile,
}
int tile_ref_count = 0;
int tile_share_count = 0;
int tile_active_count = 0;
void
tile_lock (Tile *tile)
......@@ -88,6 +90,7 @@ tile_lock (Tile *tile)
/* There is no data, so the tile must be swapped out */
tile_swap_in (tile);
}
tile_active_count ++;
}
TILE_MUTEX_UNLOCK (tile);
......@@ -133,6 +136,7 @@ tile_release (Tile *tile, int dirty)
tile cache */
tile_cache_insert (tile);
}
tile_active_count--;
}
TILE_MUTEX_UNLOCK (tile);
......@@ -142,17 +146,26 @@ void
tile_alloc (Tile *tile)
{
if (tile->data)
goto out;
return;
/* Allocate the data for the tile.
*/
tile->data = g_new (guchar, tile_size (tile));
out:
}
static void
tile_destroy (Tile *tile)
{
if (tile->ref_count)
{
g_warning ("tried to destroy a ref'd tile");
return;
}
if (tile->share_count)
{
g_warning ("tried to destroy an attached tile");
return;
}
if (tile->data)
{
g_free (tile->data);
......@@ -196,6 +209,7 @@ tile_attach (Tile *tile, void *tm, int tile_num)
tile_manager_validate ((TileManager*) tile->tlink->tm, tile);
}
tile->share_count++;
tile_share_count++;
#ifdef TILE_DEBUG
g_print("tile_attach: %p -> (%p,%d) *%d\n", tile, tm, tile_num, tile->share_count);
#endif
......@@ -232,6 +246,7 @@ tile_detach (Tile *tile, void *tm, int tile_num)
*link = tmp->next;
g_free (tmp);
tile_share_count--;
tile->share_count--;
if (tile->share_count == 0 && tile->ref_count == 0)
......
......@@ -107,7 +107,11 @@ tile_cache_insert (Tile *tile)
*/
while ((cur_cache_size + max_tile_size) > max_cache_size)
{
if (!tile_cache_zorch_next()) goto out;
if (!tile_cache_zorch_next())
{
g_warning ("cache: unable to find room for a tile");
goto out;
}
}
/* Note the increase in the number of bytes the cache
......@@ -226,6 +230,8 @@ tile_cache_zorch_next ()
{
Tile *tile;
/* printf("cache zorch: %u/%u\n", cur_cache_size, cur_cache_dirty); */
if (clean_list.first) tile = clean_list.first;
else if (dirty_list.first) tile = dirty_list.first;
else return FALSE;
......
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