#pragma src "/sys/src/libg" #pragma lib "libg.a" enum /* constants for I/O to devgraphics */ { Tilehdr = 40, Tilesize = 8000 }; /* * you may think it's a blit, but it's gnot */ enum { EMAXMSG = 128+8192, /* size of 9p header+data */ }; /* * Types */ typedef struct Bitmap Bitmap; typedef struct Display Display; typedef struct Point Point; typedef struct Rectangle Rectangle; typedef struct Cursor Cursor; typedef struct Mouse Mouse; typedef struct Menu Menu; typedef struct Font Font; typedef struct Fontchar Fontchar; typedef struct Subfont Subfont; typedef struct Cachefont Cachefont; typedef struct Cacheinfo Cacheinfo; typedef struct Cachesubf Cachesubf; typedef struct Event Event; typedef struct Slave Slave; typedef struct Ebuf Ebuf; typedef struct RGB RGB; typedef struct Linedesc Linedesc; typedef struct DRefret DRefret; struct DRefret { int n; /* number of bytes */ int dy; /* number of lines */ uchar *dp; /* pointer to data */ }; struct Point { int x; int y; }; struct Rectangle { Point min; Point max; }; typedef DRefret DRefresh(Display*, int, Rectangle, uchar*, uchar*, int); struct Bitmap { Rectangle r; /* rectangle in data area, local coords */ Rectangle clipr; /* clipping region */ int ldepth; /* log base 2 of number of bits per pixel */ ulong *base; /* pointer to start of data */ int zero; /* base+zero=&word containing (0,0) */ ulong width; /* width in words of total data area */ Display *display; /* if present */ }; struct Display { uchar *data; /* transfer buffer */ Rectangle r; int ldepth; Rectangle bb; /* bounding box of changes */ int waste; /* unused part of bb */ Rectangle bound; /* memory for boundin/boundout */ Bitmap *image; /* owner */ int id; int fd; int ctlfd; int local; int bytewidth; void *drdata1; /* storage for drefresh() */ void *drdata2; /* storage for drefresh() */ DRefresh *drefresh; }; struct Mouse { int buttons; /* bit array: LMR=124 */ Point xy; ulong msec; }; struct Cursor { Point offset; uchar clr[2*16]; uchar set[2*16]; }; struct Menu { char **item; char *(*gen)(int); int lasthit; }; struct Linedesc { int x0; int y0; char xmajor; char slopeneg; long dminor; long dmajor; }; /* * Subfonts * * given char c, Subfont *f, Fontchar *i, and Point p, one says * i = f->info+c; * bitblt(b, Pt(p.x+i->left,p.y+i->top), * bitmap, Rect(i->x,i->top,(i+1)->x,i->bottom), * fc); * p.x += i->width; * where bitmap b is the repository of the images. * */ struct Fontchar { short 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 { 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 */ Bitmap *bits; /* of font */ }; enum { /* starting values */ LOG2NFCACHE = 6, NFCACHE = (1<>8)) #define BP32INT(p, v) (BPSHORT(p, ((s32int)v)), BPSHORT(p+2, ((s32int)v)>>16)) ulong *wordaddr(Bitmap*, Point); uchar *byteaddr(Bitmap*, Point); int dfree(Display*); int dwritectl(Display*, char*, int); int dreadctl(Display*, char*, int); int dinfo(Display*, int, int*, Rectangle*); void* dinit(Display*, Bitmap*, int, int); int ddelete(Display*); void dfreemem(Display*); int dreadctl(Display*, char*, int); int dwritectl(Display*, char*, int); void dbound(Display*, Rectangle); void bload(Bitmap*, Rectangle, uchar*); ulong bunload(Bitmap*, Rectangle, uchar*); void drefresh(Display*, Rectangle); Display *dopen(char*, int, DRefresh*); Bitmap* dbitmap(Display*, DRefresh*, int); void dclose(Display*); void dflush(Display*); void _bltinit(void); Bitmap* battach(Bitmap*, int, int); int readmouse(Mouse*); int atomouse(Mouse*, char*, int); /* * Refresh functions */ DRefresh drtexture; DRefresh drbackstore;