Commit 847e41fa authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

don't call tile_ewidth() three times from the inner loop.

2004-06-13  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs.c (shapeburst_region): don't call
	tile_ewidth() three times from the inner loop.

	* app/base/tile-manager.c (tile_manager_get): don't call
	tile_size() twice on the same tile.

	* app/base/tile-private.h: added tile_size_inline(), an inline
	version of the tile_size() function.

	* app/base/tile-cache.c
	* app/base/tile-manager.c
	* app/base/tile-swap.c
	* app/base/tile.c: use tile_size_inline() from inside the tile
	subsystem.
parent a3936388
2004-06-13 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.c (shapeburst_region): don't call
tile_ewidth() three times from the inner loop.
* app/base/tile-manager.c (tile_manager_get): don't call
tile_size() twice on the same tile.
* app/base/tile-private.h: added tile_size_inline(), an inline
version of the tile_size() function.
* app/base/tile-cache.c
* app/base/tile-manager.c
* app/base/tile-swap.c
* app/base/tile.c: use tile_size_inline() from inside the tile
subsystem.
2004-06-13 Simon Budig <simon@gimp.org>
* app/tools/gimpiscissorstool.c: Minor tweaks to two macros.
......
......@@ -149,7 +149,7 @@ tile_cache_insert (Tile *tile)
tile->listhead = NULL;
if (list == &dirty_list)
cur_cache_dirty -= tile_size (tile);
cur_cache_dirty -= tile_size_inline (tile);
}
else
{
......@@ -168,7 +168,7 @@ tile_cache_insert (Tile *tile)
}
}
cur_cache_size += tile_size (tile);
cur_cache_size += tile_size_inline (tile);
}
/* Put the tile at the end of the proper list */
......@@ -191,7 +191,7 @@ tile_cache_insert (Tile *tile)
if (tile->dirty || (tile->swap_offset == -1))
{
cur_cache_dirty += tile_size (tile);
cur_cache_dirty += tile_size_inline (tile);
#ifdef USE_PTHREADS
pthread_mutex_lock (&dirty_mutex);
......@@ -226,10 +226,10 @@ tile_cache_flush_internal (Tile *tile)
if (list)
{
cur_cache_size -= tile_size (tile);
cur_cache_size -= tile_size_inline (tile);
if (list == &dirty_list)
cur_cache_dirty -= tile_size (tile);
cur_cache_dirty -= tile_size_inline (tile);
if (tile->next)
tile->next->prev = tile->prev;
......@@ -342,7 +342,7 @@ tile_idle_thread (gpointer data)
list = tile->listhead;
if (list == &dirty_list)
cur_cache_dirty -= tile_size (tile);
cur_cache_dirty -= tile_size_inline (tile);
if (tile->next)
tile->next->prev = tile->prev;
......@@ -416,7 +416,7 @@ tile_idle_preswap (gpointer data)
clean_list.first = tile;
clean_list.last = tile;
cur_cache_dirty -= tile_size (tile);
cur_cache_dirty -= tile_size_inline (tile);
}
return TRUE;
......
......@@ -216,13 +216,16 @@ tile_manager_get (TileManager *tm,
{
/* Copy-on-write required */
Tile *newtile = g_new (Tile, 1);
gint newsize;
tile_init (newtile, (*tile_ptr)->bpp);
newtile->ewidth = (*tile_ptr)->ewidth;
newtile->eheight = (*tile_ptr)->eheight;
newtile->valid = (*tile_ptr)->valid;
newtile->data = g_new (guchar, tile_size (newtile));
newsize = tile_size_inline (newtile);
newtile->data = g_new (guchar, newsize);
if (!newtile->valid)
g_warning ("Oh boy, r/w tile is invalid... we suck. "
......@@ -235,14 +238,12 @@ tile_manager_get (TileManager *tm,
if ((*tile_ptr)->data)
{
memcpy (newtile->data,
(*tile_ptr)->data, tile_size (newtile));
memcpy (newtile->data, (*tile_ptr)->data, newsize);
}
else
{
tile_lock (*tile_ptr);
memcpy (newtile->data,
(*tile_ptr)->data, tile_size (newtile));
memcpy (newtile->data, (*tile_ptr)->data, newsize);
tile_release (*tile_ptr, FALSE);
}
......
......@@ -102,4 +102,13 @@ struct _Tile
#endif
/* an inlined version of tile_size() */
static inline gint
tile_size_inline (Tile *tile)
{
return tile->ewidth * tile->eheight * tile->bpp;
}
#endif /* __TILE_PRIVATE_H__ */
......@@ -411,8 +411,8 @@ tile_swap_command (Tile *tile,
if (swap_file->fd == -1)
goto out;
}
}
while ((* swap_file->swap_func) (swap_file->fd,
}
while ((* swap_file->swap_func) (swap_file->fd,
tile, command, swap_file->user_data));
out:
......@@ -521,7 +521,7 @@ tile_swap_default_in_async (DefSwapFile *def_swap_file,
if (!async_swapin_tiles)
async_swapin_tiles = async_swapin_tiles_end;
pthread_cond_signal (&async_swapin_signal);
pthread_mutex_unlock (&async_swapin_mutex);
......@@ -579,22 +579,22 @@ tile_swap_default_in (DefSwapFile *def_swap_file,
}
}
bytes = tile_size (tile);
bytes = tile_size_inline (tile);
tile_alloc (tile);
nleft = bytes;
while (nleft > 0)
{
do
do
{
err = read (fd, tile->data + bytes - nleft, nleft);
}
}
while ((err == -1) && ((errno == EAGAIN) || (errno == EINTR)));
if (err <= 0)
{
if (read_err_msg)
g_message ("unable to read tile data from disk: %s (%d/%d bytes read)",
g_message ("unable to read tile data from disk: %s (%d/%d bytes read)",
g_strerror (errno), err, nleft);
read_err_msg = FALSE;
return;
......@@ -624,12 +624,12 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
off_t newpos;
bytes = TILE_WIDTH * TILE_HEIGHT * tile->bpp;
rbytes = tile_size (tile);
rbytes = tile_size_inline (tile);
/* If there is already a valid swap_offset, use it */
if (tile->swap_offset == -1)
newpos = tile_swap_find_offset (def_swap_file, fd, bytes);
else
else
newpos = tile->swap_offset;
if (def_swap_file->cur_position != newpos)
......@@ -638,7 +638,7 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
if (offset == -1)
{
if (seek_err_msg)
g_message ("unable to seek to tile location on disk: %s",
g_message ("unable to seek to tile location on disk: %s",
g_strerror (errno));
seek_err_msg = FALSE;
return;
......@@ -653,7 +653,7 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
if (err <= 0)
{
if (write_err_msg)
g_message ("unable to write tile data to disk: %s (%d/%d bytes written)",
g_message ("unable to write tile data to disk: %s (%d/%d bytes written)",
g_strerror (errno), err, nleft);
write_err_msg = FALSE;
return;
......@@ -708,7 +708,7 @@ tile_swap_default_delete (DefSwapFile *def_swap_file,
{
gap2->end = gap->end;
tile_swap_gap_destroy (gap);
def_swap_file->gaps =
def_swap_file->gaps =
g_list_remove_link (def_swap_file->gaps, tmp);
g_list_free (tmp);
}
......@@ -726,7 +726,7 @@ tile_swap_default_delete (DefSwapFile *def_swap_file,
{
gap2->start = gap->start;
tile_swap_gap_destroy (gap);
def_swap_file->gaps =
def_swap_file->gaps =
g_list_remove_link (def_swap_file->gaps, tmp);
g_list_free (tmp);
}
......@@ -814,7 +814,7 @@ tile_swap_find_offset (DefSwapFile *def_swap_file,
if (gap->start == gap->end)
{
tile_swap_gap_destroy (gap);
def_swap_file->gaps =
def_swap_file->gaps =
g_list_remove_link (def_swap_file->gaps, tmp);
g_list_free (tmp);
}
......@@ -827,7 +827,7 @@ tile_swap_find_offset (DefSwapFile *def_swap_file,
offset = def_swap_file->swap_file_end;
tile_swap_resize (def_swap_file, fd,
tile_swap_resize (def_swap_file, fd,
def_swap_file->swap_file_end + swap_file_grow);
if ((offset + bytes) < (def_swap_file->swap_file_end))
......@@ -899,16 +899,16 @@ tile_swap_in_attempt (DefSwapFile *def_swap_file,
return;
}
bytes = tile_size (tile);
bytes = tile_size_inline (tile);
tile_alloc (tile);
nleft = bytes;
while (nleft > 0)
{
do
do
{
err = read (fd, tile->data + bytes - nleft, nleft);
}
}
while ((err == -1) && ((errno == EAGAIN) || (errno == EINTR)));
if (err <= 0)
......
......@@ -220,7 +220,7 @@ tile_alloc (Tile *tile)
/* Allocate the data for the tile.
*/
tile->data = g_new (guchar, tile_size (tile));
tile->data = g_new (guchar, tile_size_inline (tile));
#ifdef HINTS_SANITY
tile_exist_count++;
......
......@@ -3552,7 +3552,9 @@ shapeburst_region (PixelRegion *srcPR,
min = (gint) MIN (min_left, min_prev);
fraction = 255;
/* This might need to be changed to 0 instead of k = (min) ? (min - 1) : 0 */
/* This might need to be changed to 0
instead of k = (min) ? (min - 1) : 0 */
for (k = (min) ? (min - 1) : 0; k <= min; k++)
{
x = j;
......@@ -3561,15 +3563,21 @@ shapeburst_region (PixelRegion *srcPR,
while (y >= end)
{
gint width;
tile = tile_manager_get_tile (srcPR->tiles,
x, y, TRUE, FALSE);
tile_data = tile_data_pointer (tile,
x % TILE_WIDTH,
y % TILE_HEIGHT);
boundary = MIN ((y % TILE_HEIGHT),
(tile_ewidth (tile) - (x % TILE_WIDTH) - 1));
boundary = MIN (boundary, (y - end)) + 1;
inc = 1 - tile_ewidth (tile);
width = tile_ewidth (tile);
boundary = MIN (y % TILE_HEIGHT,
width - (x % TILE_WIDTH) - 1);
boundary = MIN (boundary, y - end) + 1;
inc = 1 - width;
while (boundary--)
{
......
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