Commit 3e5d269e authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

provide a macro version of tile_data_pointer().

2008-08-25  Sven Neumann  <sven@gimp.org>

	* app/base/tile-private.h: provide a macro version of
	tile_data_pointer().

	* app/base/tile.c (tile_data_pointer): turned into a wrapper
	around the TILE_DATA_POINTER() macro.

	* app/base/tile-manager.c (read_pixel_data) (read_pixel_data_1)
	(write_pixel_data) (write_pixel_data_1): access tile struct
	members directly and use the new macro to access the tile data.


svn path=/trunk/; revision=26757
parent 35980b22
2008-08-25 Sven Neumann <sven@gimp.org>
* app/base/tile-private.h: provide a macro version of
tile_data_pointer().
* app/base/tile.c (tile_data_pointer): turned into a wrapper
around the TILE_DATA_POINTER() macro.
* app/base/tile-manager.c (read_pixel_data) (read_pixel_data_1)
(write_pixel_data) (write_pixel_data_1): access tile struct
members directly and use the new macro to access the tile data.
2008-08-25 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c (render_image_tile_fault):
......
......@@ -679,21 +679,21 @@ read_pixel_data (TileManager *tm,
for (y = y1; y <= y2; y += TILE_HEIGHT - (y % TILE_HEIGHT))
for (x = x1; x <= x2; x += TILE_WIDTH - (x % TILE_WIDTH))
{
Tile *t = tile_manager_get_tile (tm, x, y, TRUE, FALSE);
const guchar *s = tile_data_pointer (t, x, y);
guchar *d = buffer + stride * (y - y1) + tm->bpp * (x - x1);
Tile *tile = tile_manager_get_tile (tm, x, y, TRUE, FALSE);
const guchar *s = TILE_DATA_POINTER (tile, x, y);
guchar *d = buffer + stride * (y - y1) + tm->bpp * (x - x1);
guint rows, cols;
guint srcstride;
rows = tile_eheight (t) - y % TILE_HEIGHT;
rows = tile->eheight - y % TILE_HEIGHT;
if (rows > (y2 - y + 1))
rows = y2 - y + 1;
cols = tile_ewidth (t) - x % TILE_WIDTH;
cols = tile->ewidth - x % TILE_WIDTH;
if (cols > (x2 - x + 1))
cols = x2 - x + 1;
srcstride = tile_ewidth (t) * tile_bpp (t);
srcstride = tile->ewidth * tile->bpp;
while (rows--)
{
......@@ -703,7 +703,7 @@ read_pixel_data (TileManager *tm,
d += stride;
}
tile_release (t, FALSE);
tile_release (tile, FALSE);
}
}
......@@ -721,21 +721,21 @@ write_pixel_data (TileManager *tm,
for (y = y1; y <= y2; y += TILE_HEIGHT - (y % TILE_HEIGHT))
for (x = x1; x <= x2; x += TILE_WIDTH - (x % TILE_WIDTH))
{
Tile *t = tile_manager_get_tile (tm, x, y, TRUE, TRUE);
const guchar *s = buffer + stride * (y - y1) + tm->bpp * (x - x1);
guchar *d = tile_data_pointer (t, x, y);
Tile *tile = tile_manager_get_tile (tm, x, y, TRUE, TRUE);
const guchar *s = buffer + stride * (y - y1) + tm->bpp * (x - x1);
guchar *d = TILE_DATA_POINTER (tile, x, y);
guint rows, cols;
guint dststride;
rows = tile_eheight (t) - y % TILE_HEIGHT;
rows = tile->eheight - y % TILE_HEIGHT;
if (rows > (y2 - y + 1))
rows = y2 - y + 1;
cols = tile_ewidth (t) - x % TILE_WIDTH;
cols = tile->ewidth - x % TILE_WIDTH;
if (cols > (x2 - x + 1))
cols = x2 - x + 1;
dststride = tile_ewidth (t) * tile_bpp (t);
dststride = tile->ewidth * tile->bpp;
while (rows--)
{
......@@ -745,7 +745,7 @@ write_pixel_data (TileManager *tm,
d += dststride;
}
tile_release (t, TRUE);
tile_release (tile, TRUE);
}
}
......@@ -783,7 +783,7 @@ read_pixel_data_1 (TileManager *tm,
}
{
const guchar *src = tile_data_pointer (tm->cached_tile, x, y);
const guchar *src = TILE_DATA_POINTER (tm->cached_tile, x, y);
switch (tm->bpp)
{
......@@ -806,7 +806,7 @@ write_pixel_data_1 (TileManager *tm,
const guchar *buffer)
{
Tile *tile = tile_manager_get_tile (tm, x, y, TRUE, TRUE);
guchar *dest = tile_data_pointer (tile, x, y);
guchar *dest = TILE_DATA_POINTER (tile, x, y);
switch (tm->bpp)
{
......
......@@ -77,4 +77,11 @@ struct _Tile
};
/* tile_data_pointer() as a macro so that it can be inlined */
#define TILE_DATA_POINTER(tile,x,y) \
((tile)->data + \
(((y) % TILE_HEIGHT) * (tile)->ewidth + ((x) % TILE_WIDTH)) * (tile)->bpp)
#endif /* __TILE_PRIVATE_H__ */
......@@ -53,7 +53,7 @@ static gint tile_exist_count = 0;
#endif
static void tile_destroy (Tile *tile);
static void tile_destroy (Tile *tile);
Tile *
......@@ -333,9 +333,7 @@ tile_data_pointer (Tile *tile,
gint xoff,
gint yoff)
{
gsize offset = (yoff % TILE_HEIGHT) * tile->ewidth + (xoff % TILE_WIDTH);
return (gpointer) (tile->data + offset * tile->bpp);
return TILE_DATA_POINTER (tile, xoff, yoff);
}
gint
......
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