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.
14 #define HASHMASK (NHASH-1)
16 extern void flushmemscreen(Rectangle);
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;
155 _drawreplacescreenimage(Memimage *m)
158 * Replace the screen image because the screen
161 * In theory there should only be one reference
162 * to the current screen image, and that's through
163 * client0's image 0, installed a few lines above.
164 * Once the client drops the image, the underlying backing
165 * store freed properly. The client is being notified
166 * about the resize through external means, so all we
167 * need to do is this assignment.
175 if(om && --om->screenref == 0){
183 drawrefreshscreen(DImage *l, Client *client)
185 while(l != nil && l->dscreen == nil)
187 if(l != nil && l->dscreen->owner != client)
188 l->dscreen->owner->refreshme = 1;
193 drawrefresh(Memimage *m, Rectangle r, void *v)
207 for(ref=c->refresh; ref; ref=ref->next)
208 if(ref->dimage == d){
209 combinerect(&ref->r, r);
212 ref = mallocz(sizeof(Refresh), 1);
216 ref->next = c->refresh;
222 addflush(Rectangle r)
227 if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r))
230 if(flushrect.min.x >= flushrect.max.x){
236 combinerect(&nbb, r);
238 abb = Dx(flushrect)*Dy(flushrect);
239 anbb = Dx(nbb)*Dy(nbb);
241 * Area of new waste is area of new bb minus area of old bb,
242 * less the area of the new segment, which we assume is not waste.
243 * This could be negative, but that's OK.
245 waste += anbb-abb - ar;
250 * total area is small
251 * waste is less than half total area
254 if(anbb<=1024 || waste*2<anbb || rectXrect(flushrect, r)){
258 /* emit current state */
259 if(flushrect.min.x < flushrect.max.x)
260 flushmemscreen(flushrect);
267 dstflush(int dstid, Memimage *dst, Rectangle r)
272 combinerect(&flushrect, r);
275 /* how can this happen? -rsc, dec 12 2002 */
277 print("nil dstflush\n");
284 if(l->screen->image->data != screenimage->data)
286 r = rectaddpt(r, l->delta);
287 l = l->screen->image->layer;
296 if(flushrect.min.x < flushrect.max.x)
297 flushmemscreen(flushrect);
298 flushrect = Rect(10000, 10000, -10000, -10000);
303 drawcmp(char *a, char *b, int n)
307 return memcmp(a, b, n);
312 drawlookupname(int n, char *str)
317 ename = &name[sdraw.nname];
318 for(; name<ename; name++)
319 if(drawcmp(name->name, str, n) == 0)
326 drawgoodname(DImage *d)
330 /* if window, validate the screen's own images */
332 if(drawgoodname(d->dscreen->dimage) == 0
333 || drawgoodname(d->dscreen->dfill) == 0)
337 n = drawlookupname(strlen(d->name), d->name);
338 if(n==nil || n->vers!=d->vers)
345 drawlookup(Client *client, int id, int checkname)
349 d = client->dimage[id&HASHMASK];
353 * BUG: should error out but too hard.
356 if(checkname && !drawgoodname(d))
367 drawlookupdscreen(int id)
382 drawlookupscreen(Client *client, int id, CScreen **cs)
388 if(s->dscreen->id == id){
394 /* caller must check! */
400 drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
404 d = mallocz(sizeof(DImage), 1);
417 d->dscreen = dscreen;
418 d->next = client->dimage[id&HASHMASK];
419 client->dimage[id&HASHMASK] = d;
425 drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public)
430 c = mallocz(sizeof(CScreen), 1);
431 if(dimage && dimage->image && dimage->image->chan == 0){
432 print("bad image %p in drawinstallscreen", dimage->image);
439 d = mallocz(sizeof(DScreen), 1);
444 s = mallocz(sizeof(Memscreen), 1);
454 s->image = dimage->image;
459 s->fill = dfill->image;
472 c->next = client->cscreen;
479 drawdelname(DName *name)
484 memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));
490 drawfreedscreen(DScreen *this)
496 print("negative ref in drawfreedscreen\n");
501 dscreen = this->next;
504 while(next = ds->next){ /* assign = */
506 ds->next = this->next;
512 * Should signal Enodrawimage, but too hard.
518 drawfreedimage(this->dimage);
520 drawfreedimage(this->dfill);
527 drawfreedimage(DImage *dimage)
535 print("negative ref in drawfreedimage\n");
540 for(i=0; i<sdraw.nname; )
541 if(sdraw.name[i].dimage == dimage)
542 drawdelname(sdraw.name+i);
545 if(dimage->fromname){ /* acquired by name; owned by someone else*/
546 drawfreedimage(dimage->fromname);
549 ds = dimage->dscreen;
552 if(l->data == screenimage->data)
553 addflush(l->layer->screenr);
554 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
555 free(l->layer->refreshptr);
556 l->layer->refreshptr = nil;
557 if(drawgoodname(dimage))
565 else if(--l->screenref==0)
575 drawuninstallscreen(Client *client, CScreen *this)
579 cs = client->cscreen;
581 client->cscreen = this->next;
582 drawfreedscreen(this->dscreen);
586 while(next = cs->next){ /* assign = */
588 cs->next = this->next;
589 drawfreedscreen(this->dscreen);
599 drawuninstall(Client *client, int id)
603 d = client->dimage[id&HASHMASK];
607 client->dimage[id&HASHMASK] = d->next;
611 while(next = d->next){ /* assign = */
613 d->next = next->next;
614 drawfreedimage(next);
624 drawaddname(Client *client, DImage *di, int n, char *str, char **err)
626 DName *name, *ename, *new, *t;
630 ename = &name[sdraw.nname];
631 for(; name<ename; name++)
632 if(drawcmp(name->name, str, n) == 0){
633 *err = "image name in use";
636 t = mallocz((sdraw.nname+1)*sizeof(DName), 1);
638 if(t == nil || ns == nil){
641 *err = "out of memory";
644 memmove(t, sdraw.name, sdraw.nname*sizeof(DName));
647 new = &sdraw.name[sdraw.nname++];
649 memmove(new->name, str, n);
652 new->client = client;
653 new->vers = ++sdraw.vers;
658 drawclientop(Client *cl)
669 drawimage(Client *client, uchar *a)
673 d = drawlookup(client, BGLONG(a), 1);
675 return nil; /* caller must check! */
681 drawrectangle(Rectangle *r, uchar *a)
683 r->min.x = BGLONG(a+0*4);
684 r->min.y = BGLONG(a+1*4);
685 r->max.x = BGLONG(a+2*4);
686 r->max.y = BGLONG(a+3*4);
691 drawpoint(Point *p, uchar *a)
693 p->x = BGLONG(a+0*4);
694 p->y = BGLONG(a+1*4);
699 drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
705 fc = &font->fchar[index];
706 r.min.x = p.x+fc->left;
707 r.min.y = p.y-(font->ascent-fc->miny);
708 r.max.x = r.min.x+(fc->maxx-fc->minx);
709 r.max.y = r.min.y+(fc->maxy-fc->miny);
710 sp1.x = sp->x+fc->left;
711 sp1.y = sp->y+fc->miny;
712 memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
720 drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
745 _drawmsgread(Display *d, void *a, int n)
750 inbuf = d->obufp - d->obuf;
753 memmove(a, d->obuf, n);
756 memmove(d->obuf, d->obufp-inbuf, inbuf);
757 d->obufp = d->obuf+inbuf;
763 drawmsgsquirrel(Display *d, void *a, int n)
767 ep = d->obuf + d->obufsize;
768 if(d->obufp + n > ep)
770 memmove(d->obufp, a, n);
775 _drawmsgwrite(Display *d, void *v, int n)
777 char cbuf[40], *err, ibuf[12*12+1], *s;
778 int c, ci, doflush, dstid, e0, e1, esize, j, m;
779 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
780 uchar *a, refresh, *u;
784 DImage *di, *ddst, *dsrc, *font, *ll;
788 Memimage *dst, *i, *l, **lp, *mask, *src;
804 //fprint(2, "msgwrite %d(%d)...", n, *a);
807 //fprint(2, "bad command %d\n", *a);
808 err = "bad draw command";
811 /* allocate: 'b' id[4] screenid[4] refresh[1] chan[4] repl[1]
812 R[4*4] clipR[4*4] rrggbbaa[4]
815 m = 1+4+4+1+4+1+4*4+4*4+4;
819 scrnid = BGSHORT(a+5);
823 drawrectangle(&r, a+15);
824 drawrectangle(&clipr, a+31);
825 value = BGLONG(a+47);
826 if(drawlookup(client, dstid, 0))
829 dscrn = drawlookupscreen(client, scrnid, &cs);
832 scrn = dscrn->screen;
833 if(repl || chan!=scrn->image->chan){
834 err = "image parameters incompatibile with screen";
842 reffn = memlnorefresh;
848 err = "unknown refresh method";
851 l = memlalloc(scrn, r, reffn, 0, value);
854 addflush(l->layer->screenr);
856 rectclip(&l->clipr, r);
857 if(drawinstall(client, dstid, l, dscrn) == 0){
864 if(reffn == drawrefresh){
865 refx = mallocz(sizeof(Refx), 1);
867 if(drawuninstall(client, dstid) < 0)
871 refx->client = client;
872 refx->dimage = drawlookup(client, dstid, 1);
874 memlsetrefresh(l, reffn, refx);
878 i = allocmemimage(r, chan);
885 rectclip(&i->clipr, r);
886 if(drawinstall(client, dstid, i, 0) == 0){
890 memfillcolor(i, value);
893 /* allocate screen: 'A' id[4] imageid[4] fillid[4] public[1] */
901 if(drawlookupdscreen(dstid))
903 ddst = drawlookup(client, BGLONG(a+5), 1);
904 dsrc = drawlookup(client, BGLONG(a+9), 1);
905 if(ddst==0 || dsrc==0)
907 if(drawinstallscreen(client, 0, dstid, ddst, dsrc, a[13]) == 0)
911 /* set repl and clip: 'c' dstid[4] repl[1] clipR[4*4] */
916 ddst = drawlookup(client, BGLONG(a+1), 1);
920 err = "can't change repl/clipr of shared image";
926 drawrectangle(&dst->clipr, a+6);
929 /* draw: 'd' dstid[4] srcid[4] maskid[4] R[4*4] P[2*4] P[2*4] */
931 m = 1+4+4+4+4*4+2*4+2*4;
934 dst = drawimage(client, a+1);
936 src = drawimage(client, a+5);
937 mask = drawimage(client, a+9);
938 if(!dst || !src || !mask)
940 drawrectangle(&r, a+13);
943 op = drawclientop(client);
944 memdraw(dst, r, src, p, mask, q, op);
945 dstflush(dstid, dst, r);
948 /* toggle debugging: 'D' val[1] */
956 /* ellipse: 'e' dstid[4] srcid[4] center[2*4] a[4] b[4] thick[4] sp[2*4] alpha[4] phi[4]*/
959 m = 1+4+4+2*4+4+4+4+2*4+2*4;
962 dst = drawimage(client, a+1);
964 src = drawimage(client, a+5);
971 err = "invalid ellipse semidiameter";
976 err = "negative ellipse thickness";
980 drawpoint(&sp, a+29);
986 op = drawclientop(client);
987 /* high bit indicates arc angles are present */
989 if((ox & (1<<30)) == 0)
991 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
993 memellipse(dst, p, e0, e1, c, src, sp, op);
994 dstflush(dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
997 /* free: 'f' id[4] */
1002 ll = drawlookup(client, BGLONG(a+1), 0);
1003 if(ll && ll->dscreen && ll->dscreen->owner != client)
1004 ll->dscreen->owner->refreshme = 1;
1005 if(drawuninstall(client, BGLONG(a+1)) < 0)
1009 /* free screen: 'F' id[4] */
1014 if(!drawlookupscreen(client, BGLONG(a+1), &cs))
1016 drawuninstallscreen(client, cs);
1019 /* initialize font: 'i' fontid[4] nchars[4] ascent[1] */
1024 dstid = BGLONG(a+1);
1026 err = "can't use display as font";
1029 font = drawlookup(client, dstid, 1);
1032 if(font->image->layer){
1033 err = "can't use window as font";
1037 if(ni<=0 || ni>4096){
1038 err = "bad font size (4096 chars max)";
1041 free(font->fchar); /* should we complain if non-zero? */
1042 font->fchar = mallocz(ni*sizeof(FChar), 1);
1043 if(font->fchar == 0){
1044 err = "no memory for font";
1047 memset(font->fchar, 0, ni*sizeof(FChar));
1049 font->ascent = a[9];
1052 /* set image 0 to screen image */
1057 drawinstall(client, 0, screenimage, 0);
1061 /* get image info: 'I' */
1066 if(client->infoid < 0)
1068 if(client->infoid == 0){
1073 di = drawlookup(client, client->infoid, 1);
1078 ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d"
1079 " %11d %11d %11d %11d ",
1082 chantostr(cbuf, i->chan),
1083 (i->flags&Frepl)==Frepl,
1084 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
1085 i->clipr.min.x, i->clipr.min.y,
1086 i->clipr.max.x, i->clipr.max.y);
1087 drawmsgsquirrel(d, ibuf, ni);
1088 client->infoid = -1;
1091 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */
1093 m = 1+4+4+2+4*4+2*4+1+1;
1096 font = drawlookup(client, BGLONG(a+1), 1);
1099 if(font->nfchar == 0)
1101 src = drawimage(client, a+5);
1105 if(ci >= font->nfchar)
1107 drawrectangle(&r, a+11);
1108 drawpoint(&p, a+27);
1109 memdraw(font->image, r, src, p, memopaque, p, S);
1110 fc = &font->fchar[ci];
1119 /* draw line: 'L' dstid[4] p0[2*4] p1[2*4] end0[4] end1[4] radius[4] srcid[4] sp[2*4] */
1121 m = 1+4+2*4+2*4+4+4+4+4+2*4;
1124 dst = drawimage(client, a+1);
1125 dstid = BGLONG(a+1);
1127 drawpoint(&q, a+13);
1132 err = "negative line width";
1135 src = drawimage(client, a+33);
1138 drawpoint(&sp, a+37);
1139 op = drawclientop(client);
1140 memline(dst, p, q, e0, e1, j, src, sp, op);
1141 /* avoid memlinebbox if possible */
1142 if(dstid==0 || dst->layer!=nil){
1143 /* BUG: this is terribly inefficient: update maximal containing rect*/
1144 r = memlinebbox(p, q, e0, e1, j);
1145 dstflush(dstid, dst, insetrect(r, -(1+1+j)));
1149 /* create image mask: 'm' newid[4] id[4] */
1160 /* attach to a named image: 'n' dstid[4] j[1] name[j] */
1166 if(j == 0) /* give me a non-empty name please */
1171 dstid = BGLONG(a+1);
1172 if(drawlookup(client, dstid, 0))
1174 dn = drawlookupname(j, (char*)a+6);
1180 if(drawinstall(client, dstid, dn->dimage->image, 0) == 0)
1182 di = drawlookup(client, dstid, 0);
1185 di->vers = dn->vers;
1187 di->fromname = dn->dimage;
1188 di->fromname->ref++;
1189 memmove(di->name, a+6, j);
1191 client->infoid = dstid;
1194 /* name an image: 'N' dstid[4] in[1] j[1] name[j] */
1201 if(j == 0) /* give me a non-empty name please */
1206 di = drawlookup(client, BGLONG(a+1), 0);
1212 if(drawaddname(client, di, j, (char*)a+7, &err) < 0)
1215 dn = drawlookupname(j, (char*)a+7);
1218 if(dn->dimage != di)
1224 /* position window: 'o' id[4] r.min [2*4] screenr.min [2*4] */
1229 dst = drawimage(client, a+1);
1234 drawpoint(&q, a+13);
1235 r = dst->layer->screenr;
1236 ni = memlorigin(dst, p, q);
1238 err = "image origin failed";
1243 addflush(dst->layer->screenr);
1244 ll = drawlookup(client, BGLONG(a+1), 1);
1245 drawrefreshscreen(ll, client);
1250 /* set compositing operator for next draw operation: 'O' op */
1258 /* filled polygon: 'P' dstid[4] n[2] wind[4] ignore[2*4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1259 /* polygon: 'p' dstid[4] n[2] end0[4] end1[4] radius[4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1262 m = 1+4+2+4+4+4+4+2*4;
1265 dstid = BGLONG(a+1);
1266 dst = drawimage(client, a+1);
1269 err = "negative cout in polygon";
1278 err = "negative polygon line width";
1282 src = drawimage(client, a+19);
1285 drawpoint(&sp, a+23);
1286 drawpoint(&p, a+31);
1288 pp = mallocz(ni*sizeof(Point), 1);
1292 if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data))
1293 doflush = 1; /* simplify test in loop */
1297 for(y=0; y<ni; y++){
1300 u = drawcoord(u, a+n, ox, &p.x);
1303 u = drawcoord(u, a+n, oy, &p.y);
1312 c = memlineendsize(e0);
1317 c = memlineendsize(e1);
1322 if(*a=='P' && e0!=1 && e0 !=~0)
1325 r = Rect(q.x-oesize, q.y-oesize, q.x+oesize+1, q.y+oesize+1);
1326 combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1328 if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */
1329 dstflush(dstid, dst, r);
1334 dstflush(dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1335 op = drawclientop(client);
1337 mempoly(dst, pp, ni, e0, e1, j, src, sp, op);
1339 memfillpoly(dst, pp, ni, e0, src, sp, op);
1344 /* read: 'r' id[4] R[4*4] */
1349 i = drawimage(client, a+1);
1352 drawrectangle(&r, a+5);
1353 if(!rectinrect(r, i->r))
1355 c = bytesperline(r, i->depth);
1357 free(client->readdata);
1358 client->readdata = mallocz(c, 0);
1359 if(client->readdata == nil){
1360 err = "readimage malloc failed";
1363 client->nreaddata = memunload(i, r, client->readdata, c);
1364 if(client->nreaddata < 0){
1365 free(client->readdata);
1366 client->readdata = nil;
1367 err = "bad readimage call";
1372 /* string: 's' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] ni*(index[2]) */
1373 /* 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]) */
1376 m = 1+4+4+4+2*4+4*4+2*4+2;
1382 dst = drawimage(client, a+1);
1383 dstid = BGLONG(a+1);
1384 src = drawimage(client, a+5);
1387 font = drawlookup(client, BGLONG(a+9), 1);
1390 if(font->nfchar == 0)
1392 drawpoint(&p, a+13);
1393 drawrectangle(&r, a+21);
1394 drawpoint(&sp, a+37);
1402 op = drawclientop(client);
1404 /* paint background */
1405 l = drawimage(client, a+47);
1408 drawpoint(&q, a+51);
1410 r.min.y = p.y-font->ascent;
1412 r.max.y = r.min.y+Dy(font->image->r);
1416 if(ci<0 || ci>=font->nfchar){
1420 r.max.x += font->fchar[ci].width;
1423 memdraw(dst, r, l, q, memopaque, ZP, op);
1429 if(ci<0 || ci>=font->nfchar){
1433 q = drawchar(dst, q, src, &sp, font, ci, op);
1437 p.y -= font->ascent;
1438 dstflush(dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
1441 /* use public screen: 'S' id[4] chan[4] */
1446 dstid = BGLONG(a+1);
1449 dscrn = drawlookupdscreen(dstid);
1450 if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client))
1452 if(dscrn->screen->image->chan != BGLONG(a+5)){
1453 err = "inconsistent chan";
1456 if(drawinstallscreen(client, dscrn, 0, 0, 0, 0) == 0)
1460 /* top or bottom windows: 't' top[1] nw[2] n*id[4] */
1473 lp = mallocz(nw*sizeof(Memimage*), 1);
1476 for(j=0; j<nw; j++){
1477 lp[j] = drawimage(client, a+1+1+2+j*4);
1483 if(lp[0]->layer == 0){
1484 err = "images are not windows";
1489 if(lp[j]->layer->screen != lp[0]->layer->screen){
1490 err = "images not on same screen";
1495 memltofrontn(lp, nw);
1497 memltorearn(lp, nw);
1498 if(lp[0]->layer->screen->image->data == screenimage->data)
1500 addflush(lp[j]->layer->screenr);
1502 ll = drawlookup(client, BGLONG(a+1+1+2), 1);
1503 drawrefreshscreen(ll, client);
1512 /* write: 'y' id[4] R[4*4] data[x*1] */
1513 /* write from compressed data: 'Y' id[4] R[4*4] data[x*1] */
1519 dstid = BGLONG(a+1);
1520 dst = drawimage(client, a+1);
1523 drawrectangle(&r, a+5);
1524 if(!rectinrect(r, dst->r))
1526 y = memload(dst, r, a+m, n-m, *a=='Y');
1528 err = "bad writeimage call";
1531 dstflush(dstid, dst, r);
1540 err = "unknown id for draw image";
1543 err = "unknown id for draw screen";
1546 err = "short draw message";
1550 err = "draw read too short";
1554 err = "image id in use";
1557 err = "screen id in use";
1560 err = "image memory allocation failed";
1563 err = "readimage outside image";
1566 err = "writeimage outside image";
1569 err = "image not a font";
1572 err = "character index out of range";
1576 err = "no such draw client";
1579 err = "image has bad depth";
1582 err = "image name in use";
1586 err = "no image with that name";
1589 err = "named image no longer valid";
1592 err = "image already has name";
1595 err = "wrong name for image";
1598 err = "out of memory";
1601 err = "bad argument in draw message";