memdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide, memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh, memltofront, memltofrontn, memltorear, memltorearn – windows of memory-resident images
typedef struct Memscreen Memscreen;
typedef struct Memlayer Memlayer;
typedef void (*Refreshfn)(Memimage*, Rectangle, void*);
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 */
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 */
Memimage* memlalloc(Memscreen *s, Rectangle r, Refreshfn fn, void *arg, ulong col)
void memlnorefresh(Memimage *i, Rectangle r, void *arg)
int memlsetrefresh(Memimage *i, Refreshfn fn, void *arg)
int memldelete(Memimage *i)
int memlfree(Memimage *i)
int memlexpose(Memimage *i, Rectangle r)
int memlhide(Memimage *i, Rectangle r)
void memltofront(Memimage *i)
void memltofrontn(Memimage**ia, int n)
void memltorear(Memimage *i)
void memltorearn(Memimage **ia , int n)
int memlorigin(Memimage *i, Point log, Point phys)
void memdraw(Memimage *dst, Rectangle r,
Memimage *src, Point sp, Memimage *mask, Point mp, Drawop op)
int memload(Memimage *i, Rectangle r,
uchar *buf, int n, int iscompressed)
int memunload(Memimage *i, Rectangle r,
uchar *buf, int n)
These functions build upon the
interface to maintain overlapping graphical windows on in-memory images.
They are used by the kernel to implement the windows interface presented by
and probably have little use outside of the kernel.
The basic function is to extend the definition of a
to include overlapping windows defined by the
The first fields of the
structure are identical to those in
permitting a function that expects a
to be passed a
and vice versa.
Both structures have a
field, which is nil in a
and points to ‘backing store’ in a
The layer routines accept
if the image is a
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
either the display on which the window appears, or the backing store.
are associated with a
that holds the data structures to maintain the windows and connects
them to the associated
color is used to paint the background when a window is deleted.
There is no function to establish a
to create one, allocate the memory, zero
to a valid fill color or image, and set
on which the windows will be displayed.
the new window will be initialized by painting it that color.
The refresh function
and associated argument
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,
recorded when the window was created.
A couple of predefined functions provide built-in management methods:
does no backup at all, useful for making efficient temporary windows;
function specifies that the backing store
will be used to keep the obscured data.
Other functions may be provided by the client.
allows one to change the function associated with the window.
deletes the window
restoring the underlying display.
frees the data structures without unlinking the window from the associated
or doing any graphics.
within the window, using the backing store or appropriate refresh method.
goes the other way, backing up
so that portion of the screen may be modified without losing the data in this window.
to the front of the stack of windows, making it fully visible.
windows in the array
to the front as a group, leaving their internal order unaffected.
push the windows to the rear.
changes the coordinate systems associated with the window
represent the upper left corner
of the window’s internal coordinate system and its physical location on the screen.
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.
changes the physical location of the window on the screen.
When a window is created, its logical and physical coordinates are the same, so
memlorigin(i, i->r.min, i->r.min)
would be a no-op.
are implemented in the layer library but provide the main entry points for drawing on
They have the signatures of
are similarly layer-savvy versions of
specifies whether the
bytes of data in
are in compressed image format