2 * /dev/draw simulator -- handles the messages prepared by the draw library.
3 * Includes all the memlayer code even though most programs don't use it.
4 * This whole approach is overkill, but cpu is cheap and it keeps things simple.
13 extern void _flushmemscreen(Rectangle);
16 #define HASHMASK (NHASH-1)
18 typedef struct Client Client;
19 typedef struct Draw Draw;
20 typedef struct DImage DImage;
21 typedef struct DScreen DScreen;
22 typedef struct CScreen CScreen;
23 typedef struct FChar FChar;
24 typedef struct Refresh Refresh;
25 typedef struct Refx Refx;
26 typedef struct DName DName;
43 DImage* dimage[NHASH];
80 int minx; /* left edge of bits */
81 int maxx; /* right edge of bits */
82 uchar miny; /* first non-zero scan-line */
83 uchar maxy; /* last non-zero scan-line + 1 */
84 schar left; /* offset of baseline */
85 uchar width; /* width of baseline */
89 * Reference counts in DImages:
90 * one per open by original client
91 * one per screen image or fill
92 * one per image derived from this one by name
104 DScreen* dscreen; /* 0 if not a window */
105 DImage* fromname; /* image this one is derived from, by name */
128 static Client *client0;
129 static Memimage *screenimage;
130 static Rectangle flushrect;
132 static DScreen* dscreen;
133 static int drawuninstall(Client*, int);
134 static Memimage* drawinstall(Client*, int, Memimage*, DScreen*);
135 static void drawfreedimage(DImage*);
138 _initdisplaymemimage(Display *d, Memimage *m)
142 client0 = mallocz(sizeof(Client), 1);
144 fprint(2, "initdraw: allocating client0: out of memory");
148 client0->clientid = ++sdraw.clientid;
149 client0->op = SoverD;
150 sdraw.client[0] = client0;
152 sdraw.softscreen = 1;
156 _drawreplacescreenimage(Memimage *m)
159 * Replace the screen image because the screen
162 * In theory there should only be one reference
163 * to the current screen image, and that's through
164 * client0's image 0, installed a few lines above.
165 * Once the client drops the image, the underlying backing
166 * store freed properly. The client is being notified
167 * about the resize through external means, so all we
168 * need to do is this assignment.
176 if(om && --om->screenref == 0){
184 drawrefreshscreen(DImage *l, Client *client)
186 while(l != nil && l->dscreen == nil)
188 if(l != nil && l->dscreen->owner != client)
189 l->dscreen->owner->refreshme = 1;
194 drawrefresh(Memimage *m, Rectangle r, void *v)
208 for(ref=c->refresh; ref; ref=ref->next)
209 if(ref->dimage == d){
210 combinerect(&ref->r, r);
213 ref = mallocz(sizeof(Refresh), 1);
217 ref->next = c->refresh;
223 addflush(Rectangle r)
228 if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r))
231 if(flushrect.min.x >= flushrect.max.x){
237 combinerect(&nbb, r);
239 abb = Dx(flushrect)*Dy(flushrect);
240 anbb = Dx(nbb)*Dy(nbb);
242 * Area of new waste is area of new bb minus area of old bb,
243 * less the area of the new segment, which we assume is not waste.
244 * This could be negative, but that's OK.
246 waste += anbb-abb - ar;
251 * total area is small
252 * waste is less than half total area
255 if(anbb<=1024 || waste*2<anbb || rectXrect(flushrect, r)){
259 /* emit current state */
260 if(flushrect.min.x < flushrect.max.x)
261 _flushmemscreen(flushrect);
268 dstflush(int dstid, Memimage *dst, Rectangle r)
273 combinerect(&flushrect, r);
276 /* how can this happen? -rsc, dec 12 2002 */
278 print("nil dstflush\n");
285 if(l->screen->image->data != screenimage->data)
287 r = rectaddpt(r, l->delta);
288 l = l->screen->image->layer;
297 if(flushrect.min.x < flushrect.max.x)
298 _flushmemscreen(flushrect);
299 flushrect = Rect(10000, 10000, -10000, -10000);
304 drawcmp(char *a, char *b, int n)
308 return memcmp(a, b, n);
313 drawlookupname(int n, char *str)
318 ename = &name[sdraw.nname];
319 for(; name<ename; name++)
320 if(drawcmp(name->name, str, n) == 0)
327 drawgoodname(DImage *d)
331 /* if window, validate the screen's own images */
333 if(drawgoodname(d->dscreen->dimage) == 0
334 || drawgoodname(d->dscreen->dfill) == 0)
338 n = drawlookupname(strlen(d->name), d->name);
339 if(n==nil || n->vers!=d->vers)
346 drawlookup(Client *client, int id, int checkname)
350 d = client->dimage[id&HASHMASK];
354 * BUG: should error out but too hard.
357 if(checkname && !drawgoodname(d))
368 drawlookupdscreen(int id)
383 drawlookupscreen(Client *client, int id, CScreen **cs)
389 if(s->dscreen->id == id){
395 /* caller must check! */
401 drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
405 d = mallocz(sizeof(DImage), 1);
418 d->dscreen = dscreen;
419 d->next = client->dimage[id&HASHMASK];
420 client->dimage[id&HASHMASK] = d;
426 drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public)
431 c = mallocz(sizeof(CScreen), 1);
432 if(dimage && dimage->image && dimage->image->chan == 0){
433 print("bad image %p in drawinstallscreen", dimage->image);
440 d = mallocz(sizeof(DScreen), 1);
445 s = mallocz(sizeof(Memscreen), 1);
455 s->image = dimage->image;
460 s->fill = dfill->image;
473 c->next = client->cscreen;
480 drawdelname(DName *name)
485 memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));
491 drawfreedscreen(DScreen *this)
497 print("negative ref in drawfreedscreen\n");
502 dscreen = this->next;
505 while(next = ds->next){ /* assign = */
507 ds->next = this->next;
513 * Should signal Enodrawimage, but too hard.
519 drawfreedimage(this->dimage);
521 drawfreedimage(this->dfill);
528 drawfreedimage(DImage *dimage)
536 print("negative ref in drawfreedimage\n");
541 for(i=0; i<sdraw.nname; )
542 if(sdraw.name[i].dimage == dimage)
543 drawdelname(sdraw.name+i);
546 if(dimage->fromname){ /* acquired by name; owned by someone else*/
547 drawfreedimage(dimage->fromname);
550 ds = dimage->dscreen;
552 dimage->dscreen = nil; /* paranoia */
555 if(l->data == screenimage->data)
556 addflush(l->layer->screenr);
557 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
558 free(l->layer->refreshptr);
559 l->layer->refreshptr = nil;
560 if(drawgoodname(dimage))
568 else if(--l->screenref==0)
578 drawuninstallscreen(Client *client, CScreen *this)
582 cs = client->cscreen;
584 client->cscreen = this->next;
585 drawfreedscreen(this->dscreen);
589 while(next = cs->next){ /* assign = */
591 cs->next = this->next;
592 drawfreedscreen(this->dscreen);
602 drawuninstall(Client *client, int id)
606 for(l=&client->dimage[id&HASHMASK]; (d=*l) != nil; l=&d->next){
618 drawaddname(Client *client, DImage *di, int n, char *str, char **err)
620 DName *name, *ename, *new, *t;
624 ename = &name[sdraw.nname];
625 for(; name<ename; name++)
626 if(drawcmp(name->name, str, n) == 0){
627 *err = "image name in use";
630 t = mallocz((sdraw.nname+1)*sizeof(DName), 1);
632 if(t == nil || ns == nil){
635 *err = "out of memory";
638 memmove(t, sdraw.name, sdraw.nname*sizeof(DName));
641 new = &sdraw.name[sdraw.nname++];
643 memmove(new->name, str, n);
646 new->client = client;
647 new->vers = ++sdraw.vers;
652 drawclientop(Client *cl)
663 drawimage(Client *client, uchar *a)
667 d = drawlookup(client, BGLONG(a), 1);
669 return nil; /* caller must check! */
675 drawrectangle(Rectangle *r, uchar *a)
677 r->min.x = BGLONG(a+0*4);
678 r->min.y = BGLONG(a+1*4);
679 r->max.x = BGLONG(a+2*4);
680 r->max.y = BGLONG(a+3*4);
685 drawpoint(Point *p, uchar *a)
687 p->x = BGLONG(a+0*4);
688 p->y = BGLONG(a+1*4);
693 drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
699 fc = &font->fchar[index];
700 r.min.x = p.x+fc->left;
701 r.min.y = p.y-(font->ascent-fc->miny);
702 r.max.x = r.min.x+(fc->maxx-fc->minx);
703 r.max.y = r.min.y+(fc->maxy-fc->miny);
704 sp1.x = sp->x+fc->left;
705 sp1.y = sp->y+fc->miny;
706 memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
714 drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
739 _drawmsgread(Display *d, void *a, int n)
745 if(cl->readdata == nil){
746 werrstr("no draw data");
749 if(n < cl->nreaddata){
750 werrstr("short read");
754 memmove(a, cl->readdata, cl->nreaddata);
766 _drawmsgwrite(Display *d, void *v, int n)
768 char cbuf[40], *err, ibuf[12*12+1], *s;
769 int c, ci, doflush, dstid, e0, e1, esize, j, m;
770 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
771 uchar *a, refresh, *u;
775 DImage *di, *ddst, *dsrc, *font, *ll;
779 Memimage *dst, *i, *l, **lp, *mask, *src;
795 /*fprint(2, "msgwrite %d(%d)...", n, *a); */
798 /*fprint(2, "bad command %d\n", *a); */
799 err = "bad draw command";
802 /* allocate: 'b' id[4] screenid[4] refresh[1] chan[4] repl[1]
803 R[4*4] clipR[4*4] rrggbbaa[4]
806 m = 1+4+4+1+4+1+4*4+4*4+4;
810 scrnid = BGSHORT(a+5);
814 drawrectangle(&r, a+15);
815 drawrectangle(&clipr, a+31);
816 value = BGLONG(a+47);
817 if(drawlookup(client, dstid, 0))
820 dscrn = drawlookupscreen(client, scrnid, &cs);
823 scrn = dscrn->screen;
824 if(repl || chan!=scrn->image->chan){
825 err = "image parameters incompatibile with screen";
833 reffn = memlnorefresh;
839 err = "unknown refresh method";
842 l = memlalloc(scrn, r, reffn, 0, value);
845 addflush(l->layer->screenr);
847 rectclip(&l->clipr, r);
848 if(drawinstall(client, dstid, l, dscrn) == 0){
855 if(reffn == drawrefresh){
856 refx = mallocz(sizeof(Refx), 1);
858 if(drawuninstall(client, dstid) < 0)
862 refx->client = client;
863 refx->dimage = drawlookup(client, dstid, 1);
865 memlsetrefresh(l, reffn, refx);
869 i = allocmemimage(r, chan);
876 rectclip(&i->clipr, r);
877 if(drawinstall(client, dstid, i, 0) == 0){
881 memfillcolor(i, value);
884 /* allocate screen: 'A' id[4] imageid[4] fillid[4] public[1] */
892 if(drawlookupdscreen(dstid))
894 ddst = drawlookup(client, BGLONG(a+5), 1);
895 dsrc = drawlookup(client, BGLONG(a+9), 1);
896 if(ddst==0 || dsrc==0)
898 if(drawinstallscreen(client, 0, dstid, ddst, dsrc, a[13]) == 0)
902 /* set repl and clip: 'c' dstid[4] repl[1] clipR[4*4] */
907 ddst = drawlookup(client, BGLONG(a+1), 1);
911 err = "can't change repl/clipr of shared image";
917 drawrectangle(&dst->clipr, a+6);
920 /* draw: 'd' dstid[4] srcid[4] maskid[4] R[4*4] P[2*4] P[2*4] */
922 m = 1+4+4+4+4*4+2*4+2*4;
925 dst = drawimage(client, a+1);
927 src = drawimage(client, a+5);
928 mask = drawimage(client, a+9);
929 if(!dst || !src || !mask)
931 drawrectangle(&r, a+13);
934 op = drawclientop(client);
935 memdraw(dst, r, src, p, mask, q, op);
936 dstflush(dstid, dst, r);
939 /* toggle debugging: 'D' val[1] */
947 /* ellipse: 'e' dstid[4] srcid[4] center[2*4] a[4] b[4] thick[4] sp[2*4] alpha[4] phi[4]*/
950 m = 1+4+4+2*4+4+4+4+2*4+2*4;
953 dst = drawimage(client, a+1);
955 src = drawimage(client, a+5);
962 err = "invalid ellipse semidiameter";
967 err = "negative ellipse thickness";
971 drawpoint(&sp, a+29);
977 op = drawclientop(client);
978 /* high bit indicates arc angles are present */
979 if(ox & ((ulong)1<<31)){
980 if((ox & ((ulong)1<<30)) == 0)
981 ox &= ~((ulong)1<<31);
982 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
984 memellipse(dst, p, e0, e1, c, src, sp, op);
985 dstflush(dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
988 /* free: 'f' id[4] */
993 ll = drawlookup(client, BGLONG(a+1), 0);
994 if(ll && ll->dscreen && ll->dscreen->owner != client)
995 ll->dscreen->owner->refreshme = 1;
996 if(drawuninstall(client, BGLONG(a+1)) < 0)
1000 /* free screen: 'F' id[4] */
1005 if(!drawlookupscreen(client, BGLONG(a+1), &cs))
1007 drawuninstallscreen(client, cs);
1010 /* initialize font: 'i' fontid[4] nchars[4] ascent[1] */
1015 dstid = BGLONG(a+1);
1017 err = "can't use display as font";
1020 font = drawlookup(client, dstid, 1);
1023 if(font->image->layer){
1024 err = "can't use window as font";
1028 if(ni<=0 || ni>4096){
1029 err = "bad font size (4096 chars max)";
1032 free(font->fchar); /* should we complain if non-zero? */
1033 font->fchar = mallocz(ni*sizeof(FChar), 1);
1034 if(font->fchar == 0){
1035 err = "no memory for font";
1038 memset(font->fchar, 0, ni*sizeof(FChar));
1040 font->ascent = a[9];
1043 /* set image 0 to screen image */
1048 if(drawlookup(client, 0, 0))
1050 drawinstall(client, 0, screenimage, 0);
1054 /* get image info: 'I' */
1059 if(client->infoid < 0)
1061 if(client->infoid == 0){
1066 di = drawlookup(client, client->infoid, 1);
1071 ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d"
1072 " %11d %11d %11d %11d ",
1075 chantostr(cbuf, i->chan),
1076 (i->flags&Frepl)==Frepl,
1077 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
1078 i->clipr.min.x, i->clipr.min.y,
1079 i->clipr.max.x, i->clipr.max.y);
1080 free(client->readdata);
1081 client->readdata = malloc(ni);
1082 if(client->readdata == nil)
1084 memmove(client->readdata, ibuf, ni);
1085 client->nreaddata = ni;
1086 client->infoid = -1;
1089 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */
1091 m = 1+4+4+2+4*4+2*4+1+1;
1094 font = drawlookup(client, BGLONG(a+1), 1);
1097 if(font->nfchar == 0)
1099 src = drawimage(client, a+5);
1103 if(ci >= font->nfchar)
1105 drawrectangle(&r, a+11);
1106 drawpoint(&p, a+27);
1107 memdraw(font->image, r, src, p, memopaque, p, S);
1108 fc = &font->fchar[ci];
1117 /* draw line: 'L' dstid[4] p0[2*4] p1[2*4] end0[4] end1[4] radius[4] srcid[4] sp[2*4] */
1119 m = 1+4+2*4+2*4+4+4+4+4+2*4;
1122 dst = drawimage(client, a+1);
1123 dstid = BGLONG(a+1);
1125 drawpoint(&q, a+13);
1130 err = "negative line width";
1133 src = drawimage(client, a+33);
1136 drawpoint(&sp, a+37);
1137 op = drawclientop(client);
1138 memline(dst, p, q, e0, e1, j, src, sp, op);
1139 /* avoid memlinebbox if possible */
1140 if(dstid==0 || dst->layer!=nil){
1141 /* BUG: this is terribly inefficient: update maximal containing rect*/
1142 r = memlinebbox(p, q, e0, e1, j);
1143 dstflush(dstid, dst, insetrect(r, -(1+1+j)));
1147 /* create image mask: 'm' newid[4] id[4] */
1158 /* attach to a named image: 'n' dstid[4] j[1] name[j] */
1164 if(j == 0) /* give me a non-empty name please */
1169 dstid = BGLONG(a+1);
1170 if(drawlookup(client, dstid, 0))
1172 dn = drawlookupname(j, (char*)a+6);
1178 if(drawinstall(client, dstid, dn->dimage->image, 0) == 0)
1180 di = drawlookup(client, dstid, 0);
1183 di->vers = dn->vers;
1185 di->fromname = dn->dimage;
1186 di->fromname->ref++;
1187 memmove(di->name, a+6, j);
1189 client->infoid = dstid;
1192 /* name an image: 'N' dstid[4] in[1] j[1] name[j] */
1199 if(j == 0) /* give me a non-empty name please */
1204 di = drawlookup(client, BGLONG(a+1), 0);
1210 if(drawaddname(client, di, j, (char*)a+7, &err) < 0)
1213 dn = drawlookupname(j, (char*)a+7);
1216 if(dn->dimage != di)
1222 /* position window: 'o' id[4] r.min [2*4] screenr.min [2*4] */
1227 dst = drawimage(client, a+1);
1232 drawpoint(&q, a+13);
1233 r = dst->layer->screenr;
1234 ni = memlorigin(dst, p, q);
1236 err = "image origin failed";
1241 addflush(dst->layer->screenr);
1242 ll = drawlookup(client, BGLONG(a+1), 1);
1243 drawrefreshscreen(ll, client);
1248 /* set compositing operator for next draw operation: 'O' op */
1256 /* filled polygon: 'P' dstid[4] n[2] wind[4] ignore[2*4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1257 /* polygon: 'p' dstid[4] n[2] end0[4] end1[4] radius[4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1260 m = 1+4+2+4+4+4+4+2*4;
1263 dstid = BGLONG(a+1);
1264 dst = drawimage(client, a+1);
1267 err = "negative cout in polygon";
1276 err = "negative polygon line width";
1280 src = drawimage(client, a+19);
1283 drawpoint(&sp, a+23);
1284 drawpoint(&p, a+31);
1286 pp = mallocz(ni*sizeof(Point), 1);
1290 if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data))
1291 doflush = 1; /* simplify test in loop */
1295 for(y=0; y<ni; y++){
1298 u = drawcoord(u, a+n, ox, &p.x);
1301 u = drawcoord(u, a+n, oy, &p.y);
1310 c = memlineendsize(e0);
1315 c = memlineendsize(e1);
1320 if(*a=='P' && e0!=1 && e0 !=~0)
1323 r = Rect(q.x-oesize, q.y-oesize, q.x+oesize+1, q.y+oesize+1);
1324 combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1326 if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */
1327 dstflush(dstid, dst, r);
1332 dstflush(dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1333 op = drawclientop(client);
1335 mempoly(dst, pp, ni, e0, e1, j, src, sp, op);
1337 memfillpoly(dst, pp, ni, e0, src, sp, op);
1342 /* read: 'r' id[4] R[4*4] */
1347 i = drawimage(client, a+1);
1350 drawrectangle(&r, a+5);
1351 if(!rectinrect(r, i->r))
1353 c = bytesperline(r, i->depth);
1355 free(client->readdata);
1356 client->readdata = mallocz(c, 0);
1357 if(client->readdata == nil){
1358 err = "readimage malloc failed";
1361 client->nreaddata = memunload(i, r, client->readdata, c);
1362 if(client->nreaddata < 0){
1363 free(client->readdata);
1364 client->readdata = nil;
1365 err = "bad readimage call";
1370 /* string: 's' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] ni*(index[2]) */
1371 /* 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]) */
1374 m = 1+4+4+4+2*4+4*4+2*4+2;
1380 dst = drawimage(client, a+1);
1381 dstid = BGLONG(a+1);
1382 src = drawimage(client, a+5);
1385 font = drawlookup(client, BGLONG(a+9), 1);
1388 if(font->nfchar == 0)
1390 drawpoint(&p, a+13);
1391 drawrectangle(&r, a+21);
1392 drawpoint(&sp, a+37);
1400 op = drawclientop(client);
1402 /* paint background */
1403 l = drawimage(client, a+47);
1406 drawpoint(&q, a+51);
1408 r.min.y = p.y-font->ascent;
1410 r.max.y = r.min.y+Dy(font->image->r);
1414 if(ci<0 || ci>=font->nfchar){
1418 r.max.x += font->fchar[ci].width;
1421 memdraw(dst, r, l, q, memopaque, ZP, op);
1427 if(ci<0 || ci>=font->nfchar){
1431 q = drawchar(dst, q, src, &sp, font, ci, op);
1435 p.y -= font->ascent;
1436 dstflush(dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
1439 /* use public screen: 'S' id[4] chan[4] */
1444 dstid = BGLONG(a+1);
1447 dscrn = drawlookupdscreen(dstid);
1448 if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client))
1450 if(dscrn->screen->image->chan != BGLONG(a+5)){
1451 err = "inconsistent chan";
1454 if(drawinstallscreen(client, dscrn, 0, 0, 0, 0) == 0)
1458 /* top or bottom windows: 't' top[1] nw[2] n*id[4] */
1471 lp = mallocz(nw*sizeof(Memimage*), 1);
1474 for(j=0; j<nw; j++){
1475 lp[j] = drawimage(client, a+1+1+2+j*4);
1481 if(lp[0]->layer == 0){
1482 err = "images are not windows";
1487 if(lp[j]->layer->screen != lp[0]->layer->screen){
1488 err = "images not on same screen";
1493 memltofrontn(lp, nw);
1495 memltorearn(lp, nw);
1496 if(lp[0]->layer->screen->image->data == screenimage->data)
1498 addflush(lp[j]->layer->screenr);
1500 ll = drawlookup(client, BGLONG(a+1+1+2), 1);
1501 drawrefreshscreen(ll, client);
1510 /* write: 'y' id[4] R[4*4] data[x*1] */
1511 /* write from compressed data: 'Y' id[4] R[4*4] data[x*1] */
1517 dstid = BGLONG(a+1);
1518 dst = drawimage(client, a+1);
1521 drawrectangle(&r, a+5);
1522 if(!rectinrect(r, dst->r))
1524 y = memload(dst, r, a+m, n-m, *a=='Y');
1526 err = "bad writeimage call";
1529 dstflush(dstid, dst, r);
1538 err = "unknown id for draw image";
1541 err = "unknown id for draw screen";
1544 err = "short draw message";
1548 err = "draw read too short";
1552 err = "image id in use";
1555 err = "screen id in use";
1558 err = "image memory allocation failed";
1561 err = "readimage outside image";
1564 err = "writeimage outside image";
1567 err = "image not a font";
1570 err = "character index out of range";
1574 err = "no such draw client";
1577 err = "image has bad depth";
1580 err = "image name in use";
1584 err = "no image with that name";
1587 err = "named image no longer valid";
1590 err = "image already has name";
1593 err = "wrong name for image";
1596 err = "out of memory";
1599 err = "bad argument in draw message";