aboutsummaryrefslogtreecommitdiff
path: root/man/man3/memlayer.html
blob: c21f5bf6b8cdb4afb33e481bd3676b20d57616e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<head>
<title>memlayer(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>MEMLAYER(3)</b><td align=right><b>MEMLAYER(3)</b>
<tr><td width=20><td colspan=2>
    <br>
<p><font size=+1><b>NAME     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    memdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide,
    memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh,
    memltofront, memltofrontn, memltorear, memltorearn &ndash; windows of
    memory-resident images<br>
    
</table>
<p><font size=+1><b>SYNOPSIS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>#include &lt;u.h&gt; <br>
    #include &lt;libc.h&gt; <br>
    #include &lt;draw.h&gt; <br>
    #include &lt;memdraw.h&gt; <br>
    #include &lt;memlayer.h&gt; <br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>typedef struct Memscreen Memscreen;<br>
    typedef struct Memlayer Memlayer;<br>
    typedef void (*Refreshfn)(Memimage*, Rectangle, void*);<br>
    struct Memscreen<br>
    {<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        Memimage &nbsp;&nbsp;&nbsp;*frontmost; /* frontmost layer on screen */<br>
        Memimage &nbsp;&nbsp;&nbsp;*rearmost; &nbsp;&nbsp;&nbsp;/* rearmost layer on screen */<br>
        Memimage &nbsp;&nbsp;&nbsp;*image; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* upon which all layers are drawn */<br>
        Memimage &nbsp;&nbsp;&nbsp;*fill; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* if non&#8722;zero, picture to use when repainting
        */<br>
        
    </table>
    };<br>
    struct Memlayer<br>
    {<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        Rectangle screenr; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* true position of layer on screen */<br>
        Point &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delta; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* add delta to go from image coords to screen */<br>
        Memscreen *screen; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* screen this layer belongs to */<br>
        Memimage &nbsp;&nbsp;&nbsp;*front; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* window in front of this one */<br>
        Memimage &nbsp;&nbsp;&nbsp;*rear; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* window behind this one*/<br>
        int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clear; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* layer is fully visible */<br>
        Memimage &nbsp;&nbsp;&nbsp;*save; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* save area for obscured parts */<br>
        Refreshfn refreshfn; &nbsp;&nbsp;&nbsp;/* fn to refresh obscured parts if save==nil
        */<br>
        void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*refreshptr;/* argument to refreshfn */<br>
        
    </table>
    };<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>Memimage* memlalloc(Memscreen *s, Rectangle r, Refreshfn fn, void
    *arg, ulong col)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memlnorefresh(Memimage *i, Rectangle r, void *arg)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memlsetrefresh(Memimage *i, Refreshfn fn, void *arg)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memldelete(Memimage *i)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memlfree(Memimage *i)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memlexpose(Memimage *i, Rectangle r)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memlhide(Memimage *i, Rectangle r)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memltofront(Memimage *i)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memltofrontn(Memimage**ia, int n)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memltorear(Memimage *i)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memltorearn(Memimage **ia , int n)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memlorigin(Memimage *i, Point log, Point phys)<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memdraw(Image *dst, Rectangle r,<br>
     
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            Image *src, Point sp, Image *mask, Point mp, Drawop op)<br>
            
        </table>
        
    </table>
    int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memload(Memimage *i, Rectangle r,<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            uchar *buf, int n, int iscompressed) 
            <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
            
        </table>
        
    </table>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            
            
        </table>
        
    </table>
    <tt><font size=+1>int &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memunload(Memimage *i, Rectangle r,<br>
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            uchar *buf, int n) 
            <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
            
        </table>
        
    </table>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            
            
        </table>
        
    </table>
    
</table>
<p><font size=+1><b>DESCRIPTION     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    These functions build upon the <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a> interface to maintain
    overlapping graphical windows on in-memory images. They are used
    by the kernel to implement the windows interface presented by
    <a href="../man3/draw.html"><i>draw</i>(3)</a> and <a href="../man3/window.html"><i>window</i>(3)</a> and probably have little use outside of
    the kernel. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    The basic function is to extend the definition of a <tt><font size=+1>Memimage</font></tt> (see
    <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a>) to include overlapping windows defined by the <tt><font size=+1>Memlayer</font></tt>
    type. The first fields of the <tt><font size=+1>Memlayer</font></tt> structure are identical
    to those in <tt><font size=+1>Memimage</font></tt>, permitting a function that expects a <tt><font size=+1>Memimage</font></tt>
    to be passed a <tt><font size=+1>Memlayer</font></tt>, and vice versa.
    Both structures have a <tt><font size=+1>save</font></tt> field, which is nil in a <tt><font size=+1>Memimage</font></tt>
    and points to &#8216;backing store&#8217; in a <tt><font size=+1>Memlayer</font></tt>. The layer routines
    accept <tt><font size=+1>Memimages</font></tt> or <tt><font size=+1>Memlayers</font></tt>; if the image is a <tt><font size=+1>Memimage</font></tt> the
    underlying <tt><font size=+1>Memimage</font></tt> routine is called; otherwise the layer routines
    recursively subdivide the geometry, reducing the
    operation into a smaller component that ultimately can be performed
    on a <tt><font size=+1>Memimage</font></tt>, either the display on which the window appears,
    or the backing store. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <tt><font size=+1>Memlayers</font></tt> are associated with a <tt><font size=+1>Memscreen</font></tt> that holds the data
    structures to maintain the windows and connects them to the associated
    <tt><font size=+1>image</font></tt>. The <tt><font size=+1>fill</font></tt> color is used to paint the background when a window
    is deleted. There is no function to establish a <tt><font size=+1>Memscreen</font></tt>; to
    create one, allocate the memory, zero
    <tt><font size=+1>frontmost</font></tt> and <tt><font size=+1>rearmost</font></tt>, set <tt><font size=+1>fill</font></tt> to a valid fill color or image,
    and set <tt><font size=+1>image</font></tt> to the <tt><font size=+1>Memimage</font></tt> (or <tt><font size=+1>Memlayer</font></tt>) on which the windows
    will be displayed. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memlalloc</i> allocates a <tt><font size=+1>Memlayer</font></tt> of size <i>r</i> on <tt><font size=+1>Memscreen</font></tt> <i>s</i>. If <i>col</i>
    is not <tt><font size=+1>DNofill</font></tt>, the new window will be initialized by painting
    it that color. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    The refresh function <i>fn</i> and associated argument <i>arg</i> will be called
    by routines in the library to restore portions of the window uncovered
    due to another window being deleted or this window being pulled
    to the front of the stack. The function, when called, receives
    a pointer to the image (window) being refreshed, the
    rectangle that has been uncovered, and the <i>arg</i> recorded when the
    window was created. A couple of predefined functions provide built-in
    management methods: <i>memlnorefresh</i> does no backup at all, useful
    for making efficient temporary windows; while a <i>nil</i> function specifies
    that the backing store
    (<tt><font size=+1>Memlayer.save</font></tt>) will be used to keep the obscured data. Other
    functions may be provided by the client. <i>Memlsetrefresh</i> allows
    one to change the function associated with the window. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memldelete</i> deletes the window <i>i</i>, restoring the underlying display.
    <i>Memlfree</i> frees the data structures without unlinking the window
    from the associated <tt><font size=+1>Memscreen</font></tt> or doing any graphics. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memlexpose</i> restores rectangle <i>r</i> within the window, using the backing
    store or appropriate refresh method. <i>Memlhide</i> goes the other way,
    backing up <i>r</i> so that that portion of the screen may be modified
    without losing the data in this window. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memltofront</i> pulls <i>i</i> to the front of the stack of windows, making
    it fully visible. <i>Memltofrontn</i> pulls the <i>n</i> windows in the array
    <i>ia</i> to the front as a group, leaving their internal order unaffected.
    <i>Memltorear</i> and <i>memltorearn</i> push the windows to the rear. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memlorigin</i> changes the coordinate systems associated with the
    window <i>i</i>. The points <i>log</i> and <i>phys</i> represent the upper left corner
    (<tt><font size=+1>min</font></tt>) of the window&#8217;s internal coordinate system and its physical
    location on the screen. Changing <i>log</i> changes the interpretation
    of coordinates within the window; for example, setting it
    to (0, 0) makes the upper left corner of the window appear to
    be the origin of the coordinate system, regardless of its position
    on the screen. Changing <i>phys</i> changes the physical location of
    the window on the screen. When a window is created, its logical
    and physical coordinates are the same, so
    
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        
        <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

            <tt><font size=+1>memlorigin(i, i&#8722;&gt;r.min, i&#8722;&gt;r.min)<br>
            </font></tt>
        </table>
        
    </table>
    would be a no-op. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memdraw</i> and <i>memline</i> are implemented in the layer library but provide
    the main entry points for drawing on memory-resident windows.
    They have the signatures of <i>memimagedraw</i> and <i>memimageline</i> (see
    <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a>) but accept <tt><font size=+1>Memlayer</font></tt> or <tt><font size=+1>Memimage</font></tt> arguments both. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Memload</i> and <i>memunload</i> are similarly layer-savvy versions of <i>loadmemimage</i>
    and <i>unloadmemimage</i>. The <i>iscompressed</i> flag to <i>memload</i> specifies
    whether the <i>n</i> bytes of data in <i>buf</i> are in compressed image format
    (see <a href="../man7/image.html"><i>image</i>(7)</a>).<br>
    
</table>
<p><font size=+1><b>SOURCE     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>/usr/local/plan9/src/libdraw<br>
    </font></tt>
</table>
<p><font size=+1><b>SEE ALSO    </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <a href="../man3/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a>, <a href="../man3/stringsize.html"><i>stringsize</i>(3)</a>, <a href="../man3/window.html"><i>window</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a><br>
    
</table>
<p><font size=+1><b>BUGS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    These functions are archived into <i>libdraw</i>.<br>
    
</table>

<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>