#pragma src "/usr/inferno/image" typedef struct Cachefont Cachefont; typedef struct Cacheinfo Cacheinfo; typedef struct Cachesubf Cachesubf; typedef struct Display Display; typedef struct Font Font; typedef struct Fontchar Fontchar; typedef struct Image Image; typedef struct Point Point; typedef struct Rectangle Rectangle; typedef struct Refreshq Refreshq; typedef struct Screen Screen; typedef struct Subfont Subfont; enum { MaxImageSize = 4194304, /* max memory in bytes for image */ MaxImageWidth = 16384, /* max image width in cols */ MaxImageHeight = 16384 /* max image height in rows */ }; enum { Displaybufsize = 8000 }; enum { /* refresh methods */ Refbackup = 0, Reflocal = 1, Refremote = 2 }; enum { /* line ends */ Endsquare = 0, Enddisc = 1, Endarrow = 2, Endmask = 0x1F }; #define ARROW(a, b, c) (Endarrow|((a)<<5)|((b)<<14)|((c)<<23)) struct Point { int x; int y; }; struct Rectangle { Point min; Point max; }; typedef void (*Reffn)(Image*, Rectangle, void*); struct Screen { Display *display; /* display holding data */ int id; /* id of system-held Screen */ Image *image; /* unused; for reference only */ Image *fill; /* unused; for reference only */ }; struct Refreshq { Reffn reffn; void *refptr; Rectangle r; Refreshq *next; }; struct Display { int dirno; void *datachan; void *refchan; int imageid; int local; ulong dataqid; Image *ones; Image *zeros; Image *image; uchar buf[Displaybufsize+1]; /* +1 for flush message */ uchar *bufp; Font *defaultfont; Subfont *defaultsubfont; Image *windows; void *qlock; Refreshq *refhead; Refreshq *reftail; void *limbo; /* used by limbo interpreter */ }; struct Image { Display *display; /* display holding data */ int id; /* id of system-held Image */ Rectangle r; /* rectangle in data area, local coords */ Rectangle clipr; /* clipping region */ int ldepth; /* log base 2 of number of bits per pixel */ int repl; /* whether data area replicates to tile the plane */ Screen *screen; /* 0 if not a window */ Image *next; Reffn reffn; void *refptr; }; /* * Subfonts * * given char c, Subfont *f, Fontchar *i, and Point p, one says * i = f->info+c; * draw(b, Rect(p.x+i->left, p.y+i->top, * p.x+i->left+((i+1)->x-i->x), p.y+i->bottom), * color, f->bits, Pt(i->x, i->top)); * p.x += i->width; * to draw characters in the specified color (itself an Image) in Image b. */ struct Fontchar { int x; /* left edge of bits */ uchar top; /* first non-zero scan-line */ uchar bottom; /* last non-zero scan-line + 1 */ char left; /* offset of baseline */ uchar width; /* width of baseline */ }; struct Subfont { char *name; short n; /* number of chars in font */ uchar height; /* height of bitmap */ char ascent; /* top of bitmap to baseline */ Fontchar *info; /* n+1 character descriptors */ Image *bits; /* of font */ }; enum { /* starting values */ LOG2NFCACHE = 6, NFCACHE = (1<>8)) #define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16)) #define P2P(p1, p2) (p1).x = (p2).x, (p1).y = (p2).y #define R2R(r1, r2) (r1).min.x = (r2).min.x, (r1).min.y = (r2).min.y,\ (r1).max.x = (r2).max.x, (r1).max.y = (r2).max.y /* * Compressed bitmap parameters */ #define NMATCH 3 /* shortest match possible */ #define NRUN (NMATCH+31) /* longest match possible */ #define NMEM 1024 /* window size */ #define NDUMP 128 /* maximum length of dump */ #define NCBLOCK 6000 /* size of compressed blocks */ /* * Macros to convert between C and Limbo types */ #define IRECT(r) (*(Rectangle*)&(r)) #define DRECT(r) (*(Draw_Rect*)&(r)) #define IPOINT(p) (*(Point*)&(p)) #define DPOINT(p) (*(Draw_Point*)&(p))