app/base/base-types.h app/base/tile-manager.[ch] removed accessors for
2007-06-21 Sven Neumann <sven@gimp.org> * app/base/base-types.h * app/base/tile-manager.[ch] * app/base/tile-manager-private.h: removed accessors for user_data. Instead pass the user_data when setting the validation proc. * app/base/tile-pyramid.c * app/core/gimpchannel.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/tools/gimpiscissorstool.c: changed accordingly. svn path=/trunk/; revision=22820
This commit is contained in:

committed by
Sven Neumann

parent
f2e9d552b2
commit
610feafb3e
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2007-06-21 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/base-types.h
|
||||
* app/base/tile-manager.[ch]
|
||||
* app/base/tile-manager-private.h: removed accessors for user_data.
|
||||
Instead pass the user_data when setting the validation proc.
|
||||
|
||||
* app/base/tile-pyramid.c
|
||||
* app/core/gimpchannel.c
|
||||
* app/core/gimpprojection.c
|
||||
* app/core/gimpselection.c
|
||||
* app/tools/gimpiscissorstool.c: changed accordingly.
|
||||
|
||||
2007-06-21 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/tile-manager.[ch]
|
||||
|
@ -77,7 +77,8 @@ typedef struct _TilePyramid TilePyramid;
|
||||
/* functions */
|
||||
|
||||
typedef void (* TileValidateProc) (TileManager *tm,
|
||||
Tile *tile);
|
||||
Tile *tile,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
#endif /* __BASE_TYPES_H__ */
|
||||
|
@ -34,13 +34,12 @@ struct _TileManager
|
||||
gint ntile_cols; /* the number of tiles in each columns */
|
||||
|
||||
Tile **tiles; /* the tiles for this level */
|
||||
TileValidateProc validate_proc; /* this proc is called when an attempt
|
||||
* to get an invalid tile is made.
|
||||
*/
|
||||
TileValidateProc validate_proc; /* this proc is called when an attempt *
|
||||
* to get an invalid tile is made */
|
||||
gpointer user_data; /* data to pass to the validate_proc */
|
||||
|
||||
gint cached_num; /* number of cached tile */
|
||||
Tile *cached_tile; /* the actual cached tile */
|
||||
|
||||
gpointer user_data; /* hook for hanging data off of */
|
||||
};
|
||||
|
||||
|
||||
|
@ -107,11 +107,13 @@ tile_manager_unref (TileManager *tm)
|
||||
|
||||
void
|
||||
tile_manager_set_validate_proc (TileManager *tm,
|
||||
TileValidateProc proc)
|
||||
TileValidateProc proc,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (tm != NULL);
|
||||
|
||||
tm->validate_proc = proc;
|
||||
tm->user_data = user_data;
|
||||
}
|
||||
|
||||
Tile *
|
||||
@ -279,7 +281,7 @@ tile_manager_validate (TileManager *tm,
|
||||
tile->valid = TRUE;
|
||||
|
||||
if (tm->validate_proc)
|
||||
(* tm->validate_proc) (tm, tile);
|
||||
(* tm->validate_proc) (tm, tile, tm->user_data);
|
||||
|
||||
#ifdef DEBUG_TILE_MANAGER
|
||||
g_printerr ("%c", tm->user_data ? 'V' : 'v');
|
||||
@ -488,25 +490,8 @@ tile_manager_invalidate_area (TileManager *tm,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tile_manager_set_user_data (TileManager *tm,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (tm != NULL);
|
||||
|
||||
tm->user_data = user_data;
|
||||
}
|
||||
|
||||
gpointer
|
||||
tile_manager_get_user_data (const TileManager *tm)
|
||||
{
|
||||
g_return_val_if_fail (tm != NULL, NULL);
|
||||
|
||||
return tm->user_data;
|
||||
}
|
||||
|
||||
gint
|
||||
tile_manager_width (const TileManager *tm)
|
||||
tile_manager_width (const TileManager *tm)
|
||||
{
|
||||
g_return_val_if_fail (tm != NULL, 0);
|
||||
|
||||
|
@ -44,7 +44,8 @@ void tile_manager_unref (TileManager *tm);
|
||||
* allocated, but not initialized.
|
||||
*/
|
||||
void tile_manager_set_validate_proc (TileManager *tm,
|
||||
TileValidateProc proc);
|
||||
TileValidateProc proc,
|
||||
gpointer user_data);
|
||||
|
||||
/* Get a specified tile from a tile manager.
|
||||
*/
|
||||
@ -87,10 +88,6 @@ void tile_manager_invalidate_area (TileManager *tm,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
void tile_manager_set_user_data (TileManager *tm,
|
||||
gpointer user_data);
|
||||
gpointer tile_manager_get_user_data (const TileManager *tm);
|
||||
|
||||
gint tile_manager_width (const TileManager *tm);
|
||||
gint tile_manager_height (const TileManager *tm);
|
||||
gint tile_manager_bpp (const TileManager *tm);
|
||||
|
@ -44,7 +44,8 @@ struct _TilePyramid
|
||||
static gint tile_pyramid_alloc_levels (TilePyramid *pyramid,
|
||||
gint top_level);
|
||||
static void tile_pyramid_validate_tile (TileManager *tm,
|
||||
Tile *tile);
|
||||
Tile *tile,
|
||||
TileManager *tm_below);
|
||||
static void tile_pyramid_write_quarter (Tile *dest,
|
||||
Tile *src,
|
||||
gint i,
|
||||
@ -242,9 +243,9 @@ tile_pyramid_invalidate_area (TilePyramid *pyramid,
|
||||
* tile_pyramid_set_validate_proc:
|
||||
* @pyramid: a #TilePyramid
|
||||
* @proc: a function to validate the bottom level tiles
|
||||
* @user_data: data to attach to the bottom level tile manager
|
||||
* @user_data: data to pass to the validation @proc
|
||||
*
|
||||
* Sets a validation proc and user data on the bottom-most tile manager.
|
||||
* Sets a validation procedure on the bottom-most tile manager.
|
||||
**/
|
||||
void
|
||||
tile_pyramid_set_validate_proc (TilePyramid *pyramid,
|
||||
@ -253,8 +254,7 @@ tile_pyramid_set_validate_proc (TilePyramid *pyramid,
|
||||
{
|
||||
g_return_if_fail (pyramid != NULL);
|
||||
|
||||
tile_manager_set_validate_proc (pyramid->tiles[0], proc);
|
||||
tile_manager_set_user_data (pyramid->tiles[0], user_data);
|
||||
tile_manager_set_validate_proc (pyramid->tiles[0], proc, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,14 +353,10 @@ tile_pyramid_alloc_levels (TilePyramid *pyramid,
|
||||
pyramid->top_level = level;
|
||||
pyramid->tiles[level] = tile_manager_new (width, height, pyramid->bytes);
|
||||
|
||||
tile_manager_set_user_data (pyramid->tiles[level], pyramid);
|
||||
|
||||
/* Use the level below to validate tiles. */
|
||||
tile_manager_set_validate_proc (pyramid->tiles[level],
|
||||
tile_pyramid_validate_tile);
|
||||
|
||||
tile_manager_set_user_data (pyramid->tiles[level],
|
||||
pyramid->tiles[level - 1]);
|
||||
(TileValidateProc) tile_pyramid_validate_tile,
|
||||
pyramid->tiles[level - 1]);
|
||||
}
|
||||
|
||||
return pyramid->top_level;
|
||||
@ -368,19 +364,19 @@ tile_pyramid_alloc_levels (TilePyramid *pyramid,
|
||||
|
||||
static void
|
||||
tile_pyramid_validate_tile (TileManager *tm,
|
||||
Tile *tile)
|
||||
Tile *tile,
|
||||
TileManager *tm_below)
|
||||
{
|
||||
TileManager *level_below = tile_manager_get_user_data (tm);
|
||||
gint tile_col;
|
||||
gint tile_row;
|
||||
gint i, j;
|
||||
gint tile_col;
|
||||
gint tile_row;
|
||||
gint i, j;
|
||||
|
||||
tile_manager_get_tile_col_row (tm, tile, &tile_col, &tile_row);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
Tile *source = tile_manager_get_at (level_below,
|
||||
Tile *source = tile_manager_get_at (tm_below,
|
||||
tile_col * 2 + i,
|
||||
tile_row * 2 + j,
|
||||
TRUE, FALSE);
|
||||
|
@ -207,7 +207,7 @@ static void gimp_channel_real_shrink (GimpChannel *channel,
|
||||
gboolean edge_lock,
|
||||
gboolean push_undo);
|
||||
|
||||
static void gimp_channel_validate (TileManager *tm,
|
||||
static void gimp_channel_validate_tile (TileManager *tm,
|
||||
Tile *tile);
|
||||
|
||||
|
||||
@ -1461,8 +1461,8 @@ gimp_channel_real_shrink (GimpChannel *channel,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_channel_validate (TileManager *tm,
|
||||
Tile *tile)
|
||||
gimp_channel_validate_tile (TileManager *tm,
|
||||
Tile *tile)
|
||||
{
|
||||
/* Set the contents of the tile to empty */
|
||||
memset (tile_data_pointer (tile, 0, 0),
|
||||
@ -1707,7 +1707,8 @@ gimp_channel_new_mask (GimpImage *image,
|
||||
_("Selection Mask"), NULL);
|
||||
|
||||
tile_manager_set_validate_proc (GIMP_DRAWABLE (new_channel)->tiles,
|
||||
gimp_channel_validate);
|
||||
(TileValidateProc) gimp_channel_validate_tile,
|
||||
NULL);
|
||||
|
||||
return new_channel;
|
||||
}
|
||||
|
@ -82,7 +82,8 @@ static void gimp_projection_invalidate (GimpProjection *proj,
|
||||
guint w,
|
||||
guint h);
|
||||
static void gimp_projection_validate_tile (TileManager *tm,
|
||||
Tile *tile);
|
||||
Tile *tile,
|
||||
GimpProjection *proj);
|
||||
static void gimp_projection_image_update (GimpImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
@ -311,7 +312,8 @@ gimp_projection_get_tiles_at_level (GimpProjection *proj,
|
||||
proj->image->height);
|
||||
|
||||
tile_pyramid_set_validate_proc (proj->pyramid,
|
||||
gimp_projection_validate_tile, proj);
|
||||
(TileValidateProc) gimp_projection_validate_tile,
|
||||
proj);
|
||||
}
|
||||
|
||||
return tile_pyramid_get_tiles (proj->pyramid, level);
|
||||
@ -644,11 +646,11 @@ gimp_projection_invalidate (GimpProjection *proj,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_projection_validate_tile (TileManager *tm,
|
||||
Tile *tile)
|
||||
gimp_projection_validate_tile (TileManager *tm,
|
||||
Tile *tile,
|
||||
GimpProjection *proj)
|
||||
{
|
||||
GimpProjection *proj = tile_manager_get_user_data (tm);
|
||||
gint x, y;
|
||||
gint x, y;
|
||||
|
||||
/* Find the coordinates of this tile */
|
||||
tile_manager_get_tile_coordinates (tm, tile, &x, &y);
|
||||
|
@ -124,7 +124,7 @@ static void gimp_selection_shrink (GimpChannel *channel,
|
||||
gboolean edge_lock,
|
||||
gboolean push_undo);
|
||||
|
||||
static void gimp_selection_validate (TileManager *tm,
|
||||
static void gimp_selection_validate_tile (TileManager *tm,
|
||||
Tile *tile);
|
||||
|
||||
|
||||
@ -502,8 +502,8 @@ gimp_selection_shrink (GimpChannel *channel,
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_selection_validate (TileManager *tm,
|
||||
Tile *tile)
|
||||
gimp_selection_validate_tile (TileManager *tm,
|
||||
Tile *tile)
|
||||
{
|
||||
/* Set the contents of the tile to empty */
|
||||
memset (tile_data_pointer (tile, 0, 0),
|
||||
@ -536,9 +536,9 @@ gimp_selection_new (GimpImage *image,
|
||||
channel->x2 = width;
|
||||
channel->y2 = height;
|
||||
|
||||
/* Set the validate procedure */
|
||||
tile_manager_set_validate_proc (GIMP_DRAWABLE (channel)->tiles,
|
||||
gimp_selection_validate);
|
||||
(TileValidateProc) gimp_selection_validate_tile,
|
||||
NULL);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
@ -1706,11 +1706,11 @@ find_optimal_path (TileManager *gradient_map,
|
||||
/* Called to fill in a newly referenced tile in the gradient map */
|
||||
static void
|
||||
gradmap_tile_validate (TileManager *tm,
|
||||
Tile *tile)
|
||||
Tile *tile,
|
||||
GimpImage *image)
|
||||
{
|
||||
static gboolean first_gradient = TRUE;
|
||||
|
||||
GimpImage *image = tile_manager_get_user_data (tm);
|
||||
GimpPickable *pickable;
|
||||
Tile *srctile;
|
||||
PixelRegion srcPR, destPR;
|
||||
@ -1846,8 +1846,10 @@ gradient_map_new (GimpImage *image)
|
||||
|
||||
tm = tile_manager_new (image->width, image->height,
|
||||
sizeof (guint8) * COST_WIDTH);
|
||||
tile_manager_set_user_data (tm, image);
|
||||
tile_manager_set_validate_proc (tm, gradmap_tile_validate);
|
||||
|
||||
tile_manager_set_validate_proc (tm,
|
||||
(TileValidateProc) gradmap_tile_validate,
|
||||
image);
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
Reference in New Issue
Block a user