1 cfa37a7b 2004-04-10 devnull .TH MEMLAYER 3
3 cfa37a7b 2004-04-10 devnull memdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide, memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh, memltofront, memltofrontn, memltorear, memltorearn \- windows of memory-resident images
4 cfa37a7b 2004-04-10 devnull .SH SYNOPSIS
6 cfa37a7b 2004-04-10 devnull .B #include <u.h>
8 cfa37a7b 2004-04-10 devnull .B #include <libc.h>
10 cfa37a7b 2004-04-10 devnull .B #include <draw.h>
12 cfa37a7b 2004-04-10 devnull .B #include <memdraw.h>
14 cfa37a7b 2004-04-10 devnull .B #include <memlayer.h>
17 cfa37a7b 2004-04-10 devnull typedef struct Memscreen Memscreen;
18 cfa37a7b 2004-04-10 devnull typedef struct Memlayer Memlayer;
19 cfa37a7b 2004-04-10 devnull typedef void (*Refreshfn)(Memimage*, Rectangle, void*);
20 cfa37a7b 2004-04-10 devnull .ta 4n +\w'\fLRefreshfn 'u +\w'\fL*frontmost; 'u
22 cfa37a7b 2004-04-10 devnull struct Memscreen
24 cfa37a7b 2004-04-10 devnull Memimage *frontmost; /* frontmost layer on screen */
25 cfa37a7b 2004-04-10 devnull Memimage *rearmost; /* rearmost layer on screen */
26 cfa37a7b 2004-04-10 devnull Memimage *image; /* upon which all layers are drawn */
27 cfa37a7b 2004-04-10 devnull Memimage *fill; /* if non-zero, picture to use when repainting */
30 cfa37a7b 2004-04-10 devnull struct Memlayer
32 cfa37a7b 2004-04-10 devnull Rectangle screenr; /* true position of layer on screen */
33 cfa37a7b 2004-04-10 devnull Point delta; /* add delta to go from image coords to screen */
34 cfa37a7b 2004-04-10 devnull Memscreen *screen; /* screen this layer belongs to */
35 cfa37a7b 2004-04-10 devnull Memimage *front; /* window in front of this one */
36 cfa37a7b 2004-04-10 devnull Memimage *rear; /* window behind this one*/
37 cfa37a7b 2004-04-10 devnull int clear; /* layer is fully visible */
38 cfa37a7b 2004-04-10 devnull Memimage *save; /* save area for obscured parts */
39 cfa37a7b 2004-04-10 devnull Refreshfn refreshfn; /* fn to refresh obscured parts if save==nil */
40 cfa37a7b 2004-04-10 devnull void *refreshptr; /* argument to refreshfn */
43 cfa37a7b 2004-04-10 devnull .ta \w'\fLMemimage* 'u
46 cfa37a7b 2004-04-10 devnull Memimage* memlalloc(Memscreen *s, Rectangle r, Refreshfn fn, void *arg, ulong col)
48 cfa37a7b 2004-04-10 devnull .B void memlnorefresh(Memimage *i, Rectangle r, void *arg)
51 cfa37a7b 2004-04-10 devnull int memlsetrefresh(Memimage *i, Refreshfn fn, void *arg)
54 cfa37a7b 2004-04-10 devnull int memldelete(Memimage *i)
57 cfa37a7b 2004-04-10 devnull int memlfree(Memimage *i)
60 cfa37a7b 2004-04-10 devnull int memlexpose(Memimage *i, Rectangle r)
63 cfa37a7b 2004-04-10 devnull int memlhide(Memimage *i, Rectangle r)
66 cfa37a7b 2004-04-10 devnull void memltofront(Memimage *i)
69 cfa37a7b 2004-04-10 devnull void memltofrontn(Memimage**ia, int n)
72 cfa37a7b 2004-04-10 devnull void memltorear(Memimage *i)
75 cfa37a7b 2004-04-10 devnull void memltorearn(Memimage **ia , int n)
78 cfa37a7b 2004-04-10 devnull int memlorigin(Memimage *i, Point log, Point phys)
81 cfa37a7b 2004-04-10 devnull void memdraw(Image *dst, Rectangle r,
84 cfa37a7b 2004-04-10 devnull Image *src, Point sp, Image *mask, Point mp, Drawop op)
87 cfa37a7b 2004-04-10 devnull int memload(Memimage *i, Rectangle r,
90 cfa37a7b 2004-04-10 devnull uchar *buf, int n, int iscompressed)
93 cfa37a7b 2004-04-10 devnull int memunload(Memimage *i, Rectangle r,
96 cfa37a7b 2004-04-10 devnull uchar *buf, int n)
98 cfa37a7b 2004-04-10 devnull .SH DESCRIPTION
99 cfa37a7b 2004-04-10 devnull These functions build upon the
100 bf8a59fa 2004-04-11 devnull .IR memdraw (3)
101 cfa37a7b 2004-04-10 devnull interface to maintain overlapping graphical windows on in-memory images.
102 cfa37a7b 2004-04-10 devnull They are used by the kernel to implement the windows interface presented by
103 cfa37a7b 2004-04-10 devnull .IR draw (3)
105 bf8a59fa 2004-04-11 devnull .IR window (3)
106 cfa37a7b 2004-04-10 devnull and probably have little use outside of the kernel.
108 cfa37a7b 2004-04-10 devnull The basic function is to extend the definition of a
109 cfa37a7b 2004-04-10 devnull .B Memimage
111 bf8a59fa 2004-04-11 devnull .IR memdraw (3))
112 cfa37a7b 2004-04-10 devnull to include overlapping windows defined by the
113 cfa37a7b 2004-04-10 devnull .B Memlayer
115 cfa37a7b 2004-04-10 devnull The first fields of the
116 cfa37a7b 2004-04-10 devnull .B Memlayer
117 cfa37a7b 2004-04-10 devnull structure are identical to those in
118 cfa37a7b 2004-04-10 devnull .BR Memimage ,
119 cfa37a7b 2004-04-10 devnull permitting a function that expects a
120 cfa37a7b 2004-04-10 devnull .B Memimage
121 cfa37a7b 2004-04-10 devnull to be passed a
122 cfa37a7b 2004-04-10 devnull .BR Memlayer ,
123 cfa37a7b 2004-04-10 devnull and vice versa.
124 cfa37a7b 2004-04-10 devnull Both structures have a
126 cfa37a7b 2004-04-10 devnull field, which is nil in a
127 cfa37a7b 2004-04-10 devnull .B Memimage
128 cfa37a7b 2004-04-10 devnull and points to `backing store' in a
129 cfa37a7b 2004-04-10 devnull .BR Memlayer .
130 cfa37a7b 2004-04-10 devnull The layer routines accept
131 cfa37a7b 2004-04-10 devnull .B Memimages
133 cfa37a7b 2004-04-10 devnull .BR Memlayers ;
134 cfa37a7b 2004-04-10 devnull if the image is a
135 cfa37a7b 2004-04-10 devnull .B Memimage
136 cfa37a7b 2004-04-10 devnull the underlying
137 cfa37a7b 2004-04-10 devnull .B Memimage
138 cfa37a7b 2004-04-10 devnull routine is called; otherwise the layer routines recursively
139 cfa37a7b 2004-04-10 devnull subdivide the geometry, reducing the operation into a smaller
140 cfa37a7b 2004-04-10 devnull component that ultimately can be performed on a
141 cfa37a7b 2004-04-10 devnull .BR Memimage ,
142 cfa37a7b 2004-04-10 devnull either the display on which the window appears, or the backing store.
144 cfa37a7b 2004-04-10 devnull .B Memlayers
145 cfa37a7b 2004-04-10 devnull are associated with a
146 cfa37a7b 2004-04-10 devnull .B Memscreen
147 cfa37a7b 2004-04-10 devnull that holds the data structures to maintain the windows and connects
148 cfa37a7b 2004-04-10 devnull them to the associated
149 cfa37a7b 2004-04-10 devnull .BR image .
152 cfa37a7b 2004-04-10 devnull color is used to paint the background when a window is deleted.
153 cfa37a7b 2004-04-10 devnull There is no function to establish a
154 cfa37a7b 2004-04-10 devnull .BR Memscreen ;
155 cfa37a7b 2004-04-10 devnull to create one, allocate the memory, zero
156 cfa37a7b 2004-04-10 devnull .B frontmost
158 cfa37a7b 2004-04-10 devnull .BR rearmost ,
161 cfa37a7b 2004-04-10 devnull to a valid fill color or image, and set
162 cfa37a7b 2004-04-10 devnull .B image
164 cfa37a7b 2004-04-10 devnull .B Memimage
166 cfa37a7b 2004-04-10 devnull .BR Memlayer )
167 cfa37a7b 2004-04-10 devnull on which the windows will be displayed.
169 cfa37a7b 2004-04-10 devnull .I Memlalloc
170 cfa37a7b 2004-04-10 devnull allocates a
171 cfa37a7b 2004-04-10 devnull .B Memlayer
175 cfa37a7b 2004-04-10 devnull .B Memscreen
180 cfa37a7b 2004-04-10 devnull .BR DNofill ,
181 cfa37a7b 2004-04-10 devnull the new window will be initialized by painting it that color.
183 cfa37a7b 2004-04-10 devnull The refresh function
185 cfa37a7b 2004-04-10 devnull and associated argument
187 cfa37a7b 2004-04-10 devnull will be called by routines in the library to restore portions of the window
188 cfa37a7b 2004-04-10 devnull uncovered due to another window being deleted or this window being pulled to the front of the stack.
189 cfa37a7b 2004-04-10 devnull The function, when called,
190 cfa37a7b 2004-04-10 devnull receives a pointer to the image (window) being refreshed, the rectangle that has been uncovered,
193 cfa37a7b 2004-04-10 devnull recorded when the window was created.
194 cfa37a7b 2004-04-10 devnull A couple of predefined functions provide built-in management methods:
195 cfa37a7b 2004-04-10 devnull .I memlnorefresh
196 cfa37a7b 2004-04-10 devnull does no backup at all, useful for making efficient temporary windows;
199 cfa37a7b 2004-04-10 devnull function specifies that the backing store
200 cfa37a7b 2004-04-10 devnull .RB ( Memlayer.save )
201 cfa37a7b 2004-04-10 devnull will be used to keep the obscured data.
202 cfa37a7b 2004-04-10 devnull Other functions may be provided by the client.
203 cfa37a7b 2004-04-10 devnull .I Memlsetrefresh
204 cfa37a7b 2004-04-10 devnull allows one to change the function associated with the window.
206 cfa37a7b 2004-04-10 devnull .I Memldelete
207 cfa37a7b 2004-04-10 devnull deletes the window
209 cfa37a7b 2004-04-10 devnull restoring the underlying display.
210 cfa37a7b 2004-04-10 devnull .I Memlfree
211 cfa37a7b 2004-04-10 devnull frees the data structures without unlinking the window from the associated
212 cfa37a7b 2004-04-10 devnull .B Memscreen
213 cfa37a7b 2004-04-10 devnull or doing any graphics.
215 cfa37a7b 2004-04-10 devnull .I Memlexpose
216 cfa37a7b 2004-04-10 devnull restores rectangle
218 cfa37a7b 2004-04-10 devnull within the window, using the backing store or appropriate refresh method.
219 cfa37a7b 2004-04-10 devnull .I Memlhide
220 cfa37a7b 2004-04-10 devnull goes the other way, backing up
222 cfa37a7b 2004-04-10 devnull so that that portion of the screen may be modified without losing the data in this window.
224 cfa37a7b 2004-04-10 devnull .I Memltofront
227 cfa37a7b 2004-04-10 devnull to the front of the stack of windows, making it fully visible.
228 cfa37a7b 2004-04-10 devnull .I Memltofrontn
229 cfa37a7b 2004-04-10 devnull pulls the
231 cfa37a7b 2004-04-10 devnull windows in the array
233 cfa37a7b 2004-04-10 devnull to the front as a group, leaving their internal order unaffected.
234 cfa37a7b 2004-04-10 devnull .I Memltorear
236 cfa37a7b 2004-04-10 devnull .I memltorearn
237 cfa37a7b 2004-04-10 devnull push the windows to the rear.
239 cfa37a7b 2004-04-10 devnull .I Memlorigin
240 cfa37a7b 2004-04-10 devnull changes the coordinate systems associated with the window
242 cfa37a7b 2004-04-10 devnull The points
246 cfa37a7b 2004-04-10 devnull represent the upper left corner
247 cfa37a7b 2004-04-10 devnull .RB ( min )
248 cfa37a7b 2004-04-10 devnull of the window's internal coordinate system and its physical location on the screen.
249 cfa37a7b 2004-04-10 devnull Changing
251 cfa37a7b 2004-04-10 devnull changes the interpretation of coordinates within the window; for example, setting it to
252 cfa37a7b 2004-04-10 devnull (0,\ 0) makes the upper left corner of the window appear to be the origin of the coordinate
253 cfa37a7b 2004-04-10 devnull system, regardless of its position on the screen.
254 cfa37a7b 2004-04-10 devnull Changing
256 cfa37a7b 2004-04-10 devnull changes the physical location of the window on the screen.
257 cfa37a7b 2004-04-10 devnull When a window is created, its logical and physical coordinates are the same, so
259 cfa37a7b 2004-04-10 devnull memlorigin(i, i->r.min, i->r.min)
261 cfa37a7b 2004-04-10 devnull would be a no-op.
263 cfa37a7b 2004-04-10 devnull .I Memdraw
265 cfa37a7b 2004-04-10 devnull .I memline
266 cfa37a7b 2004-04-10 devnull are implemented in the layer library but provide the main entry points for drawing on
267 cfa37a7b 2004-04-10 devnull memory-resident windows.
268 cfa37a7b 2004-04-10 devnull They have the signatures of
269 cfa37a7b 2004-04-10 devnull .I memimagedraw
271 cfa37a7b 2004-04-10 devnull .I memimageline
273 bf8a59fa 2004-04-11 devnull .IR memdraw (3))
274 cfa37a7b 2004-04-10 devnull but accept
275 cfa37a7b 2004-04-10 devnull .B Memlayer
277 cfa37a7b 2004-04-10 devnull .B Memimage
278 cfa37a7b 2004-04-10 devnull arguments both.
280 cfa37a7b 2004-04-10 devnull .I Memload
282 cfa37a7b 2004-04-10 devnull .I memunload
283 cfa37a7b 2004-04-10 devnull are similarly layer-savvy versions of
284 cfa37a7b 2004-04-10 devnull .I loadmemimage
286 cfa37a7b 2004-04-10 devnull .IR unloadmemimage .
288 cfa37a7b 2004-04-10 devnull .I iscompressed
290 cfa37a7b 2004-04-10 devnull .I memload
291 cfa37a7b 2004-04-10 devnull specifies whether the
293 cfa37a7b 2004-04-10 devnull bytes of data in
295 cfa37a7b 2004-04-10 devnull are in compressed image format
297 cfa37a7b 2004-04-10 devnull .IR image (6)).
298 cfa37a7b 2004-04-10 devnull .SH SOURCE
299 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/libmemlayer
300 cfa37a7b 2004-04-10 devnull .SH SEE ALSO
301 bf8a59fa 2004-04-11 devnull .IR graphics (3),
302 bf8a59fa 2004-04-11 devnull .IR memdraw (3),
303 bf8a59fa 2004-04-11 devnull .IR stringsize (3),
304 bf8a59fa 2004-04-11 devnull .IR window (3),
305 cfa37a7b 2004-04-10 devnull .IR draw (3)