305 lines · 6.8 KB · Text
RawDownload
.TH MEMLAYER 2.SH NAMEmemdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide, memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh, memltofront, memltofrontn, memltorear, memltorearn \- windows of memory-resident images.SH SYNOPSIS.nf.B #include <u.h>.br.B #include <libc.h>.br.B #include <draw.h>.br.B #include <memdraw.h>.br.B #include <memlayer.h>.PP.ft Ltypedef struct Memscreen Memscreen;typedef struct Memlayer Memlayer;typedef void (*Refreshfn)(Memimage*, Rectangle, void*);.ta 4n +\w'\fLRefreshfn 'u +\w'\fL*frontmost; 'u struct Memscreen{	Memimage	*frontmost;	/* frontmost layer on screen */	Memimage	*rearmost;	/* rearmost layer on screen */	Memimage	*image;	/* upon which all layers are drawn */	Memimage	*fill;		/* if non-zero, picture to use when repainting */}; struct Memlayer{	Rectangle	screenr;	/* true position of layer on screen */	Point	delta;	/* add delta to go from image coords to screen */	Memscreen	*screen;	/* screen this layer belongs to */	Memimage	*front;	/* window in front of this one */	Memimage	*rear;	/* window behind this one*/	int	clear;	/* layer is fully visible */	Memimage	*save;	/* save area for obscured parts */	Refreshfn	refreshfn;		/* fn to refresh obscured parts if save==nil */	void	*refreshptr;	/* argument to refreshfn */};.ft.ta \w'\fLMemimage* 'u.PP.BMemimage*	memlalloc(Memscreen *s, Rectangle r, Refreshfn fn, void *arg, ulong col).PP.B void	memlnorefresh(Memimage *i, Rectangle r, void *arg).PP.Bint	memlsetrefresh(Memimage *i, Refreshfn fn, void *arg).PP.Bint	memldelete(Memimage *i).PP.Bint	memlfree(Memimage *i).PP.Bint	memlexpose(Memimage *i, Rectangle r).PP.Bint	memlhide(Memimage *i, Rectangle r).PP.B void	memltofront(Memimage *i).PP.Bvoid	memltofrontn(Memimage**ia, int n).PP.Bvoid	memltorear(Memimage *i).PP.Bvoid	memltorearn(Memimage **ia , int n).PP.Bint	memlorigin(Memimage *i, Point log, Point phys).PP.Bvoid	memdraw(Image *dst, Rectangle r,.br.B		   Image *src, Point sp, Image *mask, Point mp, Drawop op).fi.Bint	memload(Memimage *i, Rectangle r,.br.B		uchar *buf, int n, int iscompressed).PP.Bint	memunload(Memimage *i, Rectangle r,.br.B		uchar *buf, int n).PP.SH DESCRIPTIONThese functions build upon the.IR memdraw (2)interface to maintain overlapping graphical windows on in-memory images.They are used by the kernel to implement the windows interface presented by.IR draw (3)and.IR window (2)and probably have little use outside of the kernel..PPThe basic function is to extend the definition of a.B Memimage(see.IR memdraw (2))to include overlapping windows defined by the.B Memlayertype.The first fields of the.B Memlayerstructure are identical to those in.BR Memimage ,permitting a function that expects a.B Memimageto be passed a.BR Memlayer ,and vice versa.Both structures have a.B savefield, which is nil in a.B Memimageand points to `backing store' in a.BR Memlayer .The layer routines accept.B Memimagesor.BR Memlayers ;if the image is a.B Memimagethe underlying.B Memimageroutine is called; otherwise the layer routines recursivelysubdivide the geometry, reducing the operation into a smallercomponent that ultimately can be performed on a.BR Memimage ,either the display on which the window appears, or the backing store..PP.B Memlayersare associated with a.B Memscreenthat holds the data structures to maintain the windows and connectsthem to the associated.BR image .The.B fillcolor is used to paint the background when a window is deleted.There is no function to establish a.BR Memscreen ;to create one, allocate the memory, zero.B frontmostand.BR rearmost ,set.B fillto a valid fill color or image, and set.B imageto the.B Memimage(or.BR Memlayer )on which the windows will be displayed..PP.I Memlallocallocates a.B Memlayerof size.I ron.B Memscreen.IR s .If.I colis not.BR DNofill ,the new window will be initialized by painting it that color..PPThe refresh function.I fnand associated argument.I argwill be called by routines in the library to restore portions of the windowuncovered 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 argrecorded when the window was created.A couple of predefined functions provide built-in management methods:.I memlnorefreshdoes no backup at all, useful for making efficient temporary windows;while a.I nilfunction specifies that the backing store.RB ( Memlayer.save )will be used to keep the obscured data.Other functions may be provided by the client..I Memlsetrefreshallows one to change the function associated with the window..PP.I Memldeletedeletes the window.IR i ,restoring the underlying display..I Memlfreefrees the data structures without unlinking the window from the associated.B Memscreenor doing any graphics..PP.I Memlexposerestores rectangle.I rwithin the window, using the backing store or appropriate refresh method..I Memlhidegoes the other way, backing up.I rso that that portion of the screen may be modified without losing the data in this window..PP.I Memltofrontpulls.I ito the front of the stack of windows, making it fully visible..I Memltofrontnpulls the.I nwindows in the array.I iato the front as a group, leaving their internal order unaffected..I Memltorearand.I memltorearnpush the windows to the rear..PP.I Memloriginchanges the coordinate systems associated with the window.IR i .The points.I logand.I physrepresent the upper left corner.RB ( min )of the window's internal coordinate system and its physical location on the screen.Changing.I logchanges 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 coordinatesystem, regardless of its position on the screen.Changing.I physchanges the physical location of the window on the screen.When a window is created, its logical and physical coordinates are the same, so.EX	memlorigin(i, i->r.min, i->r.min).EEwould be a no-op..PP.I Memdrawand.I memlineare implemented in the layer library but provide the main entry points for drawing onmemory-resident windows.They have the signatures of.I memimagedrawand.I memimageline(see.IR memdraw (2))but accept.B Memlayeror.B Memimagearguments both..PP.I Memloadand.I memunloadare similarly layer-savvy versions of.I loadmemimageand.IR unloadmemimage .The.I iscompressedflag to.I memloadspecifies whether the.I nbytes of data in.I bufare in compressed image format(see.IR image (6))..SH SOURCE.B /sys/src/libmemlayer.SH SEE ALSO.IR graphics (2),.IR memdraw (2),.IR stringsize (2),.IR window (2),.IR draw (3)