tile-manager.h 6.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* 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
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 */
18

Elliot Lee's avatar
Elliot Lee committed
19
20
21
#ifndef __TILE_MANAGER_H__
#define __TILE_MANAGER_H__

22
struct _PixelDataHandle
23
{
Sven Neumann's avatar
Sven Neumann committed
24
25
26
27
28
  guchar *data;
  gint    width;
  gint	  height;
  gint    stride;
  gint	  bpp;
29
};
Elliot Lee's avatar
Elliot Lee committed
30
31
32
33
34
35

/* 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.
Michael Natterer's avatar
Michael Natterer committed
36
 *
Elliot Lee's avatar
Elliot Lee committed
37
38
39
40
 * 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
 */
41
42
43
TileManager * tile_manager_new               (gint toplevel_width,
					      gint toplevel_height,
					      gint bpp);
Elliot Lee's avatar
Elliot Lee committed
44

45
/* Ref/Unref a tile manager.
Elliot Lee's avatar
Elliot Lee committed
46
 */
47
48
TileManager * tile_manager_ref               (TileManager *tm);
void          tile_manager_unref             (TileManager *tm);
Elliot Lee's avatar
Elliot Lee committed
49
50
51
52
53
54
55

/* 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.
 */
56
57
void          tile_manager_set_validate_proc (TileManager      *tm,
					      TileValidateProc  proc);
Elliot Lee's avatar
Elliot Lee committed
58

59
/* Get a specified tile from a tile manager.
Elliot Lee's avatar
Elliot Lee committed
60
 */
61
62
63
Tile        * tile_manager_get_tile          (TileManager *tm,
					      gint         xpixel,
					      gint         ypixel,
64
65
					      gint         wantread,
					      gint         wantwrite);
Elliot Lee's avatar
Elliot Lee committed
66
67
68

/* Get a specified tile from a tile manager.
 */
69
Tile        * tile_manager_get               (TileManager *tm,
70
71
72
					      gint         tile_num,
					      gint         wantread,
					      gint         wantwrite);
73

74
/* Request that (if possible) the tile at x,y be swapped
75
76
77
78
 * 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...
 */
79
80
81
void          tile_manager_get_async         (TileManager *tm,
					      gint         xpixel,
					      gint         ypixel);
82

83
84
85
86
void          tile_manager_map_tile          (TileManager *tm,
					      gint         xpixel,
					      gint         ypixel,
					      Tile        *srctile);
87

88
void          tile_manager_map               (TileManager *tm,
89
					      gint         tile_num,
90
					      Tile        *srctile);
Elliot Lee's avatar
Elliot Lee committed
91
92
93

/* Validate a tiles memory.
 */
94
95
void          tile_manager_validate          (TileManager  *tm,
					      Tile         *tile);
Elliot Lee's avatar
Elliot Lee committed
96

97
98
void          tile_invalidate                (Tile        **tile_ptr,
					      TileManager  *tm,
99
					      gint          tile_num);
100
void          tile_invalidate_tile           (Tile        **tile_ptr,
101
					      TileManager  *tm,
102
103
					      gint          xpixel,
					      gint          ypixel);
scott's avatar
scott committed
104

Elliot Lee's avatar
Elliot Lee committed
105
/* Given a toplevel tile, this procedure will invalidate
106
 *  (set the dirty bit) for this toplevel tile.
Elliot Lee's avatar
Elliot Lee committed
107
 */
Michael Natterer's avatar
Michael Natterer committed
108
109
void          tile_manager_invalidate_tiles  (TileManager       *tm,
					      Tile              *toplevel_tile);
110

Michael Natterer's avatar
Michael Natterer committed
111
112
113
void          tile_manager_set_user_data     (TileManager       *tm,
					      gpointer           user_data);
gpointer      tile_manager_get_user_data     (const TileManager *tm);
114

Michael Natterer's avatar
Michael Natterer committed
115
116
117
gint          tile_manager_width             (const TileManager *tm);
gint          tile_manager_height            (const TileManager *tm);
gint          tile_manager_bpp               (const TileManager *tm);
118

Michael Natterer's avatar
Michael Natterer committed
119
120
121
122
123
124
void          tile_manager_get_offsets       (const TileManager *tm,
					      gint              *x,
					      gint              *y);
void          tile_manager_set_offsets       (TileManager       *tm,
					      gint               x,
					      gint               y);
Elliot Lee's avatar
Elliot Lee committed
125

126
127
gint64        tile_manager_get_memsize       (const TileManager *tm,
                                              gboolean           sparse);
128

129
130
131
132
void          tile_manager_get_tile_coordinates (TileManager *tm,
						 Tile        *tile,
						 gint        *x,
						 gint        *y);
133

134
135
136
void          tile_manager_map_over_tile        (TileManager *tm,
						 Tile        *tile,
						 Tile        *srctile);
137

138
139
140
141
142
143
144
145
146
147
PixelDataHandle * request_pixel_data (TileManager *tm,
				      gint         x1,
				      gint	   y1,
				      gint	   x2,
				      gint	   y2,
				      gboolean     wantread,
				      gboolean     wantwrite);

void              release_pixel_data (PixelDataHandle *pdh);

Sven Neumann's avatar
Sven Neumann committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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,
                                      const guchar *buffer,
                                      guint         stride);
163

164
165
166
/*   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.
 */
Sven Neumann's avatar
Sven Neumann committed
167
168
169
170
171
172
173
174
175
void		  read_pixel_data_1  (TileManager  *tm,
                                      gint	    x,
                                      gint	    y,
                                      guchar       *buffer);

void		  write_pixel_data_1 (TileManager  *tm,
				      gint	    x,
				      gint	    y,
				      const guchar *buffer);
Michael Natterer's avatar
Michael Natterer committed
176

Elliot Lee's avatar
Elliot Lee committed
177
#endif /* __TILE_MANAGER_H__ */