2 * /dev/draw simulator -- handles the messages prepared by the draw library.
3 * Doesn't simulate the file system part, just the messages.
14 #include <drawfcall.h>
17 static int drawuninstall(Client*, int);
18 static Memimage* drawinstall(Client*, int, Memimage*, DScreen*);
19 static void drawfreedimage(Client*, DImage*);
22 draw_initdisplaymemimage(Client *c, Memimage *m)
31 // gfx_replacescreenimage replaces c's screen image with m.
32 // It is called by the host driver on the main host thread.
34 gfx_replacescreenimage(Client *c, Memimage *m)
37 * Replace the screen image because the screen
40 * In theory there should only be one reference
41 * to the current screen image, and that's through
42 * client0's image 0, installed a few lines above.
43 * Once the client drops the image, the underlying backing
44 * store freed properly. The client is being notified
45 * about the resize through external means, so all we
46 * need to do is this assignment.
54 if(om && --om->screenref == 0){
62 drawrefreshscreen(DImage *l, Client *client)
64 while(l != nil && l->dscreen == nil)
66 if(l != nil && l->dscreen->owner != client)
67 l->dscreen->owner->refreshme = 1;
71 drawrefresh(Memimage *m, Rectangle r, void *v)
85 for(ref=c->refresh; ref; ref=ref->next)
87 combinerect(&ref->r, r);
90 ref = mallocz(sizeof(Refresh), 1);
94 ref->next = c->refresh;
100 addflush(Client *c, Rectangle r)
105 if(/*sdraw.softscreen==0 ||*/ !rectclip(&r, c->screenimage->r))
108 if(c->flushrect.min.x >= c->flushrect.max.x){
114 combinerect(&nbb, r);
116 abb = Dx(c->flushrect)*Dy(c->flushrect);
117 anbb = Dx(nbb)*Dy(nbb);
119 * Area of new waste is area of new bb minus area of old bb,
120 * less the area of the new segment, which we assume is not waste.
121 * This could be negative, but that's OK.
123 c->waste += anbb-abb - ar;
128 * total area is small
129 * waste is less than half total area
132 if(anbb<=1024 || c->waste*2<anbb || rectXrect(c->flushrect, r)){
136 /* emit current state */
140 if(fr.min.x < fr.max.x) {
141 // Unlock drawlk because rpc_flush may want to run on gfx thread,
142 // and gfx thread might be blocked on drawlk trying to install a new screen
153 dstflush(Client *c, int dstid, Memimage *dst, Rectangle r)
158 combinerect(&c->flushrect, r);
161 /* how can this happen? -rsc, dec 12 2002 */
163 fprint(2, "nil dstflush\n");
170 if(l->screen->image->data != c->screenimage->data)
172 r = rectaddpt(r, l->delta);
173 l = l->screen->image->layer;
184 c->flushrect = Rect(10000, 10000, -10000, -10000);
185 if(r.min.x < r.max.x) {
186 // Unlock drawlk because rpc_flush may want to run on gfx thread,
187 // and gfx thread might be blocked on drawlk trying to install a new screen
198 drawcmp(char *a, char *b, int n)
202 return memcmp(a, b, n);
206 drawlookupname(Client *client, int n, char *str)
211 ename = &name[client->nname];
212 for(; name<ename; name++)
213 if(drawcmp(name->name, str, n) == 0)
219 drawgoodname(Client *client, DImage *d)
223 /* if window, validate the screen's own images */
225 if(drawgoodname(client, d->dscreen->dimage) == 0
226 || drawgoodname(client, d->dscreen->dfill) == 0)
230 n = drawlookupname(client, strlen(d->name), d->name);
231 if(n==nil || n->vers!=d->vers)
237 drawlookup(Client *client, int id, int checkname)
241 d = client->dimage[id&HASHMASK];
245 * BUG: should error out but too hard.
248 if(checkname && !drawgoodname(client, d))
258 drawlookupdscreen(Client *c, int id)
272 drawlookupscreen(Client *client, int id, CScreen **cs)
278 if(s->dscreen->id == id){
284 /* caller must check! */
289 drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
293 d = mallocz(sizeof(DImage), 1);
306 d->dscreen = dscreen;
307 d->next = client->dimage[id&HASHMASK];
308 client->dimage[id&HASHMASK] = d;
313 drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public)
318 c = mallocz(sizeof(CScreen), 1);
319 if(dimage && dimage->image && dimage->image->chan == 0){
320 fprint(2, "bad image %p in drawinstallscreen", dimage->image);
327 d = mallocz(sizeof(DScreen), 1);
332 s = mallocz(sizeof(Memscreen), 1);
342 s->image = dimage->image;
347 s->fill = dfill->image;
354 d->next = client->dscreen;
360 c->next = client->cscreen;
366 drawdelname(Client *client, DName *name)
370 i = name-client->name;
371 memmove(name, name+1, (client->nname-(i+1))*sizeof(DName));
376 drawfreedscreen(Client *client, DScreen *this)
382 fprint(2, "negative ref in drawfreedscreen\n");
385 ds = client->dscreen;
387 client->dscreen = this->next;
390 while(next = ds->next){ /* assign = */
392 ds->next = this->next;
398 * Should signal Enodrawimage, but too hard.
404 drawfreedimage(client, this->dimage);
406 drawfreedimage(client, this->dfill);
412 drawfreedimage(Client *client, DImage *dimage)
420 fprint(2, "negative ref in drawfreedimage\n");
425 for(i=0; i<client->nname; )
426 if(client->name[i].dimage == dimage)
427 drawdelname(client, client->name+i);
430 if(dimage->fromname){ /* acquired by name; owned by someone else*/
431 drawfreedimage(client, dimage->fromname);
434 ds = dimage->dscreen;
436 dimage->dscreen = nil; /* paranoia */
439 if(l->data == client->screenimage->data)
440 addflush(client, l->layer->screenr);
441 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
442 free(l->layer->refreshptr);
443 l->layer->refreshptr = nil;
444 if(drawgoodname(client, dimage))
448 drawfreedscreen(client, ds);
452 else if(--l->screenref==0)
461 drawuninstallscreen(Client *client, CScreen *this)
465 cs = client->cscreen;
467 client->cscreen = this->next;
468 drawfreedscreen(client, this->dscreen);
472 while(next = cs->next){ /* assign = */
474 cs->next = this->next;
475 drawfreedscreen(client, this->dscreen);
484 drawuninstall(Client *client, int id)
488 for(l=&client->dimage[id&HASHMASK]; (d=*l) != nil; l=&d->next){
491 drawfreedimage(client, d);
499 drawaddname(Client *client, DImage *di, int n, char *str, char **err)
501 DName *name, *ename, *new, *t;
505 ename = &name[client->nname];
506 for(; name<ename; name++)
507 if(drawcmp(name->name, str, n) == 0){
508 *err = "image name in use";
511 t = mallocz((client->nname+1)*sizeof(DName), 1);
513 if(t == nil || ns == nil){
516 *err = "out of memory";
519 memmove(t, client->name, client->nname*sizeof(DName));
522 new = &client->name[client->nname++];
524 memmove(new->name, str, n);
527 new->client = client;
528 new->vers = ++client->namevers;
533 drawclientop(Client *cl)
543 drawimage(Client *client, uchar *a)
547 d = drawlookup(client, BGLONG(a), 1);
549 return nil; /* caller must check! */
554 drawrectangle(Rectangle *r, uchar *a)
556 r->min.x = BGLONG(a+0*4);
557 r->min.y = BGLONG(a+1*4);
558 r->max.x = BGLONG(a+2*4);
559 r->max.y = BGLONG(a+3*4);
563 drawpoint(Point *p, uchar *a)
565 p->x = BGLONG(a+0*4);
566 p->y = BGLONG(a+1*4);
570 drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
576 fc = &font->fchar[index];
577 r.min.x = p.x+fc->left;
578 r.min.y = p.y-(font->ascent-fc->miny);
579 r.max.x = r.min.x+(fc->maxx-fc->minx);
580 r.max.y = r.min.y+(fc->maxy-fc->miny);
581 sp1.x = sp->x+fc->left;
582 sp1.y = sp->y+fc->miny;
583 memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
590 drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
615 draw_dataread(Client *cl, void *a, int n)
618 if(cl->readdata == nil){
619 werrstr("no draw data");
622 if(n < cl->nreaddata){
623 werrstr("short read");
627 memmove(a, cl->readdata, cl->nreaddata);
630 qunlock(&cl->drawlk);
634 qunlock(&cl->drawlk);
639 draw_datawrite(Client *client, void *v, int n)
641 char cbuf[40], *err, ibuf[12*12+1], *s;
642 int c, ci, doflush, dstid, e0, e1, esize, j, m;
643 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
644 uchar *a, refresh, *u;
647 DImage *di, *ddst, *dsrc, *font, *ll;
652 Memimage *dst, *i, *l, **lp, *mask, *src;
659 qlock(&client->drawlk);
667 /*fprint(2, "msgwrite %d(%d)...", n, *a); */
670 /*fprint(2, "bad command %d\n", *a); */
671 err = "bad draw command";
674 /* allocate: 'b' id[4] screenid[4] refresh[1] chan[4] repl[1]
675 R[4*4] clipR[4*4] rrggbbaa[4]
678 m = 1+4+4+1+4+1+4*4+4*4+4;
682 scrnid = BGSHORT(a+5);
686 drawrectangle(&r, a+15);
687 drawrectangle(&clipr, a+31);
688 value = BGLONG(a+47);
689 if(drawlookup(client, dstid, 0))
692 dscrn = drawlookupscreen(client, scrnid, &cs);
695 scrn = dscrn->screen;
696 if(repl || chan!=scrn->image->chan){
697 err = "image parameters incompatibile with screen";
705 reffn = memlnorefresh;
711 err = "unknown refresh method";
714 l = memlalloc(scrn, r, reffn, 0, value);
717 addflush(client, l->layer->screenr);
719 rectclip(&l->clipr, r);
720 if(drawinstall(client, dstid, l, dscrn) == 0){
727 if(reffn == drawrefresh){
728 refx = mallocz(sizeof(Refx), 1);
730 if(drawuninstall(client, dstid) < 0)
734 refx->client = client;
735 refx->dimage = drawlookup(client, dstid, 1);
737 memlsetrefresh(l, reffn, refx);
741 i = allocmemimage(r, chan);
748 rectclip(&i->clipr, r);
749 if(drawinstall(client, dstid, i, 0) == 0){
753 memfillcolor(i, value);
756 /* allocate screen: 'A' id[4] imageid[4] fillid[4] public[1] */
764 if(drawlookupdscreen(client, dstid))
766 ddst = drawlookup(client, BGLONG(a+5), 1);
767 dsrc = drawlookup(client, BGLONG(a+9), 1);
768 if(ddst==0 || dsrc==0)
770 if(drawinstallscreen(client, 0, dstid, ddst, dsrc, a[13]) == 0)
774 /* set repl and clip: 'c' dstid[4] repl[1] clipR[4*4] */
779 ddst = drawlookup(client, BGLONG(a+1), 1);
783 err = "can't change repl/clipr of shared image";
789 drawrectangle(&dst->clipr, a+6);
792 /* draw: 'd' dstid[4] srcid[4] maskid[4] R[4*4] P[2*4] P[2*4] */
794 m = 1+4+4+4+4*4+2*4+2*4;
797 dst = drawimage(client, a+1);
799 src = drawimage(client, a+5);
800 mask = drawimage(client, a+9);
801 if(!dst || !src || !mask)
803 drawrectangle(&r, a+13);
806 op = drawclientop(client);
807 memdraw(dst, r, src, p, mask, q, op);
808 dstflush(client, dstid, dst, r);
811 /* toggle debugging: 'D' val[1] */
819 /* ellipse: 'e' dstid[4] srcid[4] center[2*4] a[4] b[4] thick[4] sp[2*4] alpha[4] phi[4]*/
822 m = 1+4+4+2*4+4+4+4+2*4+2*4;
825 dst = drawimage(client, a+1);
827 src = drawimage(client, a+5);
834 err = "invalid ellipse semidiameter";
839 err = "negative ellipse thickness";
843 drawpoint(&sp, a+29);
849 op = drawclientop(client);
850 /* high bit indicates arc angles are present */
851 if(ox & ((ulong)1<<31)){
852 if((ox & ((ulong)1<<30)) == 0)
853 ox &= ~((ulong)1<<31);
854 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
856 memellipse(dst, p, e0, e1, c, src, sp, op);
857 dstflush(client, dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
860 /* free: 'f' id[4] */
865 ll = drawlookup(client, BGLONG(a+1), 0);
866 if(ll && ll->dscreen && ll->dscreen->owner != client)
867 ll->dscreen->owner->refreshme = 1;
868 if(drawuninstall(client, BGLONG(a+1)) < 0)
872 /* free screen: 'F' id[4] */
877 if(!drawlookupscreen(client, BGLONG(a+1), &cs))
879 drawuninstallscreen(client, cs);
882 /* initialize font: 'i' fontid[4] nchars[4] ascent[1] */
889 err = "can't use display as font";
892 font = drawlookup(client, dstid, 1);
895 if(font->image->layer){
896 err = "can't use window as font";
900 if(ni<=0 || ni>4096){
901 err = "bad font size (4096 chars max)";
904 free(font->fchar); /* should we complain if non-zero? */
905 font->fchar = mallocz(ni*sizeof(FChar), 1);
906 if(font->fchar == 0){
907 err = "no memory for font";
910 memset(font->fchar, 0, ni*sizeof(FChar));
915 /* set image 0 to screen image */
920 if(drawlookup(client, 0, 0))
922 drawinstall(client, 0, client->screenimage, 0);
926 /* get image info: 'I' */
931 if(client->infoid < 0)
933 if(client->infoid == 0){
934 i = client->screenimage;
938 di = drawlookup(client, client->infoid, 1);
943 ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d"
944 " %11d %11d %11d %11d ",
947 chantostr(cbuf, i->chan),
948 (i->flags&Frepl)==Frepl,
949 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
950 i->clipr.min.x, i->clipr.min.y,
951 i->clipr.max.x, i->clipr.max.y);
952 free(client->readdata);
953 client->readdata = malloc(ni);
954 if(client->readdata == nil)
956 memmove(client->readdata, ibuf, ni);
957 client->nreaddata = ni;
961 /* query: 'Q' n[1] queryspec[n] */
969 for(c=0; c<a[1]; c++) {
972 err = "unknown query";
976 fmtprint(&fmt, "%11d ", client->forcedpi);
978 fmtprint(&fmt, "%11d ", client->displaydpi);
982 client->readdata = (uchar*)fmtstrflush(&fmt);
983 if(client->readdata == nil)
985 client->nreaddata = strlen((char*)client->readdata);
988 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */
990 m = 1+4+4+2+4*4+2*4+1+1;
993 font = drawlookup(client, BGLONG(a+1), 1);
996 if(font->nfchar == 0)
998 src = drawimage(client, a+5);
1002 if(ci >= font->nfchar)
1004 drawrectangle(&r, a+11);
1005 drawpoint(&p, a+27);
1006 memdraw(font->image, r, src, p, memopaque, p, S);
1007 fc = &font->fchar[ci];
1016 /* draw line: 'L' dstid[4] p0[2*4] p1[2*4] end0[4] end1[4] radius[4] srcid[4] sp[2*4] */
1018 m = 1+4+2*4+2*4+4+4+4+4+2*4;
1021 dst = drawimage(client, a+1);
1022 dstid = BGLONG(a+1);
1024 drawpoint(&q, a+13);
1029 err = "negative line width";
1032 src = drawimage(client, a+33);
1035 drawpoint(&sp, a+37);
1036 op = drawclientop(client);
1037 memline(dst, p, q, e0, e1, j, src, sp, op);
1038 /* avoid memlinebbox if possible */
1039 if(dstid==0 || dst->layer!=nil){
1040 /* BUG: this is terribly inefficient: update maximal containing rect*/
1041 r = memlinebbox(p, q, e0, e1, j);
1042 dstflush(client, dstid, dst, insetrect(r, -(1+1+j)));
1046 /* create image mask: 'm' newid[4] id[4] */
1057 /* attach to a named image: 'n' dstid[4] j[1] name[j] */
1063 if(j == 0) /* give me a non-empty name please */
1068 dstid = BGLONG(a+1);
1069 if(drawlookup(client, dstid, 0))
1071 dn = drawlookupname(client, j, (char*)a+6);
1077 if(drawinstall(client, dstid, dn->dimage->image, 0) == 0)
1079 di = drawlookup(client, dstid, 0);
1082 di->vers = dn->vers;
1084 di->fromname = dn->dimage;
1085 di->fromname->ref++;
1086 memmove(di->name, a+6, j);
1088 client->infoid = dstid;
1091 /* name an image: 'N' dstid[4] in[1] j[1] name[j] */
1098 if(j == 0) /* give me a non-empty name please */
1103 di = drawlookup(client, BGLONG(a+1), 0);
1109 if(drawaddname(client, di, j, (char*)a+7, &err) < 0)
1112 dn = drawlookupname(client, j, (char*)a+7);
1115 if(dn->dimage != di)
1117 drawdelname(client, dn);
1121 /* position window: 'o' id[4] r.min [2*4] screenr.min [2*4] */
1126 dst = drawimage(client, a+1);
1131 drawpoint(&q, a+13);
1132 r = dst->layer->screenr;
1133 ni = memlorigin(dst, p, q);
1135 err = "image origin failed";
1139 addflush(client, r);
1140 addflush(client, dst->layer->screenr);
1141 ll = drawlookup(client, BGLONG(a+1), 1);
1142 drawrefreshscreen(ll, client);
1147 /* set compositing operator for next draw operation: 'O' op */
1155 /* filled polygon: 'P' dstid[4] n[2] wind[4] ignore[2*4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1156 /* polygon: 'p' dstid[4] n[2] end0[4] end1[4] radius[4] srcid[4] sp[2*4] p0[2*4] dp[2*2*n] */
1159 m = 1+4+2+4+4+4+4+2*4;
1162 dstid = BGLONG(a+1);
1163 dst = drawimage(client, a+1);
1166 err = "negative cout in polygon";
1175 err = "negative polygon line width";
1179 src = drawimage(client, a+19);
1182 drawpoint(&sp, a+23);
1183 drawpoint(&p, a+31);
1185 pp = mallocz(ni*sizeof(Point), 1);
1189 if(dstid==0 || (dst->layer && dst->layer->screen->image->data == client->screenimage->data))
1190 doflush = 1; /* simplify test in loop */
1194 for(y=0; y<ni; y++){
1197 u = drawcoord(u, a+n, ox, &p.x);
1200 u = drawcoord(u, a+n, oy, &p.y);
1209 c = memlineendsize(e0);
1214 c = memlineendsize(e1);
1219 if(*a=='P' && e0!=1 && e0 !=~0)
1222 r = Rect(q.x-oesize, q.y-oesize, q.x+oesize+1, q.y+oesize+1);
1223 combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1225 if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */
1226 dstflush(client, dstid, dst, r);
1231 dstflush(client, dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
1232 op = drawclientop(client);
1234 mempoly(dst, pp, ni, e0, e1, j, src, sp, op);
1236 memfillpoly(dst, pp, ni, e0, src, sp, op);
1241 /* read: 'r' id[4] R[4*4] */
1246 i = drawimage(client, a+1);
1249 drawrectangle(&r, a+5);
1250 if(!rectinrect(r, i->r))
1252 c = bytesperline(r, i->depth);
1254 free(client->readdata);
1255 client->readdata = mallocz(c, 0);
1256 if(client->readdata == nil){
1257 err = "readimage malloc failed";
1260 client->nreaddata = memunload(i, r, client->readdata, c);
1261 if(client->nreaddata < 0){
1262 free(client->readdata);
1263 client->readdata = nil;
1264 err = "bad readimage call";
1269 /* string: 's' dstid[4] srcid[4] fontid[4] P[2*4] clipr[4*4] sp[2*4] ni[2] ni*(index[2]) */
1270 /* 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]) */
1273 m = 1+4+4+4+2*4+4*4+2*4+2;
1279 dst = drawimage(client, a+1);
1280 dstid = BGLONG(a+1);
1281 src = drawimage(client, a+5);
1284 font = drawlookup(client, BGLONG(a+9), 1);
1287 if(font->nfchar == 0)
1289 drawpoint(&p, a+13);
1290 drawrectangle(&r, a+21);
1291 drawpoint(&sp, a+37);
1299 op = drawclientop(client);
1301 /* paint background */
1302 l = drawimage(client, a+47);
1305 drawpoint(&q, a+51);
1307 r.min.y = p.y-font->ascent;
1309 r.max.y = r.min.y+Dy(font->image->r);
1313 if(ci<0 || ci>=font->nfchar){
1317 r.max.x += font->fchar[ci].width;
1320 memdraw(dst, r, l, q, memopaque, ZP, op);
1326 if(ci<0 || ci>=font->nfchar){
1330 q = drawchar(dst, q, src, &sp, font, ci, op);
1334 p.y -= font->ascent;
1335 dstflush(client, dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
1338 /* use public screen: 'S' id[4] chan[4] */
1343 dstid = BGLONG(a+1);
1346 dscrn = drawlookupdscreen(client, dstid);
1347 if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client))
1349 if(dscrn->screen->image->chan != BGLONG(a+5)){
1350 err = "inconsistent chan";
1353 if(drawinstallscreen(client, dscrn, 0, 0, 0, 0) == 0)
1357 /* top or bottom windows: 't' top[1] nw[2] n*id[4] */
1370 lp = mallocz(nw*sizeof(Memimage*), 1);
1373 for(j=0; j<nw; j++){
1374 lp[j] = drawimage(client, a+1+1+2+j*4);
1380 if(lp[0]->layer == 0){
1381 err = "images are not windows";
1386 if(lp[j]->layer->screen != lp[0]->layer->screen){
1387 err = "images not on same screen";
1392 memltofrontn(lp, nw);
1394 memltorearn(lp, nw);
1395 if(lp[0]->layer->screen->image->data == client->screenimage->data)
1397 addflush(client, lp[j]->layer->screenr);
1399 ll = drawlookup(client, BGLONG(a+1+1+2), 1);
1400 drawrefreshscreen(ll, client);
1409 /* write: 'y' id[4] R[4*4] data[x*1] */
1410 /* write from compressed data: 'Y' id[4] R[4*4] data[x*1] */
1416 dstid = BGLONG(a+1);
1417 dst = drawimage(client, a+1);
1420 drawrectangle(&r, a+5);
1421 if(!rectinrect(r, dst->r))
1423 y = memload(dst, r, a+m, n-m, *a=='Y');
1425 err = "bad writeimage call";
1428 dstflush(client, dstid, dst, r);
1433 rpc_gfxdrawunlock();
1434 qunlock(&client->drawlk);
1438 err = "unknown id for draw image";
1441 err = "unknown id for draw screen";
1444 err = "short draw message";
1448 err = "draw read too short";
1452 err = "image id in use";
1455 err = "screen id in use";
1458 err = "image memory allocation failed";
1461 err = "readimage outside image";
1464 err = "writeimage outside image";
1467 err = "image not a font";
1470 err = "character index out of range";
1474 err = "no such draw client";
1477 err = "image has bad depth";
1480 err = "image name in use";
1484 err = "no image with that name";
1487 err = "named image no longer valid";
1490 err = "image already has name";
1493 err = "wrong name for image";
1496 err = "out of memory";
1499 err = "bad argument in draw message";
1504 rpc_gfxdrawunlock();
1505 qunlock(&client->drawlk);