History

import devdraw from 9front

cinap_lenrek committed 10 years ago

Commit df777991 parent 17b41ae6 files · +234 −236Browse files

Unified · Split

6 files
  1. gui-osx/screen.c +6 −6
  2. gui-x11/x11.c +13 −10
  3. kern/devdraw.c +204 −204
  4. kern/fns.h +0 −4
  5. kern/screen.h +4 −7
  6. kern/term.c +7 −5
gui-osx/screen.c+6−6
@@ -313,9 +313,9 @@ leave_full_screen() · 312 unmodified lines
313 Rectangle rect = { { 0, 0 },313 Rectangle rect = { { 0, 0 },
314 { bounds.size.width,314 { bounds.size.width,
315 bounds.size.height} };315 bounds.size.height} };
316 drawqlock();316 qlock(&drawlock);
317 flushmemscreen(rect);317 flushmemscreen(rect);
318 drawqunlock();318 qunlock(&drawlock);
319 }319 }
320}320}
321 321
@@ -331,9 +331,9 @@ full_screen() · 9 unmodified lines
331 Rectangle rect = { { 0, 0 },331 Rectangle rect = { { 0, 0 },
332 { bounds.size.width,332 { bounds.size.width,
333 bounds.size.height} };333 bounds.size.height} };
334 drawqlock();334 qlock(&drawlock);
335 flushmemscreen(rect);335 flushmemscreen(rect);
336 drawqunlock();336 qunlock(&drawlock);
337 }337 }
338}338}
339 339
@@ -556,9 +556,9 @@ static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, · 216 unmodified lines
556 Rectangle rect = { { 0, 0 },556 Rectangle rect = { { 0, 0 },
557 { bounds.size.width,557 { bounds.size.width,
558 bounds.size.height} };558 bounds.size.height} };
559 drawqlock();559 qlock(&drawlock);
560 flushmemscreen(rect);560 flushmemscreen(rect);
561 drawqunlock();561 qunlock(&drawlock);
562 break;562 break;
563 563
564 default:564 default:
gui-x11/x11.c+13−10
@@ -163,7 +163,7 @@ flushmemscreen(Rectangle r) · 162 unmodified lines
163 int x, y;163 int x, y;
164 uchar *p;164 uchar *p;
165 165
166 assert(!drawcanqlock());166 assert(!canqlock(&drawlock));
167 if(r.min.x >= r.max.x || r.min.y >= r.max.y)167 if(r.min.x >= r.max.x || r.min.y >= r.max.y)
168 return;168 return;
169 169
@@ -193,9 +193,9 @@ screeninit(void) · 23 unmodified lines
193 193
194 memimageinit();194 memimageinit();
195 terminit();195 terminit();
196 drawqlock();196 qlock(&drawlock);
197 flushmemscreen(gscreen->r);197 flushmemscreen(gscreen->r);
198 drawqunlock();198 qunlock(&drawlock);
199}199}
200 200
201uchar*201uchar*
@@ -230,10 +230,10 @@ revbyte(int b) · 28 unmodified lines
230void230void
231mouseset(Point xy)231mouseset(Point xy)
232{232{
233 drawqlock();233 qlock(&drawlock);
234 XWarpPointer(xdisplay, None, xdrawable, 0, 0, 0, 0, xy.x, xy.y);234 XWarpPointer(xdisplay, None, xdrawable, 0, 0, 0, 0, xy.x, xy.y);
235 XFlush(xdisplay);235 XFlush(xdisplay);
236 drawqunlock();236 qunlock(&drawlock);
237}237}
238 238
239static XCursor xcursor;239static XCursor xcursor;
@@ -252,7 +252,7 @@ setcursor(void) · 12 unmodified lines
252 mask[i] = revbyte(cursor.set[i] | cursor.clr[i]);252 mask[i] = revbyte(cursor.set[i] | cursor.clr[i]);
253 }253 }
254 254
255 drawqlock();255 qlock(&drawlock);
256 fg = map[0];256 fg = map[0];
257 bg = map[255];257 bg = map[255];
258 xsrc = XCreateBitmapFromData(xdisplay, xdrawable, (char*)src, 16, 16);258 xsrc = XCreateBitmapFromData(xdisplay, xdrawable, (char*)src, 16, 16);
@@ -267,20 +267,20 @@ setcursor(void) · 8 unmodified lines
267 XFreePixmap(xdisplay, xsrc);267 XFreePixmap(xdisplay, xsrc);
268 XFreePixmap(xdisplay, xmask);268 XFreePixmap(xdisplay, xmask);
269 XFlush(xdisplay);269 XFlush(xdisplay);
270 drawqunlock();270 qunlock(&drawlock);
271}271}
272 272
273void273void
274cursorarrow(void)274cursorarrow(void)
275{275{
276 drawqlock();276 qlock(&drawlock);
277 if(xcursor != 0){277 if(xcursor != 0){
278 XFreeCursor(xdisplay, xcursor);278 XFreeCursor(xdisplay, xcursor);
279 xcursor = 0;279 xcursor = 0;
280 }280 }
281 XUndefineCursor(xdisplay, xdrawable);281 XUndefineCursor(xdisplay, xdrawable);
282 XFlush(xdisplay);282 XFlush(xdisplay);
283 drawqunlock();283 qunlock(&drawlock);
284}284}
285 285
286static void286static void
@@ -716,7 +716,10 @@ xexpose(XEvent *e) · 429 unmodified lines
716 r.min.y = xe->y;716 r.min.y = xe->y;
717 r.max.x = xe->x + xe->width;717 r.max.x = xe->x + xe->width;
718 r.max.y = xe->y + xe->height;718 r.max.y = xe->y + xe->height;
719 drawflushr(r);719
720 qlock(&drawlock);
721 flushmemscreen(r);
722 qunlock(&drawlock);
720}723}
721 724
722static void725static void
kern/devdraw.c+204−204
@@ -15,6 +15,7 @@ enum · 14 unmodified lines
15{15{
16 Qtopdir = 0,16 Qtopdir = 0,
17 Qnew,17 Qnew,
18 Qwinname,
18 Q3rd,19 Q3rd,
19 Q2nd,20 Q2nd,
20 Qcolormap,21 Qcolormap,
@@ -36,7 +37,7 @@ enum · 15 unmodified lines
36 37
37#define NHASH (1<<5)38#define NHASH (1<<5)
38#define HASHMASK (NHASH-1)39#define HASHMASK (NHASH-1)
39#define IOUNIT (64*1024)40#define IOUNIT (64*1024)
40 41
41typedef struct Client Client;42typedef struct Client Client;
42typedef struct Draw Draw;43typedef struct Draw Draw;
@@ -52,17 +53,15 @@ ulong blanktime = 30; /* in minutes; a half hour */ · 9 unmodified lines
52 53
53struct Draw54struct Draw
54{55{
55 QLock lk;
56 int clientid;56 int clientid;
57 int nclient;57 int nclient;
58 Client** client;58 Client** client;
59 int nname;59 int nname;
60 DName* name;60 DName* name;
61 int vers;61 int vers;
62 int softscreen;62 int softscreen;
63 int blanked; /* screen turned off */63 int blanked; /* screen turned off */
64 ulong blanktime; /* time of last operation */64 ulong blanktime; /* time of last operation */
65 ulong savemap[3*256];
66};65};
67 66
68struct Client67struct Client
@@ -72,6 +71,7 @@ struct Client · 3 unmodified lines
72 CScreen* cscreen;71 CScreen* cscreen;
73 Refresh* refresh;72 Refresh* refresh;
74 Rendez refrend;73 Rendez refrend;
74 QLock refq;
75 uchar* readdata;75 uchar* readdata;
76 int nreaddata;76 int nreaddata;
77 int busy;77 int busy;
@@ -97,10 +97,10 @@ struct Refx · 19 unmodified lines
97 97
98struct DName98struct DName
99{99{
100 char *name;100 char *name;
101 Client *client;101 Client *client;
102 DImage* dimage;102 DImage* dimage;
103 int vers;103 int vers;
104};104};
105 105
106struct FChar106struct FChar
@@ -130,7 +130,7 @@ struct DImage · 23 unmodified lines
130 int nfchar;130 int nfchar;
131 FChar* fchar;131 FChar* fchar;
132 DScreen* dscreen; /* 0 if not a window */132 DScreen* dscreen; /* 0 if not a window */
133 DImage* fromname; /* image this one is derived from, by name */133 DImage* fromname; /* image this one is derived from, by name */
134 DImage* next;134 DImage* next;
135};135};
136 136
@@ -145,16 +145,21 @@ struct DScreen · 8 unmodified lines
145 int id;145 int id;
146 int public;146 int public;
147 int ref;147 int ref;
148 DImage *dimage;148 DImage *dimage;
149 DImage *dfill;149 DImage *dfill;
150 Memscreen* screen;150 Memscreen* screen;
151 Client* owner;151 Client* owner;
152 DScreen* next;152 DScreen* next;
153};153};
154 154
155static Draw sdraw;155static Draw sdraw;
156 QLock drawlock;
157
156static Memimage *screenimage;158static Memimage *screenimage;
157static Memdata screendata;159static DImage* screendimage;
160static char screenname[40];
161static int screennameid;
162
158static Rectangle flushrect;163static Rectangle flushrect;
159static int waste;164static int waste;
160static DScreen* dscreen;165static DScreen* dscreen;
@@ -163,6 +168,7 @@ extern void flushmemscreen(Rectangle); · 2 unmodified lines
163 void drawuninstall(Client*, int);168 void drawuninstall(Client*, int);
164 void drawfreedimage(DImage*);169 void drawfreedimage(DImage*);
165 Client* drawclientofpath(ulong);170 Client* drawclientofpath(ulong);
171 DImage* allocdimage(Memimage*);
166 172
167static char Enodrawimage[] = "unknown id for draw image";173static char Enodrawimage[] = "unknown id for draw image";
168static char Enodrawscreen[] = "unknown id for draw screen";174static char Enodrawscreen[] = "unknown id for draw screen";
@@ -176,42 +182,35 @@ static char Ewriteoutside[] = "writeimage outside image"; · 7 unmodified lines
176static char Enotfont[] = "image not a font";182static char Enotfont[] = "image not a font";
177static char Eindex[] = "character index out of range";183static char Eindex[] = "character index out of range";
178static char Enoclient[] = "no such draw client";184static char Enoclient[] = "no such draw client";
179/* static char Edepth[] = "image has bad depth"; */
180static char Enameused[] = "image name in use";185static char Enameused[] = "image name in use";
181static char Enoname[] = "no image with that name";186static char Enoname[] = "no image with that name";
182static char Eoldname[] = "named image no longer valid";187static char Eoldname[] = "named image no longer valid";
183static char Enamed[] = "image already has name";188static char Enamed[] = "image already has name";
184static char Ewrongname[] = "wrong name for image";189static char Ewrongname[] = "wrong name for image";
185 190
186int191static void
187drawcanqlock(void)192dlock(void)
188{
189 return canqlock(&sdraw.lk);
190}
191
192void
193drawqlock(void)
194{193{
195 qlock(&sdraw.lk);194 qlock(&drawlock);
196}195}
197 196
198void197static void
199drawqunlock(void)198dunlock(void)
200{199{
201 qunlock(&sdraw.lk);200 qunlock(&drawlock);
202}201}
203 202
204static int203static int
205drawgen(Chan *c, char *name, Dirtab *dt, int ndt, int s, Dir *dp)204drawgen(Chan *c, char *n, Dirtab *d, int nd, int s, Dir *dp)
206{205{
207 int t;206 int t;
208 Qid q;207 Qid q;
209 ulong path;208 ulong path;
210 Client *cl;209 Client *cl;
211 210
212 USED(name);211 USED(n);
213 USED(dt);212 USED(d);
214 USED(ndt);213 USED(nd);
215 214
216 q.vers = 0;215 q.vers = 0;
217 216
@@ -241,15 +240,17 @@ drawgen(Chan *c, char *name, Dirtab *dt, int ndt, int s, Dir *dp) · 23 unmodified lines
241 * Top level directory contains the name of the device.240 * Top level directory contains the name of the device.
242 */241 */
243 t = QID(c->qid);242 t = QID(c->qid);
244 if(t == Qtopdir){243 if(t == Qtopdir || t == Qwinname){
245 switch(s){244 if(s == 1 || t == Qwinname){
246 case 0:245 mkqid(&q, Qwinname, 0, QTFILE);
246 devdir(c, q, "winname", 0, eve, 0444, dp);
247 }
248 else if(s == 0){
247 mkqid(&q, Q2nd, 0, QTDIR);249 mkqid(&q, Q2nd, 0, QTDIR);
248 devdir(c, q, "draw", 0, eve, 0555, dp);250 devdir(c, q, "draw", 0, eve, 0555, dp);
249 break;
250 default:
251 return -1;
252 }251 }
252 else
253 return -1;
253 return 1;254 return 1;
254 }255 }
255 256
@@ -326,14 +327,14 @@ drawrefreshscreen(DImage *l, Client *client) · 70 unmodified lines
326 327
327static328static
328void329void
329drawrefresh(Memimage *m, Rectangle r, void *v)330drawrefresh(Memimage *i, Rectangle r, void *v)
330{331{
331 Refx *x;332 Refx *x;
332 DImage *d;333 DImage *d;
333 Client *c;334 Client *c;
334 Refresh *ref;335 Refresh *ref;
335 336
336 USED(m);337 USED(i);
337 338
338 if(v == 0)339 if(v == 0)
339 return;340 return;
@@ -360,9 +361,8 @@ addflush(Rectangle r) · 20 unmodified lines
360 int abb, ar, anbb;361 int abb, ar, anbb;
361 Rectangle nbb;362 Rectangle nbb;
362 363
363 if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r))364 if(sdraw.softscreen==0 || screenimage == nil || !rectclip(&r, screenimage->r))
364 return;365 return;
365
366 if(flushrect.min.x >= flushrect.max.x){366 if(flushrect.min.x >= flushrect.max.x){
367 flushrect = r;367 flushrect = r;
368 waste = 0;368 waste = 0;
@@ -408,13 +408,7 @@ dstflush(int dstid, Memimage *dst, Rectangle r) · 39 unmodified lines
408 combinerect(&flushrect, r);408 combinerect(&flushrect, r);
409 return;409 return;
410 }410 }
411 /* how can this happen? -rsc, dec 12 2002 */411 if(screenimage == nil || dst == nil || (l = dst->layer) == nil)
412 if(dst == 0){
413 print("nil dstflush\n");
414 return;
415 }
416 l = dst->layer;
417 if(l == nil)
418 return;412 return;
419 do{413 do{
420 if(l->screen->image->data != screenimage->data)414 if(l->screen->image->data != screenimage->data)
@@ -428,20 +422,11 @@ dstflush(int dstid, Memimage *dst, Rectangle r) · 7 unmodified lines
428void422void
429drawflush(void)423drawflush(void)
430{424{
431 if(flushrect.min.x < flushrect.max.x)425 if(screenimage && flushrect.min.x < flushrect.max.x)
432 flushmemscreen(flushrect);426 flushmemscreen(flushrect);
433 flushrect = Rect(10000, 10000, -10000, -10000);427 flushrect = Rect(10000, 10000, -10000, -10000);
434}428}
435 429
436void
437drawflushr(Rectangle r)
438{
439 qlock(&sdraw.lk);
440 flushmemscreen(r);
441 qunlock(&sdraw.lk);
442}
443
444static
445int430int
446drawcmp(char *a, char *b, int n)431drawcmp(char *a, char *b, int n)
447{432{
@@ -529,15 +514,14 @@ drawlookupscreen(Client *client, int id, CScreen **cs) · 81 unmodified lines
529 return 0;514 return 0;
530}515}
531 516
532Memimage*517DImage*
533drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)518allocdimage(Memimage *i)
534{519{
535 DImage *d;520 DImage *d;
536 521
537 d = malloc(sizeof(DImage));522 d = malloc(sizeof(DImage));
538 if(d == 0)523 if(d == 0)
539 return 0;524 return 0;
540 d->id = id;
541 d->ref = 1;525 d->ref = 1;
542 d->name = 0;526 d->name = 0;
543 d->vers = 0;527 d->vers = 0;
@@ -545,6 +529,18 @@ drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen) · 1 unmodified line
545 d->nfchar = 0;529 d->nfchar = 0;
546 d->fchar = 0;530 d->fchar = 0;
547 d->fromname = 0;531 d->fromname = 0;
532 return d;
533}
534
535Memimage*
536drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
537{
538 DImage *d;
539
540 d = allocdimage(i);
541 if(d == 0)
542 return 0;
543 d->id = id;
548 d->dscreen = dscreen;544 d->dscreen = dscreen;
549 d->next = client->dimage[id&HASHMASK];545 d->next = client->dimage[id&HASHMASK];
550 client->dimage[id&HASHMASK] = d;546 client->dimage[id&HASHMASK] = d;
@@ -607,6 +603,7 @@ drawdelname(DName *name) · 56 unmodified lines
607{603{
608 int i;604 int i;
609 605
606 free(name->name);
610 i = name-sdraw.name;607 i = name-sdraw.name;
611 memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));608 memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));
612 sdraw.nname--;609 sdraw.nname--;
@@ -627,7 +624,7 @@ drawfreedscreen(DScreen *this) · 14 unmodified lines
627 dscreen = this->next;624 dscreen = this->next;
628 goto Found;625 goto Found;
629 }626 }
630 while((next = ds->next)){ /* assign = */627 while(next = ds->next){ /* assign = */
631 if(next == this){628 if(next == this){
632 ds->next = this->next;629 ds->next = this->next;
633 goto Found;630 goto Found;
@@ -668,12 +665,10 @@ drawfreedimage(DImage *dimage) · 34 unmodified lines
668 drawfreedimage(dimage->fromname);665 drawfreedimage(dimage->fromname);
669 goto Return;666 goto Return;
670 }667 }
671 if(dimage->image == screenimage) /* don't free the display */
672 goto Return;
673 ds = dimage->dscreen;668 ds = dimage->dscreen;
674 if(ds){669 if(ds){
675 l = dimage->image;670 l = dimage->image;
676 if(l->data == screenimage->data)671 if(screenimage && l->data == screenimage->data)
677 addflush(l->layer->screenr);672 addflush(l->layer->screenr);
678 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */673 if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
679 free(l->layer->refreshptr);674 free(l->layer->refreshptr);
@@ -702,7 +697,7 @@ drawuninstallscreen(Client *client, CScreen *this) · 22 unmodified lines
702 free(this);697 free(this);
703 return;698 return;
704 }699 }
705 while((next = cs->next)){ /* assign = */700 while(next = cs->next){ /* assign = */
706 if(next == this){701 if(next == this){
707 cs->next = this->next;702 cs->next = this->next;
708 drawfreedscreen(this->dscreen);703 drawfreedscreen(this->dscreen);
@@ -726,7 +721,7 @@ drawuninstall(Client *client, int id) · 17 unmodified lines
726 drawfreedimage(d);721 drawfreedimage(d);
727 return;722 return;
728 }723 }
729 while((next = d->next)){ /* assign = */724 while(next = d->next){ /* assign = */
730 if(next->id == id){725 if(next->id == id){
731 d->next = next->next;726 d->next = next->next;
732 drawfreedimage(next);727 drawfreedimage(next);
@@ -867,12 +862,8 @@ drawpoint(Point *p, uchar *a) · 134 unmodified lines
867 p->y = BGLONG(a+1*4);862 p->y = BGLONG(a+1*4);
868}863}
869 864
870#define isvgascreen(dst) 1
871
872
873Point865Point
874drawchar(Memimage *dst, Memimage *rdst, Point p, 866drawchar(Memimage *dst, Memimage *rdst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
875 Memimage *src, Point *sp, DImage *font, int index, int op)
876{867{
877 FChar *fc;868 FChar *fc;
878 Rectangle r;869 Rectangle r;
@@ -886,7 +877,7 @@ drawchar(Memimage *dst, Memimage *rdst, Point p, · 7 unmodified lines
886 r.max.y = r.min.y+(fc->maxy-fc->miny);877 r.max.y = r.min.y+(fc->maxy-fc->miny);
887 sp1.x = sp->x+fc->left;878 sp1.x = sp->x+fc->left;
888 sp1.y = sp->y+fc->miny;879 sp1.y = sp->y+fc->miny;
889 880
890 /*881 /*
891 * If we're drawing greyscale fonts onto a VGA screen,882 * If we're drawing greyscale fonts onto a VGA screen,
892 * it's very costly to read the screen memory to do the883 * it's very costly to read the screen memory to do the
@@ -895,7 +886,7 @@ drawchar(Memimage *dst, Memimage *rdst, Point p, · 2 unmodified lines
895 * refer to for the underlying dst pixels instead of reading dst886 * refer to for the underlying dst pixels instead of reading dst
896 * directly.887 * directly.
897 */888 */
898 if(1 || (isvgascreen(dst) && !isvgascreen(rdst) /*&& font->image->depth > 1*/)){889 if(ishwimage(dst) && !ishwimage(rdst) && font->image->depth > 1){
899 if(tmp == nil || tmp->chan != dst->chan || Dx(tmp->r) < Dx(r) || Dy(tmp->r) < Dy(r)){890 if(tmp == nil || tmp->chan != dst->chan || Dx(tmp->r) < Dx(r) || Dy(tmp->r) < Dy(r)){
900 if(tmp)891 if(tmp)
901 freememimage(tmp);892 freememimage(tmp);
@@ -916,60 +907,112 @@ drawchar(Memimage *dst, Memimage *rdst, Point p, · 14 unmodified lines
916 return p;907 return p;
917}908}
918 909
919static int910static DImage*
920initscreenimage(void)911makescreenimage(void)
921{912{
922 int width, depth;913 int width, depth;
923 ulong chan;914 ulong chan;
915 DImage *di;
916 Memdata *md;
917 Memimage *i;
924 Rectangle r;918 Rectangle r;
919 uchar *data;
925 920
926 if(screenimage != nil)921 if((data = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen)) == nil)
927 return 1;922 return nil;
923 if(sdraw.softscreen == 0xa110c){
924 /* hack: softscreen is memimage. */
925 md = *((Memdata**)(data - sizeof(ulong) - sizeof(Memdata*)));
928 926
929 screendata.base = nil;927 assert(md->bdata == data);
930 screendata.bdata = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen);928 assert(md->ref > 1);
931 if(screendata.bdata == nil)929 assert(md->allocd);
932 return 0;
933 screendata.ref = 1;
934 930
935 screenimage = allocmemimaged(r, chan, &screendata);931 if((i = allocmemimaged(r, chan, md)) == nil){
936 if(screenimage == nil){932 md->ref--;
937 /* RSC: BUG: detach screen */933 return nil;
938 return 0;934 }
935 }else{
936 if((md = malloc(sizeof *md)) == nil)
937 return nil;
938 md->allocd = 1;
939 md->base = nil;
940 md->bdata = data;
941 md->ref = 1;
942 if((i = allocmemimaged(r, chan, md)) == nil){
943 free(md);
944 return nil;
945 }
946 }
947 i->width = width;
948 i->clipr = r;
949 di = allocdimage(i);
950 if(di == nil){
951 freememimage(i); /* frees md */
952 return nil;
953 }
954 if(!waserror()){
955 snprint(screenname, sizeof screenname, "noborder.screen.%d", ++screennameid);
956 drawaddname(nil, di, strlen(screenname), screenname);
957 poperror();
939 }958 }
959 return di;
960}
940 961
941 screenimage->width = width;962static int
942 screenimage->clipr = r;963initscreenimage(void)
964{
965 if(screenimage != nil)
966 return 1;
967
968 screendimage = makescreenimage();
969 if(screendimage == nil)
970 return 0;
971 screenimage = screendimage->image;
972// iprint("initscreenimage %p %p\n", screendimage, screenimage);
943 return 1;973 return 1;
944}974}
945 975
946void976void
947deletescreenimage(void)977deletescreenimage(void)
948{978{
949 qlock(&sdraw.lk);979 dlock();
950 /* RSC: BUG: detach screen */980 if(screenimage){
951 if(screenimage)981 /* will be freed via screendimage; disable */
952 freememimage(screenimage);982 screenimage->clipr = ZR;
953 screenimage = nil;983 screenimage = nil;
954 qunlock(&sdraw.lk);984 }
985 if(screendimage){
986 drawfreedimage(screendimage);
987 screendimage = nil;
988 }
989 dunlock();
990}
991
992void
993resetscreenimage(void)
994{
995 dlock();
996 initscreenimage();
997 dunlock();
955}998}
956 999
957static Chan*1000static Chan*
958drawattach(char *spec)1001drawattach(char *spec)
959{1002{
960 qlock(&sdraw.lk);1003 dlock();
961 if(!initscreenimage()){1004 if(!initscreenimage()){
962 qunlock(&sdraw.lk);1005 dunlock();
963 error("no frame buffer");1006 error("no frame buffer");
964 }1007 }
965 qunlock(&sdraw.lk);1008 dunlock();
966 return devattach('i', spec);1009 return devattach('i', spec);
967}1010}
968 1011
969static Walkqid*1012static Walkqid*
970drawwalk(Chan *c, Chan *nc, char **name, int nname)1013drawwalk(Chan *c, Chan *nc, char **name, int nname)
971{1014{
972 if(screendata.bdata == nil)1015 if(screenimage == nil)
973 error("no frame buffer");1016 error("no frame buffer");
974 return devwalk(c, nc, name, nname, 0, 0, drawgen);1017 return devwalk(c, nc, name, nname, 0, 0, drawgen);
975}1018}
@@ -984,15 +1027,17 @@ static Chan* · 8 unmodified lines
984drawopen(Chan *c, int omode)1027drawopen(Chan *c, int omode)
985{1028{
986 Client *cl;1029 Client *cl;
1030 DName *dn;
1031 DImage *di;
987 1032
988 if(c->qid.type & QTDIR){1033 if(c->qid.type & QTDIR){
989 c = devopen(c, omode, 0, 0, drawgen);1034 c = devopen(c, omode, 0, 0, drawgen);
990 c->iounit = IOUNIT;1035 c->iounit = IOUNIT;
991 }1036 }
992 1037
993 qlock(&sdraw.lk);1038 dlock();
994 if(waserror()){1039 if(waserror()){
995 qunlock(&sdraw.lk);1040 dunlock();
996 nexterror();1041 nexterror();
997 }1042 }
998 1043
@@ -1004,6 +1049,9 @@ drawopen(Chan *c, int omode) · 5 unmodified lines
1004 }1049 }
1005 1050
1006 switch(QID(c->qid)){1051 switch(QID(c->qid)){
1052 case Qwinname:
1053 break;
1054
1007 case Qnew:1055 case Qnew:
1008 break;1056 break;
1009 1057
@@ -1013,9 +1061,22 @@ drawopen(Chan *c, int omode) · 3 unmodified lines
1013 error(Einuse);1061 error(Einuse);
1014 cl->busy = 1;1062 cl->busy = 1;
1015 flushrect = Rect(10000, 10000, -10000, -10000);1063 flushrect = Rect(10000, 10000, -10000, -10000);
1016 drawinstall(cl, 0, screenimage, 0);1064 dn = drawlookupname(strlen(screenname), screenname);
1065 if(dn == 0)
1066 error("draw: cannot happen 2");
1067 if(drawinstall(cl, 0, dn->dimage->image, 0) == 0)
1068 error(Edrawmem);
1069 di = drawlookup(cl, 0, 0);
1070 if(di == 0)
1071 error("draw: cannot happen 1");
1072 di->vers = dn->vers;
1073 di->name = smalloc(strlen(screenname)+1);
1074 strcpy(di->name, screenname);
1075 di->fromname = dn->dimage;
1076 di->fromname->ref++;
1017 incref(&cl->r);1077 incref(&cl->r);
1018 break;1078 break;
1079
1019 case Qcolormap:1080 case Qcolormap:
1020 case Qdata:1081 case Qdata:
1021 case Qrefresh:1082 case Qrefresh:
@@ -1023,7 +1084,7 @@ drawopen(Chan *c, int omode) · 1 unmodified line
1023 incref(&cl->r);1084 incref(&cl->r);
1024 break;1085 break;
1025 }1086 }
1026 qunlock(&sdraw.lk);1087 dunlock();
1027 poperror();1088 poperror();
1028 c->mode = openmode(omode);1089 c->mode = openmode(omode);
1029 c->flag |= COPEN;1090 c->flag |= COPEN;
@@ -1042,9 +1103,9 @@ drawclose(Chan *c) · 12 unmodified lines
1042 1103
1043 if(QID(c->qid) < Qcolormap) /* Qtopdir, Qnew, Q3rd, Q2nd have no client */1104 if(QID(c->qid) < Qcolormap) /* Qtopdir, Qnew, Q3rd, Q2nd have no client */
1044 return;1105 return;
1045 qlock(&sdraw.lk);1106 dlock();
1046 if(waserror()){1107 if(waserror()){
1047 qunlock(&sdraw.lk);1108 dunlock();
1048 nexterror();1109 nexterror();
1049 }1110 }
1050 1111
@@ -1052,7 +1113,7 @@ drawclose(Chan *c) · 1 unmodified line
1052 if(QID(c->qid) == Qctl)1113 if(QID(c->qid) == Qctl)
1053 cl->busy = 0;1114 cl->busy = 0;
1054 if((c->flag&COPEN) && (decref(&cl->r)==0)){1115 if((c->flag&COPEN) && (decref(&cl->r)==0)){
1055 while((r = cl->refresh)){ /* assign = */1116 while(r = cl->refresh){ /* assign = */
1056 cl->refresh = r->next;1117 cl->refresh = r->next;
1057 free(r);1118 free(r);
1058 }1119 }
@@ -1077,7 +1138,7 @@ drawclose(Chan *c) · 18 unmodified lines
1077 drawflush(); /* to erase visible, now dead windows */1138 drawflush(); /* to erase visible, now dead windows */
1078 free(cl);1139 free(cl);
1079 }1140 }
1080 qunlock(&sdraw.lk);1141 dunlock();
1081 poperror();1142 poperror();
1082}1143}
1083 1144
@@ -1096,10 +1157,13 @@ drawread(Chan *c, void *a, long n, vlong off) · 12 unmodified lines
1096 1157
1097 if(c->qid.type & QTDIR)1158 if(c->qid.type & QTDIR)
1098 return devdirread(c, a, n, 0, 0, drawgen);1159 return devdirread(c, a, n, 0, 0, drawgen);
1160 if(QID(c->qid) == Qwinname)
1161 return readstr(off, a, n, screenname);
1162
1099 cl = drawclient(c);1163 cl = drawclient(c);
1100 qlock(&sdraw.lk);1164 dlock();
1101 if(waserror()){1165 if(waserror()){
1102 qunlock(&sdraw.lk);1166 dunlock();
1103 nexterror();1167 nexterror();
1104 }1168 }
1105 switch(QID(c->qid)){1169 switch(QID(c->qid)){
@@ -1118,15 +1182,15 @@ drawread(Chan *c, void *a, long n, vlong off) · 12 unmodified lines
1118 error(Enodrawimage);1182 error(Enodrawimage);
1119 i = di->image;1183 i = di->image;
1120 }1184 }
1121 n = sprint(a, "%11d %11d %11s %11d %11d %11d %11d %11d %11d %11d %11d %11d ",1185 n = sprint(a, "%11d %11d %11s %11d %11d %11d %11d %11d %11d %11d %11d %11d",
1122 cl->clientid, cl->infoid, chantostr(buf, i->chan), (i->flags&Frepl)==Frepl,1186 cl->clientid, cl->infoid, chantostr(buf, i->chan), (i->flags&Frepl)==Frepl,
1123 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,1187 i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
1124 i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, i->clipr.max.y);1188 i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, i->clipr.max.y);
1189 ((char*)a)[n++] = ' ';
1125 cl->infoid = -1;1190 cl->infoid = -1;
1126 break;1191 break;
1127 1192
1128 case Qcolormap:1193 case Qcolormap:
1129 drawactive(1); /* to restore map from backup */
1130 p = malloc(4*12*256+1);1194 p = malloc(4*12*256+1);
1131 if(p == 0)1195 if(p == 0)
1132 error(Enomem);1196 error(Enomem);
@@ -1156,14 +1220,21 @@ drawread(Chan *c, void *a, long n, vlong off) · 23 unmodified lines
1156 for(;;){1220 for(;;){
1157 if(cl->refreshme || cl->refresh)1221 if(cl->refreshme || cl->refresh)
1158 break;1222 break;
1159 qunlock(&sdraw.lk);1223 dunlock();
1160 if(waserror()){1224 if(waserror()){
1161 qlock(&sdraw.lk); /* restore lock for waserror() above */1225 dlock();
1226 nexterror();
1227 }
1228 qlock(&cl->refq);
1229 if(waserror()){
1230 qunlock(&cl->refq);
1162 nexterror();1231 nexterror();
1163 }1232 }
1164 sleep(&cl->refrend, drawrefactive, cl);1233 sleep(&cl->refrend, drawrefactive, cl);
1165 poperror();1234 poperror();
1166 qlock(&sdraw.lk);1235 qunlock(&cl->refq);
1236 poperror();
1237 dlock();
1167 }1238 }
1168 p = a;1239 p = a;
1169 while(cl->refresh && n>=5*4){1240 while(cl->refresh && n>=5*4){
@@ -1180,8 +1251,9 @@ drawread(Chan *c, void *a, long n, vlong off) · 10 unmodified lines
1180 }1251 }
1181 cl->refreshme = 0;1252 cl->refreshme = 0;
1182 n = p-(uchar*)a;1253 n = p-(uchar*)a;
1254 break;
1183 }1255 }
1184 qunlock(&sdraw.lk);1256 dunlock();
1185 poperror();1257 poperror();
1186 return n;1258 return n;
1187}1259}
@@ -1200,21 +1272,21 @@ drawwakeall(void) · 12 unmodified lines
1200}1272}
1201 1273
1202static long1274static long
1203drawwrite(Chan *c, void *a, long n, vlong offset)1275drawwrite(Chan *c, void *a, long n, vlong off)
1204{1276{
1205 char buf[128], *fields[4], *q;1277 char buf[128], *fields[4], *q;
1206 Client *cl;1278 Client *cl;
1207 int i, m, red, green, blue, x;1279 int i, m, red, green, blue, x;
1208 1280
1209 USED(offset);1281 USED(off);
1210 1282
1211 if(c->qid.type & QTDIR)1283 if(c->qid.type & QTDIR)
1212 error(Eisdir);1284 error(Eisdir);
1213 cl = drawclient(c);1285 cl = drawclient(c);
1214 qlock(&sdraw.lk);1286 dlock();
1215 if(waserror()){1287 if(waserror()){
1216 drawwakeall();1288 drawwakeall();
1217 qunlock(&sdraw.lk);1289 dunlock();
1218 nexterror();1290 nexterror();
1219 }1291 }
1220 switch(QID(c->qid)){1292 switch(QID(c->qid)){
@@ -1225,7 +1297,6 @@ drawwrite(Chan *c, void *a, long n, vlong offset) · 4 unmodified lines
1225 break;1297 break;
1226 1298
1227 case Qcolormap:1299 case Qcolormap:
1228 drawactive(1); /* to restore map from backup */
1229 m = n;1300 m = n;
1230 n = 0;1301 n = 0;
1231 while(m > 0){1302 while(m > 0){
@@ -1268,7 +1339,7 @@ drawwrite(Chan *c, void *a, long n, vlong offset) · 36 unmodified lines
1268 default:1339 default:
1269 error(Ebadusefd);1340 error(Ebadusefd);
1270 }1341 }
1271 qunlock(&sdraw.lk);1342 dunlock();
1272 poperror();1343 poperror();
1273 return n;1344 return n;
1274}1345}
@@ -1306,14 +1377,6 @@ printmesg(char *fmt, uchar *a, int plsprnt) · 31 unmodified lines
1306 int s;1377 int s;
1307 1378
1308 if(1|| plsprnt==0){1379 if(1|| plsprnt==0){
1309 SET(s);
1310 SET(q);
1311 SET(p);
1312 USED(fmt);
1313 USED(a);
1314 p = buf;
1315 USED(p);
1316 USED(q);
1317 USED(s);1380 USED(s);
1318 return;1381 return;
1319 }1382 }
@@ -1364,7 +1427,7 @@ drawmesg(Client *client, void *av, int n) · 44 unmodified lines
1364 ulong value, chan;1427 ulong value, chan;
1365 Rectangle r, clipr;1428 Rectangle r, clipr;
1366 Point p, q, *pp, sp;1429 Point p, q, *pp, sp;
1367 Memimage *i, *dst, *src, *mask;1430 Memimage *i, *bg, *dst, *src, *mask;
1368 Memimage *l, **lp;1431 Memimage *l, **lp;
1369 Memscreen *scrn;1432 Memscreen *scrn;
1370 DImage *font, *ll, *di, *ddst, *dsrc;1433 DImage *font, *ll, *di, *ddst, *dsrc;
@@ -1396,7 +1459,7 @@ drawmesg(Client *client, void *av, int n) · 25 unmodified lines
1396 if(n < m)1459 if(n < m)
1397 error(Eshortdraw);1460 error(Eshortdraw);
1398 dstid = BGLONG(a+1);1461 dstid = BGLONG(a+1);
1399 scrnid = BGSHORT(a+5);1462 scrnid = BGLONG(a+5);
1400 refresh = a[9];1463 refresh = a[9];
1401 chan = BGLONG(a+10);1464 chan = BGLONG(a+10);
1402 repl = a[14];1465 repl = a[14];
@@ -1410,7 +1473,7 @@ drawmesg(Client *client, void *av, int n) · 7 unmodified lines
1410 scrn = dscrn->screen;1473 scrn = dscrn->screen;
1411 if(repl || chan!=scrn->image->chan)1474 if(repl || chan!=scrn->image->chan)
1412 error("image parameters incompatible with screen");1475 error("image parameters incompatible with screen");
1413 reffn = 0;1476 reffn = nil;
1414 switch(refresh){1477 switch(refresh){
1415 case Refbackup:1478 case Refbackup:
1416 break;1479 break;
@@ -1493,7 +1556,7 @@ drawmesg(Client *client, void *av, int n) · 76 unmodified lines
1493 if(ddst == nil)1556 if(ddst == nil)
1494 error(Enodrawimage);1557 error(Enodrawimage);
1495 if(ddst->name)1558 if(ddst->name)
1496 error("can't change repl/clipr of shared image");1559 error("cannot change repl/clipr of shared image");
1497 dst = ddst->image;1560 dst = ddst->image;
1498 if(a[5])1561 if(a[5])
1499 dst->flags |= Frepl;1562 dst->flags |= Frepl;
@@ -1553,9 +1616,9 @@ drawmesg(Client *client, void *av, int n) · 53 unmodified lines
1553 oy = BGLONG(a+41);1616 oy = BGLONG(a+41);
1554 op = drawclientop(client);1617 op = drawclientop(client);
1555 /* high bit indicates arc angles are present */1618 /* high bit indicates arc angles are present */
1556 if(ox & (1U<<31)){1619 if(ox & (1<<31)){
1557 if((ox & (1<<30)) == 0)1620 if((ox & (1<<30)) == 0)
1558 ox &= ~(1U<<31);1621 ox &= ~(1<<31);
1559 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);1622 memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
1560 }else1623 }else
1561 memellipse(dst, p, e0, e1, c, src, sp, op);1624 memellipse(dst, p, e0, e1, c, src, sp, op);
@@ -1592,12 +1655,12 @@ drawmesg(Client *client, void *av, int n) · 30 unmodified lines
1592 error(Eshortdraw);1655 error(Eshortdraw);
1593 dstid = BGLONG(a+1);1656 dstid = BGLONG(a+1);
1594 if(dstid == 0)1657 if(dstid == 0)
1595 error("can't use display as font");1658 error("cannot use display as font");
1596 font = drawlookup(client, dstid, 1);1659 font = drawlookup(client, dstid, 1);
1597 if(font == 0)1660 if(font == 0)
1598 error(Enodrawimage);1661 error(Enodrawimage);
1599 if(font->image->layer)1662 if(font->image->layer)
1600 error("can't use window as font");1663 error("cannot use window as font");
1601 ni = BGLONG(a+5);1664 ni = BGLONG(a+5);
1602 if(ni<=0 || ni>4096)1665 if(ni<=0 || ni>4096)
1603 error("bad font size (4096 chars max)");1666 error("bad font size (4096 chars max)");
@@ -1698,7 +1761,7 @@ drawmesg(Client *client, void *av, int n) · 94 unmodified lines
1698 error(Edrawmem);1761 error(Edrawmem);
1699 di = drawlookup(client, dstid, 0);1762 di = drawlookup(client, dstid, 0);
1700 if(di == 0)1763 if(di == 0)
1701 error("draw: can't happen");1764 error("draw: cannot happen");
1702 di->vers = dn->vers;1765 di->vers = dn->vers;
1703 di->name = smalloc(j+1);1766 di->name = smalloc(j+1);
1704 di->fromname = dn->dimage;1767 di->fromname = dn->dimage;
@@ -1799,7 +1862,7 @@ drawmesg(Client *client, void *av, int n) · 94 unmodified lines
1799 if(pp == nil)1862 if(pp == nil)
1800 error(Enomem);1863 error(Enomem);
1801 doflush = 0;1864 doflush = 0;
1802 if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data))1865 if(dstid==0 || (screenimage && dst->layer && dst->layer->screen->image->data == screenimage->data))
1803 doflush = 1; /* simplify test in loop */1866 doflush = 1; /* simplify test in loop */
1804 ox = oy = 0;1867 ox = oy = 0;
1805 esize = 0;1868 esize = 0;
@@ -1901,10 +1964,10 @@ drawmesg(Client *client, void *av, int n) · 95 unmodified lines
1901 clipr = dst->clipr;1964 clipr = dst->clipr;
1902 dst->clipr = r;1965 dst->clipr = r;
1903 op = drawclientop(client);1966 op = drawclientop(client);
1904 l = dst;1967 bg = dst;
1905 if(*a == 'x'){1968 if(*a == 'x'){
1906 /* paint background */1969 /* paint background */
1907 l = drawimage(client, a+47);1970 bg = drawimage(client, a+47);
1908 drawpoint(&q, a+51);1971 drawpoint(&q, a+51);
1909 r.min.x = p.x;1972 r.min.x = p.x;
1910 r.min.y = p.y-font->ascent;1973 r.min.y = p.y-font->ascent;
@@ -1920,7 +1983,7 @@ drawmesg(Client *client, void *av, int n) · 9 unmodified lines
1920 r.max.x += font->fchar[ci].width;1983 r.max.x += font->fchar[ci].width;
1921 u += 2;1984 u += 2;
1922 }1985 }
1923 memdraw(dst, r, l, q, memopaque, ZP, op);1986 memdraw(dst, r, bg, q, memopaque, ZP, op);
1924 u -= 2*ni;1987 u -= 2*ni;
1925 }1988 }
1926 q = p;1989 q = p;
@@ -1930,7 +1993,7 @@ drawmesg(Client *client, void *av, int n) · 3 unmodified lines
1930 dst->clipr = clipr;1993 dst->clipr = clipr;
1931 error(Eindex);1994 error(Eindex);
1932 }1995 }
1933 q = drawchar(dst, l, q, src, &sp, font, ci, op);1996 q = drawchar(dst, bg, q, src, &sp, font, ci, op);
1934 u += 2;1997 u += 2;
1935 }1998 }
1936 dst->clipr = clipr;1999 dst->clipr = clipr;
@@ -1988,7 +2051,7 @@ drawmesg(Client *client, void *av, int n) · 51 unmodified lines
1988 memltofrontn(lp, nw);2051 memltofrontn(lp, nw);
1989 else2052 else
1990 memltorearn(lp, nw);2053 memltorearn(lp, nw);
1991 if(lp[0]->layer->screen->image->data == screenimage->data)2054 if(screenimage && lp[0]->layer->screen->image->data == screenimage->data)
1992 for(j=0; j<nw; j++)2055 for(j=0; j<nw; j++)
1993 addflush(lp[j]->layer->screenr);2056 addflush(lp[j]->layer->screenr);
1994 ll = drawlookup(client, BGLONG(a+1+1+2), 1);2057 ll = drawlookup(client, BGLONG(a+1+1+2), 1);
@@ -2060,7 +2123,6 @@ drawcmap(void) · 65 unmodified lines
2060 int num, den;2123 int num, den;
2061 int i, j;2124 int i, j;
2062 2125
2063 drawactive(1); /* to restore map from backup */
2064 for(r=0,i=0; r!=4; r++)2126 for(r=0,i=0; r!=4; r++)
2065 for(v=0; v!=4; v++,i+=16){2127 for(v=0; v!=4; v++,i+=16){
2066 for(g=0,j=v-r; g!=4; g++)2128 for(g=0,j=v-r; g!=4; g++)
@@ -2083,65 +2145,3 @@ drawcmap(void) · 16 unmodified lines
2083 }2145 }
2084 }2146 }
2085}2147}
2086
2087void
2088drawblankscreen(int blank)
2089{
2090 int i, nc;
2091 ulong *p;
2092
2093 if(blank == sdraw.blanked)
2094 return;
2095 if(!canqlock(&sdraw.lk))
2096 return;
2097 if(!initscreenimage()){
2098 qunlock(&sdraw.lk);
2099 return;
2100 }
2101 p = sdraw.savemap;
2102 nc = screenimage->depth > 8 ? 256 : 1<<screenimage->depth;
2103
2104 /*
2105 * blankscreen uses the hardware to blank the screen
2106 * when possible. to help in cases when it is not possible,
2107 * we set the color map to be all black.
2108 */
2109 if(blank == 0){ /* turn screen on */
2110 for(i=0; i<nc; i++, p+=3)
2111 setcolor(i, p[0], p[1], p[2]);
2112 // blankscreen(0);
2113 }else{ /* turn screen off */
2114 // blankscreen(1);
2115 for(i=0; i<nc; i++, p+=3){
2116 getcolor(i, &p[0], &p[1], &p[2]);
2117 setcolor(i, 0, 0, 0);
2118 }
2119 }
2120 sdraw.blanked = blank;
2121 qunlock(&sdraw.lk);
2122}
2123
2124/*
2125 * record activity on screen, changing blanking as appropriate
2126 */
2127void
2128drawactive(int active)
2129{
2130/*
2131 if(active){
2132 drawblankscreen(0);
2133 sdraw.blanktime = MACHP(0)->ticks;
2134 }else{
2135 if(blanktime && sdraw.blanktime && TK2SEC(MACHP(0)->ticks - sdraw.blanktime)/60 >= blanktime)
2136 drawblankscreen(1);
2137 }
2138*/
2139}
2140
2141int
2142drawidletime(void)
2143{
2144 return 0;
2145/* return TK2SEC(MACHP(0)->ticks - sdraw.blanktime)/60; */
2146}
2147
kern/fns.h+0−4
@@ -77,11 +77,7 @@ void devshutdown(void); · 76 unmodified lines
77int devstat(Chan*, uchar*, int, Dirtab*, int, Devgen*);77int devstat(Chan*, uchar*, int, Dirtab*, int, Devgen*);
78Walkqid* devwalk(Chan*, Chan*, char**, int, Dirtab*, int, Devgen*);78Walkqid* devwalk(Chan*, Chan*, char**, int, Dirtab*, int, Devgen*);
79int devwstat(Chan*, uchar*, int);79int devwstat(Chan*, uchar*, int);
80void drawactive(int);
81void drawcmap(void);80void drawcmap(void);
82int drawcanqlock(void);
83void drawqlock(void);
84void drawqunlock(void);
85void dumpaproc(Proc*);81void dumpaproc(Proc*);
86void dumpqueues(void);82void dumpqueues(void);
87void dumpregs(Ureg*);83void dumpregs(Ureg*);
kern/screen.h+4−7
@@ -48,16 +48,13 @@ void screenload(Rectangle, int, uchar *, Point, int); · 47 unmodified lines
48void getcolor(ulong, ulong*, ulong*, ulong*);48void getcolor(ulong, ulong*, ulong*, ulong*);
49void setcolor(ulong, ulong, ulong, ulong);49void setcolor(ulong, ulong, ulong, ulong);
50 50
51void refreshrect(Rectangle);
52
53void cursorarrow(void);51void cursorarrow(void);
54void setcursor(void);52void setcursor(void);
55void mouseset(Point);53void mouseset(Point);
56void drawflushr(Rectangle);
57void flushmemscreen(Rectangle);54void flushmemscreen(Rectangle);
58uchar *attachscreen(Rectangle*, ulong*, int*, int*, int*);55uchar* attachscreen(Rectangle*, ulong*, int*, int*, int*);
56
57extern QLock drawlock;
58#define ishwimage(i) 1
59 59
60void drawqlock(void);
61void drawqunlock(void);
62int drawcanqlock(void);
63void terminit(void);60void terminit(void);
kern/term.c+7−5
@@ -34,8 +34,10 @@ static void termscreenputs(char*, int); · 33 unmodified lines
34static void34static void
35screenflush(void)35screenflush(void)
36{36{
37 drawflushr(flushr);37 qlock(&drawlock);
38 flushmemscreen(flushr);
38 flushr = Rect(10000, 10000, -10000, -10000);39 flushr = Rect(10000, 10000, -10000, -10000);
40 qunlock(&drawlock);
39}41}
40 42
41static void43static void
@@ -54,7 +56,7 @@ screenwin(void) · 12 unmodified lines
54 char *greet;56 char *greet;
55 Memimage *grey;57 Memimage *grey;
56 58
57 drawqlock();59 qlock(&drawlock);
58 back = memwhite;60 back = memwhite;
59 conscol = memblack;61 conscol = memblack;
60 memfillcolor(gscreen, 0x444488FF);62 memfillcolor(gscreen, 0x444488FF);
@@ -86,7 +88,7 @@ screenwin(void) · 25 unmodified lines
86 curpos = window.min;88 curpos = window.min;
87 window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h;89 window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h;
88 flushmemscreen(gscreen->r);90 flushmemscreen(gscreen->r);
89 drawqunlock();91 qunlock(&drawlock);
90}92}
91 93
92void94void
@@ -184,7 +186,7 @@ termscreenputs(char *s, int n) · 91 unmodified lines
184 char buf[4];186 char buf[4];
185 187
186 lock(&screenlock);188 lock(&screenlock);
187 locked = drawcanqlock();189 locked = canqlock(&drawlock);
188 while(n > 0){190 while(n > 0){
189 i = chartorune(&r, s);191 i = chartorune(&r, s);
190 if(i == 0){192 if(i == 0){
@@ -199,7 +201,7 @@ termscreenputs(char *s, int n) · 8 unmodified lines
199 screenputc(buf);201 screenputc(buf);
200 }202 }
201 if(locked)203 if(locked)
202 drawqunlock();204 qunlock(&drawlock);
203 screenflush();205 screenflush();
204 unlock(&screenlock);206 unlock(&screenlock);
205}207}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t