gimp/app/base/tile-manager.h
Michael Natterer 707e597665 added "gint ref_count" to the TileManager struct.
2003-05-26  Michael Natterer  <mitch@gimp.org>

	* app/base/tile-manager-private.h: added "gint ref_count" to the
	TileManager struct.

	* app/base/tile-manager.[ch]: replaced tile_manager_destroy()
	by tile_manager_ref() and tile_manager_unref().

	* app/core/gimpimage-undo-push.c: ref the tile managers stored in
	the undo system and DON'T destroy them if no undo could be pushed.
	Should fix the remaining crashes with undo disabled like in
	bug #9350.

	(!!!) Note that the tiles passed to gimp_image_undo_push_image()
	and gimp_drawable_push_undo() as well as the tile managers of
	drawables passed to gimp_image_undo_push_[layer|channel]_mod()
	must be unref'ed by the caller now.

	* app/core/gimpdrawable-transform.c (gimp_drawable_transform_paste):
	don't take ownership of the passed tiles but ref them if needed.

	(!!!) Callers must unref the passed tiles themselves now.

	* app/core/gimpbuffer.c
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpdrawable-offset.c
	* app/core/gimpdrawable.c
	* app/core/gimpedit.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage-mask.c
	* app/core/gimpimage-projection.c
	* app/core/gimpimage.c
	* app/core/gimpimagemap.c
	* app/core/gimplayer-floating-sel.c
	* app/core/gimplayer.c
	* app/paint/gimppaintcore.c
	* app/text/gimptextlayer.c
	* app/tools/gimpinktool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimptransformtool-undo.c
	* app/tools/gimptransformtool.c: changed accordingly.
2003-05-26 17:02:06 +00:00

177 lines
5.8 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __TILE_MANAGER_H__
#define __TILE_MANAGER_H__
struct _PixelDataHandle
{
guchar *data;
gint width;
gint height;
gint stride;
gint bpp;
};
/* Creates a new tile manager with the specified
* width for the toplevel. The toplevel sizes is
* used to compute the number of levels and there
* size. Each level is 1/2 the width and height of
* the level above it.
*
* The toplevel is level 0. The smallest level in the
* hierarchy is "nlevels - 1". That level will be smaller
* than TILE_WIDTH x TILE_HEIGHT
*/
TileManager * tile_manager_new (gint toplevel_width,
gint toplevel_height,
gint bpp);
/* Ref/Unref a tile manager.
*/
TileManager * tile_manager_ref (TileManager *tm);
void tile_manager_unref (TileManager *tm);
/* Set the validate procedure for the tile manager.
* The validate procedure is called when an invalid tile
* is referenced. If the procedure is NULL, then the tile
* is set to valid and its memory is allocated, but
* not initialized.
*/
void tile_manager_set_validate_proc (TileManager *tm,
TileValidateProc proc);
/* Get a specified tile from a tile manager.
*/
Tile * tile_manager_get_tile (TileManager *tm,
gint xpixel,
gint ypixel,
gint wantread,
gint wantwrite);
/* Get a specified tile from a tile manager.
*/
Tile * tile_manager_get (TileManager *tm,
gint tile_num,
gint wantread,
gint wantwrite);
/* Request that (if possible) the tile at x,y be swapped
* in. This is only a hint to improve performance; no guarantees.
* The tile may be swapped in or otherwise made more accessible
* if it is convenient...
*/
void tile_manager_get_async (TileManager *tm,
gint xpixel,
gint ypixel);
void tile_manager_map_tile (TileManager *tm,
gint xpixel,
gint ypixel,
Tile *srctile);
void tile_manager_map (TileManager *tm,
gint tile_num,
Tile *srctile);
/* Validate a tiles memory.
*/
void tile_manager_validate (TileManager *tm,
Tile *tile);
void tile_invalidate (Tile **tile_ptr,
TileManager *tm,
gint tile_num);
void tile_invalidate_tile (Tile **tile_ptr,
TileManager *tm,
gint xpixel,
gint ypixel);
/* Given a toplevel tile, this procedure will invalidate
* (set the dirty bit) for this toplevel tile.
*/
void tile_manager_invalidate_tiles (TileManager *tm,
Tile *toplevel_tile);
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);
void tile_manager_get_offsets (const TileManager *tm,
gint *x,
gint *y);
void tile_manager_set_offsets (TileManager *tm,
gint x,
gint y);
gsize tile_manager_get_memsize (const TileManager *tm);
void tile_manager_get_tile_coordinates (TileManager *tm,
Tile *tile,
gint *x,
gint *y);
void tile_manager_map_over_tile (TileManager *tm,
Tile *tile,
Tile *srctile);
PixelDataHandle * request_pixel_data (TileManager *tm,
gint x1,
gint y1,
gint x2,
gint y2,
gboolean wantread,
gboolean wantwrite);
void release_pixel_data (PixelDataHandle *pdh);
void read_pixel_data (TileManager *tm,
gint x1,
gint y1,
gint x2,
gint y2,
guchar *buffer,
guint stride);
void write_pixel_data (TileManager *tm,
gint x1,
gint y1,
gint x2,
gint y2,
guchar *buffer,
guint stride);
/* Fill buffer with the pixeldata for the pixel at coordinates x,y
* if x,y is outside the area of the tilemanger, nothing is done.
*/
void read_pixel_data_1 (TileManager *tm,
gint x,
gint y,
guchar *buffer);
void write_pixel_data_1 (TileManager *tm,
gint x,
gint y,
guchar *buffer);
#endif /* __TILE_MANAGER_H__ */