2 * /dev/draw simulator -- handles the messages prepared by the draw library.
3 * Doesn't simulate the file system part, just the messages.
13 extern void _flushmemscreen(Rectangle);
18 #define HASHMASK (NHASH-1)
20 typedef struct Client Client;
21 typedef struct Draw Draw;
22 typedef struct DImage DImage;
23 typedef struct DScreen DScreen;
24 typedef struct CScreen CScreen;
25 typedef struct FChar FChar;
26 typedef struct Refresh Refresh;
27 typedef struct Refx Refx;
28 typedef struct DName DName;
45 DImage* dimage[NHASH];
82 int minx; /* left edge of bits */
83 int maxx; /* right edge of bits */
84 uchar miny; /* first non-zero scan-line */
85 uchar maxy; /* last non-zero scan-line + 1 */
86 schar left; /* offset of baseline */
87 uchar width; /* width of baseline */
91 * Reference counts in DImages:
92 * one per open by original client
93 * one per screen image or fill
94 * one per image derived from this one by name
106 DScreen* dscreen; /* 0 if not a window */
107 DImage* fromname; /* image this one is derived from, by name */
130 static Client *client0;
131 static Memimage *screenimage;
132 static Rectangle flushrect;
134 static DScreen* dscreen;
135 static int drawuninstall(Client*, int);
136 static Memimage* drawinstall(Client*, int, Memimage*, DScreen*);
137 static void drawfreedimage(DImage*);
140 _initdisplaymemimage(Memimage *m)
144 client0 = mallocz(sizeof(Client), 1);
146 fprint(2, "initdraw: allocating client0: out of memory");
150 client0->clientid = ++sdraw.clientid;
151 client0->op = SoverD;
152 sdraw.client[0] = client0;
154 sdraw.softscreen = 1;
158 _drawreplacescreenimage(Memimage *m)
161 * Replace the screen image because the screen
164 * In theory there should only be one reference
165 * to the current screen image, and that's through
166 * client0's image 0, installed a few lines above.
167 * Once the client drops the image, the underlying backing
168 * store freed properly. The client is being notified
169 * about the resize through external means, so all we
170 * need to do is this assignment.
178 if(om && --om->screenref == 0){
186 drawrefreshscreen(DImage *l, Client *client)
188 while(l != nil && l->dscreen == nil)
190 if(l != nil && l->dscreen->owner != client)
191 l->dscreen->owner->refreshme = 1;
196 drawrefresh(Memimage *m, Rectangle r, void *v)
210 for(ref=c->refresh; ref; ref=ref->next)
211 if(ref->dimage == d){
212 combinerect(&ref->r, r);
215 ref = mallocz(sizeof(Refresh), 1);
219 ref->next = c->refresh;
225 addflush(Rectangle r)
230 if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r))
233 if(flushrect.min.x >= flushrect.max.x){
239 combinerect(&nbb, r);
241 abb = Dx(flushrect)*Dy(flushrect);
242 anbb = Dx(nbb)*Dy(nbb);
244 * Area of new waste is area of new bb minus area of old bb,
245 * less the area of the new segment, which we assume is not waste.
246 * This could be negative, but that's OK.
248 waste += anbb-abb - ar;
253 * total area is small
254 * waste is less than half total area
257 if(anbb<=1024 || waste*2<anbb || rectXrect(flushrect, r)){
261 /* emit current state */
262 if(flushrect.min.x < flushrect.max.x)
263 _flushmemscreen(flushrect);
270 dstflush(int dstid, Memimage *dst, Rectangle r)
275 combinerect(&flushrect, r);
278 /* how can this happen? -rsc, dec 12 2002 */
280 fprint(2, "nil dstflush\n");
287 if(l->screen->image->data != screenimage->data)
289 r = rectaddpt(r, l->delta);
290 l = l->screen->image->layer;
299 if(flushrect.min.x < flushrect.max.x)
300 _flushmemscreen(flushrect);
301 flushrect = Rect(10000, 10000, -10000, -10000);
306 drawcmp(char *a, char *b, int n)
310 return memcmp(a, b, n);
315 drawlookupname(int n, char *str)
320 ename = &name[sdraw.nname];
321 for(; name<ename; name++)
322 if(drawcmp(name->name, str, n) == 0)
329 drawgoodname(DImage *d)
333 /* if window, validate the screen's own images */
335 if(drawgoodname(d->dscreen->dimage) == 0
336 || drawgoodname(d->dscreen->dfill) == 0)
340 n = drawlookupname(strlen(d->name), d->name);
341 if(n==nil || n->vers!=d->vers)
348 drawlookup(Client *client, int id, int checkname)
352 d = client->dimage[id&HASHMASK];
356 * BUG: should error out but too hard.
359 if(checkname && !drawgoodname(d))
370 drawlookupdscreen(int id)
385 drawlookupscreen(Client *client, int id, CScreen **cs)
391 if(s->dscreen->id == id){
397 /* caller must check! */
403 drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
407 d = mallocz(sizeof(DImage), 1);
420 d->dscreen = dscreen;
421 d->next = client->dimage[id&HASHMASK];
422 client->dimage[id&HASHMASK] = d;
428 drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public)
433 c = mallocz(sizeof(CScreen), 1);
434 if(dimage && dimage->image && dimage->image->chan == 0){
435 fprint(2, "bad image %p in drawinstallscreen", dimage->image);
442 d = mallocz(sizeof(DScreen), 1);
447 s = mallocz(sizeof(Memscreen), 1);
457 s->image = dimage->image;
462 s->fill = dfill->image;
475 c->next = client->cscreen;
482 drawdelname(DName *name)
487 memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));
493 drawfreedscreen(DScreen *this)
499 fprint(2, "negative ref in drawfreedscreen\n");
504 dscreen = this->next;
507 while(next = ds->next){ /* assign = */
509 ds->next = this->next;
515 * Should signal Enodrawimage, but too hard.
521 drawfreedimage(this->dimage);
523 drawfreedimage(this->dfill);
530 drawfreedimage(DImage *dimage)
538 fprint(2, "negative ref in drawfreedimage\n");
543 for(i=0; i<sdraw.nname; )
544 if(sdraw.name[i].dimage == dimage)
545 drawdelname(sdraw.name+i);
548 if(dimage->fromname){ /* acquired by name; owned by someone else*/
549 drawfreedimage(dimage->fromname);
552 ds = dimage->dscreen;
554 dimage->dscreen = nil; /* paranoia */
557 if(l->data == screenimage->data)
558 addflush(l->layer->screenr);
559 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
560 free(l->layer->refreshptr);
561 l->layer->refreshptr = nil;
562 if(drawgoodname(dimage))
570 else if(--l->screenref==0)
580 drawuninstallscreen(Client *client, CScreen *this)
584 cs = client->cscreen;
586 client->cscreen = this->next;
587 drawfreedscreen(this->dscreen);
591 while(next = cs->next){ /* assign = */
593 cs->next = this->next;
594 drawfreedscreen(this->dscreen);
604 drawuninstall(Client *client, int id)
608 for(l=&client->dimage[id&HASHMASK]; (d=*l) != nil; l=&d->next){
620 drawaddname(Client *client, DImage *di, int n, char *str, char **err)
622 DName *name, *ename, *new, *t;
626 ename = &name[sdraw.nname];
627 for(; name<ename; name++)
628 if(drawcmp(name->name, str, n) == 0){
629 *err = "image name in use";
632 t = mallocz((sdraw.nname+1)*sizeof(DName), 1);
634 if(t == nil || ns == nil){
637 *err = "out of memory";
640 memmove(t, sdraw.name, sdraw.nname*sizeof(DName));
643 new = &sdraw.name[sdraw.nname++];
645 memmove(new->name, str, n);
648 new->client = client;
649 new->vers = ++sdraw.vers;
654 drawclientop(Client *cl)
665 drawimage(Client *client, uchar *a)
669 d = drawlookup(client, BGLONG(a), 1);
671 return nil; /* caller must check! */
677 drawrectangle(Rectangle *r, uchar *a)
679 r->min.x = BGLONG(a+0*4);
680 r->min.y = BGLONG(a+1*4);
681 r->max.x = BGLONG(a+2*4);
682 r->max.y = BGLONG(a+3*4);
687 drawpoint(Point *p, uchar *a)
689 p->x = BGLONG(a+0*4);
690 p->y = BGLONG(a+1*4);
695 drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
701 fc = &font->fchar[index];
702 r.min.x = p.x+fc->left;
703 r.min.y = p.y-(font->ascent-fc->miny);
704 r.max.x = r.min.x+(fc->maxx-fc->minx);
705 r.max.y = r.min.y+(fc->maxy-fc->miny);
706 sp1.x = sp->x+fc->left;
707 sp1.y = sp->y+fc->miny;
708 memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
716 drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
741 _drawmsgread(void *a, int n)
747 if(cl->readdata == nil){
748 werrstr("no draw data");
751 if(n < cl->nreaddata){
752 werrstr("short read");
756 memmove(a, cl->readdata, cl->nreaddata);
768 _drawmsgwrite(void *v, int n)
770 char cbuf[40], *err, ibuf[12*12+1], *s;
771 int c, ci, doflush, dstid, e0, e1, esize, j, m;
772 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
773 uchar *a, refresh, *u;
777 DImage *di, *ddst, *dsrc, *font, *ll;
782 Memimage *dst, *i, *l, **lp, *mask, *src;
797 /*fprint(2, "msgwrite %d(%d)...", n, *a); */
800 /*fprint(2, "bad command %d\n", *a); */
801 err = "bad draw command";
804 /* allocate: 'b' id[4] screenid[4] refresh[1] chan[4] repl[1]
805 R[4*4] clipR[4*4] rrggbbaa[4]
808 m = 1+4+4+1+4+1+4*4+4*4+4;
812 scrnid = BGSHORT(a+5);
816 drawrectangle(&r, a+15);
817 drawrectangle(&clipr, a+31);
818 value = BGLONG(a+47);
819 if(drawlookup(client, dstid, 0))
822 dscrn = drawlookupscreen(client, scrnid, &cs);
825 scrn = dscrn->screen;
826 if(repl || chan!=scrn->image->chan){
827 err = "image parameters incompatibile with screen";
835 reffn = memlnorefresh;
841 err = "unknown refresh method";
844 l = memlalloc(scrn, r, reffn, 0, value);
847 addflush(l->layer->screenr);
849 rectclip(&l->clipr, r);
850 if(drawinstall(client, dstid, l, dscrn) == 0){
857 if(reffn == drawrefresh){
858 refx = mallocz(sizeof(Refx), 1);
860 if(drawuninstall(client, dstid) < 0)
864 refx->client = client;
865 refx->dimage = drawlookup(client, dstid, 1);
867 memlsetrefresh(l, reffn, refx);
871 i = allocmemimage(r, chan);
878 rectclip(&i->clipr, r);
879 if(drawinstall(client, dstid, i, 0) == 0){
883 memfillcolor(i, value);
886 /* allocate screen: 'A' id[4] imageid[4] fillid[4] public[1] */
894 if(drawlookupdscreen(dstid))
896 ddst = drawlookup(client, BGLONG(a+5), 1);
897 dsrc = drawlookup(client, BGLONG(a+9), 1);
898 if(ddst==0 || dsrc==0)
900 if(drawinstallscreen(client, 0, dstid, ddst, dsrc, a[13]) == 0)
904 /* set repl and clip: 'c' dstid[4] repl[1] clipR[4*4] */
909 ddst = drawlookup(client, BGLONG(a+1), 1);
913 err = "can't change repl/clipr of shared image";
919 drawrectangle(&dst->clipr, a+6);
922 /* draw: 'd' dstid[4] srcid[4] maskid[4] R[4*4] P[2*4] P[2*4] */
924 m = 1+4+4+4+4*4+2*4+2*4;
927 dst = drawimage(client, a+1);
929 src = drawimage(client, a+5);
930 mask = drawimage(client, a+9);
931 if(!dst || !src || !mask)
933 drawrectangle(&r, a+13);
936 op = drawclientop(client);
937 memdraw(dst, r, src, p, mask, q, op);
938 dstflush(dstid, dst, r);
941 /* toggle debugging: 'D' val[1] */
949 /* ellipse: 'e' dstid[4] srcid[4] center[2*4] a[4] b[4] thick[4] sp[2*4] alpha[4] phi[4]*/
952 m = 1+4+4+2*4+4+4+4+2*4+2*4;
955 dst = drawimage(client, a+1);
957 src = drawimage(client, a+5);
964 err = "invalid ellipse semidiameter";
969 err = "negative ellipse thickness";
973 drawpoint(&sp, a+29);
979 op = drawclientop(client);
980 /* high bit indicates arc angles are present */
981 if(ox & ((ulong)1<<31)){
982 if((ox & ((ulong)1<<30)) == 0)
983 ox &= ~((ulong)1<<31);
984 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
986 memellipse(dst, p, e0, e1, c, src, sp, op);
987 dstflush(dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
990 /* free: 'f' id[4] */
995 ll = drawlookup(client, BGLONG(a+1), 0);
996 if(ll && ll->dscreen && ll->dscreen->owner != client)
997 ll->dscreen->owner->refreshme = 1;
998 if(drawuninstall(client, BGLONG(a+1)) < 0)
1002 /* free screen: 'F' id[4] */
1007 if(!drawlookupscreen(client, BGLONG(a+1), &cs))
1009 drawuninstallscreen(client, cs);
1012 /* initialize font: 'i' fontid[4] nchars[4] ascent[1] */
1017 dstid = BGLONG(a+1);
1019 err = "can't use display as font";
1022 font = drawlookup(client, dstid, 1);
1025 if(font->image->layer){
1026 err = "can't use window as font";
1030 if(ni<=0 || ni>4096){
1031 err = "bad font size (4096 chars max)";
1034 free(font->fchar); /* should we complain if non-zero? */
1035 font->fchar = mallocz(ni*sizeof(FChar), 1);
1036 if(font->fchar == 0){
1037 err = "no memory for font";
1040 memset(font->fchar, 0, ni*sizeof(FChar));
1042 font->ascent = a[9];
1045 /* set image 0 to screen image */
1050 if(drawlookup(client, 0, 0))
1052 drawinstall(client, 0, screenimage, 0);
1056 /* get image info: 'I' */
1061 if(client->infoid < 0)
1063 if(client->infoid == 0){
1068 di = drawlookup(client, client->infoid, 1);
1073 ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d"
1074 " %11d %11d %11d %11d ",
1077 chantostr(cbuf, i->chan),
1078 (i->flags&Frepl)==Frepl,
1079 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
1080 i->clipr.min.x, i->clipr.min.y,
1081 i->clipr.max.x, i->clipr.max.y);
1082 free(client->readdata);
1083 client->readdata = malloc(ni);
1084 if(client->readdata == nil)
1086 memmove(client->readdata, ibuf, ni);
1087 client->nreaddata = ni;
1088 client->infoid = -1;
1091 /* query: 'Q' n[1] queryspec[n] */
1099 for(c=0; c<a[1]; c++) {
1102 err = "unknown query";
1106 fmtprint(&fmt, "%11d ", forcedpi);
1108 fmtprint(&fmt, "%11d ", displaydpi);
1112 client->readdata = (uchar*)fmtstrflush(&fmt);
1113 if(client->readdata == nil)
1115 client->nreaddata = strlen((char*)client->readdata);
1118 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */
1120 m = 1+4+4+2+4*4+2*4+1+1;
1123 font = drawlookup(client, BGLONG(a+1), 1);
1126 if(font->nfchar == 0)
1128 src = drawimage(client, a+5);
1132 if(ci >= font->nfchar)
1134 drawrectangle(&r, a+11);
1135 drawpoint(&p, a+27);
1136 memdraw(font->image, r, src, p, memopaque, p, S);
1137 fc = &font->fchar[ci];
1146 /* draw line: 'L' dstid[4] p0[2*4] p1[2*4] end0[4] end1[4] radius[4] srcid[4] sp[2*4] */
1148 m = 1+4+2*4+2*4+4+4+4+4+2*4;
1151 dst = drawimage(client, a+1);
1152 dstid = BGLONG(a+1);
1154 drawpoint(&q, a+13);
1159 err = "negative line width";
1162 src = drawimage(client, a+33);
1165 drawpoint(&sp, a+37);
1166 op = drawclientop(client);
1167 memline(dst, p, q, e0, e1, j, src, sp, op);
1168 /* avoid memlinebbox if possible */
1169 if(dstid==0 || dst->layer!=nil){
1170 /* BUG: this is terribly inefficient: update maximal containing rect*/
1171 r = memlinebbox(p, q, e0, e1, j);
1172 dstflush(dstid, dst, insetrect(r, -(1+1+j)));
1176 /* create image mask: 'm' newid[4] id[4] */
1187 /* attach to a named image: 'n' dstid[4] j[1] name[j] */
1193 if(j == 0) /* give me a non-empty name please */
1198 dstid = BGLONG(a+1);
1199 if(drawlookup(client, dstid, 0))
1201 dn = drawlookupname(j, (char*)a+6);
1207 if(drawinstall(client, dstid, dn->dimage->image, 0) == 0)
1209 di = drawlookup(client, dstid, 0);
1212 di->vers = dn->vers;
1214 di->fromname = dn->dimage;
1215 di->fromname->ref++;
1216 memmove(di->name, a+6, j);
1218 client->infoid = dstid;
1221 /* name an image: 'N' dstid[4] in[1] j[1] name[j] */
1228 if(j == 0) /* give me a non-empty name please */
1233 di = drawlookup(client, BGLONG(a+1), 0);
1239 if(drawaddname(client, di, j, (char*)a+7, &err) < 0)
1242 dn = drawlookupname(j, (char*)a+7);
1245 if(dn->dimage != di)
1251 /* position window: 'o' id[4] r.min [2*4] screenr.min [2*4] */
1256 dst = drawimage(client, a+1);
1261 drawpoint(&q, a+13);
1262 r = dst->layer->screenr;
1263 ni = memlorigin(dst, p, q);
1265 err = "image origin failed";
1270 addflush(dst->layer->screenr);
1271 ll = drawlookup(client, BGLONG(a+1), 1);
1272 drawrefreshscreen(ll, client);
1277 /* set compositing operator for next draw operation: 'O' op */
1285 /* filled polygon: 'P' dstid[4] n[2] wind[4] ignore[2*4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1286 /* polygon: 'p' dstid[4] n[2] end0[4] end1[4] radius[4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1289 m = 1+4+2+4+4+4+4+2*4;
1292 dstid = BGLONG(a+1);
1293 dst = drawimage(client, a+1);
1296 err = "negative cout in polygon";
1305 err = "negative polygon line width";
1309 src = drawimage(client, a+19);
1312 drawpoint(&sp, a+23);
1313 drawpoint(&p, a+31);
1315 pp = mallocz(ni*sizeof(Point), 1);
1319 if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data))
1320 doflush = 1; /* simplify test in loop */
1324 for(y=0; y<ni; y++){
1327 u = drawcoord(u, a+n, ox, &p.x);
1330 u = drawcoord(u, a+n, oy, &p.y);
1339 c = memlineendsize(e0);
1344 c = memlineendsize(e1);
1349 if(*a=='P' && e0!=1 && e0 !=~0)
1352 r = Rect(q.x-oesize, q.y-oesize, q.x+oesize+1, q.y+oesize+1);
1353 combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1355 if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */
1356 dstflush(dstid, dst, r);
1361 dstflush(dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1362 op = drawclientop(client);
1364 mempoly(dst, pp, ni, e0, e1, j, src, sp, op);
1366 memfillpoly(dst, pp, ni, e0, src, sp, op);
1371 /* read: 'r' id[4] R[4*4] */
1376 i = drawimage(client, a+1);
1379 drawrectangle(&r, a+5);
1380 if(!rectinrect(r, i->r))
1382 c = bytesperline(r, i->depth);
1384 free(client->readdata);
1385 client->readdata = mallocz(c, 0);
1386 if(client->readdata == nil){
1387 err = "readimage malloc failed";
1390 client->nreaddata = memunload(i, r, client->readdata, c);
1391 if(client->nreaddata < 0){
1392 free(client->readdata);
1393 client->readdata = nil;
1394 err = "bad readimage call";
1399 /* string: 's' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] ni*(index[2]) */
1400 /* stringbg: 'x' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] bgid[4] bgpt[2*4] ni*(index[2]) */
1403 m = 1+4+4+4+2*4+4*4+2*4+2;
1409 dst = drawimage(client, a+1);
1410 dstid = BGLONG(a+1);
1411 src = drawimage(client, a+5);
1414 font = drawlookup(client, BGLONG(a+9), 1);
1417 if(font->nfchar == 0)
1419 drawpoint(&p, a+13);
1420 drawrectangle(&r, a+21);
1421 drawpoint(&sp, a+37);
1429 op = drawclientop(client);
1431 /* paint background */
1432 l = drawimage(client, a+47);
1435 drawpoint(&q, a+51);
1437 r.min.y = p.y-font->ascent;
1439 r.max.y = r.min.y+Dy(font->image->r);
1443 if(ci<0 || ci>=font->nfchar){
1447 r.max.x += font->fchar[ci].width;
1450 memdraw(dst, r, l, q, memopaque, ZP, op);
1456 if(ci<0 || ci>=font->nfchar){
1460 q = drawchar(dst, q, src, &sp, font, ci, op);
1464 p.y -= font->ascent;
1465 dstflush(dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
1468 /* use public screen: 'S' id[4] chan[4] */
1473 dstid = BGLONG(a+1);
1476 dscrn = drawlookupdscreen(dstid);
1477 if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client))
1479 if(dscrn->screen->image->chan != BGLONG(a+5)){
1480 err = "inconsistent chan";
1483 if(drawinstallscreen(client, dscrn, 0, 0, 0, 0) == 0)
1487 /* top or bottom windows: 't' top[1] nw[2] n*id[4] */
1500 lp = mallocz(nw*sizeof(Memimage*), 1);
1503 for(j=0; j<nw; j++){
1504 lp[j] = drawimage(client, a+1+1+2+j*4);
1510 if(lp[0]->layer == 0){
1511 err = "images are not windows";
1516 if(lp[j]->layer->screen != lp[0]->layer->screen){
1517 err = "images not on same screen";
1522 memltofrontn(lp, nw);
1524 memltorearn(lp, nw);
1525 if(lp[0]->layer->screen->image->data == screenimage->data)
1527 addflush(lp[j]->layer->screenr);
1529 ll = drawlookup(client, BGLONG(a+1+1+2), 1);
1530 drawrefreshscreen(ll, client);
1539 /* write: 'y' id[4] R[4*4] data[x*1] */
1540 /* write from compressed data: 'Y' id[4] R[4*4] data[x*1] */
1546 dstid = BGLONG(a+1);
1547 dst = drawimage(client, a+1);
1550 drawrectangle(&r, a+5);
1551 if(!rectinrect(r, dst->r))
1553 y = memload(dst, r, a+m, n-m, *a=='Y');
1555 err = "bad writeimage call";
1558 dstflush(dstid, dst, r);
1567 err = "unknown id for draw image";
1570 err = "unknown id for draw screen";
1573 err = "short draw message";
1577 err = "draw read too short";
1581 err = "image id in use";
1584 err = "screen id in use";
1587 err = "image memory allocation failed";
1590 err = "readimage outside image";
1593 err = "writeimage outside image";
1596 err = "image not a font";
1599 err = "character index out of range";
1603 err = "no such draw client";
1606 err = "image has bad depth";
1609 err = "image name in use";
1613 err = "no image with that name";
1616 err = "named image no longer valid";
1619 err = "image already has name";
1622 err = "wrong name for image";
1625 err = "out of memory";
1628 err = "bad argument in draw message";