OLD | NEW |
1 /* | 1 /* |
2 * /dev/draw simulator -- handles the messages prepared by the draw library. | 2 * /dev/draw simulator -- handles the messages prepared by the draw library. |
3 * Doesn't simulate the file system part, just the messages. | 3 * Doesn't simulate the file system part, just the messages. |
4 */ | 4 */ |
5 | 5 |
6 #include <u.h> | 6 #include <u.h> |
7 #include <libc.h> | 7 #include <libc.h> |
8 #include <draw.h> | 8 #include <draw.h> |
9 #include <memdraw.h> | 9 #include <memdraw.h> |
10 #include <memlayer.h> | 10 #include <memlayer.h> |
11 #include "devdraw.h" | 11 #include "devdraw.h" |
12 | 12 |
13 extern void _flushmemscreen(Rectangle); | 13 extern void _flushmemscreen(Rectangle); |
| 14 int displaydpi = 100; |
14 | 15 |
15 #define NHASH (1<<5) | 16 #define NHASH (1<<5) |
16 #define HASHMASK (NHASH-1) | 17 #define HASHMASK (NHASH-1) |
17 | 18 |
18 typedef struct Client Client; | 19 typedef struct Client Client; |
19 typedef struct Draw Draw; | 20 typedef struct Draw Draw; |
20 typedef struct DImage DImage; | 21 typedef struct DImage DImage; |
21 typedef struct DScreen DScreen; | 22 typedef struct DScreen DScreen; |
22 typedef struct CScreen CScreen; | 23 typedef struct CScreen CScreen; |
23 typedef struct FChar FChar; | 24 typedef struct FChar FChar; |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 int c, ci, doflush, dstid, e0, e1, esize, j, m; | 770 int c, ci, doflush, dstid, e0, e1, esize, j, m; |
770 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;· | 771 int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;· |
771 uchar *a, refresh, *u; | 772 uchar *a, refresh, *u; |
772 u32int chan, value; | 773 u32int chan, value; |
773 Client *client; | 774 Client *client; |
774 CScreen *cs; | 775 CScreen *cs; |
775 DImage *di, *ddst, *dsrc, *font, *ll; | 776 DImage *di, *ddst, *dsrc, *font, *ll; |
776 DName *dn; | 777 DName *dn; |
777 DScreen *dscrn; | 778 DScreen *dscrn; |
778 FChar *fc; | 779 FChar *fc; |
| 780 Fmt fmt; |
779 Memimage *dst, *i, *l, **lp, *mask, *src; | 781 Memimage *dst, *i, *l, **lp, *mask, *src; |
780 Memscreen *scrn; | 782 Memscreen *scrn; |
781 Point p, *pp, q, sp; | 783 Point p, *pp, q, sp; |
782 Rectangle clipr, r; | 784 Rectangle clipr, r; |
783 Refreshfn reffn; | 785 Refreshfn reffn; |
784 Refx *refx; | 786 Refx *refx; |
785 | 787 |
786 qlock(&sdraw.lk); | 788 qlock(&sdraw.lk); |
787 a = v; | 789 a = v; |
788 m = 0; | 790 m = 0; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 i->r.min.x, i->r.min.y, i->r.max.x, i->r
.max.y, | 1078 i->r.min.x, i->r.min.y, i->r.max.x, i->r
.max.y, |
1077 i->clipr.min.x, i->clipr.min.y,· | 1079 i->clipr.min.x, i->clipr.min.y,· |
1078 i->clipr.max.x, i->clipr.max.y); | 1080 i->clipr.max.x, i->clipr.max.y); |
1079 free(client->readdata); | 1081 free(client->readdata); |
1080 client->readdata = malloc(ni); | 1082 client->readdata = malloc(ni); |
1081 if(client->readdata == nil) | 1083 if(client->readdata == nil) |
1082 goto Enomem; | 1084 goto Enomem; |
1083 memmove(client->readdata, ibuf, ni); | 1085 memmove(client->readdata, ibuf, ni); |
1084 client->nreaddata = ni; | 1086 client->nreaddata = ni; |
1085 client->infoid = -1; | 1087 client->infoid = -1; |
1086 » » » continue;»······ | 1088 » » » continue; |
| 1089 » »······· |
| 1090 » » /* query: 'Q' n[1] queryspec[n] */ |
| 1091 » » case 'q': |
| 1092 » » » if(n < 2) |
| 1093 » » » » goto Eshortdraw; |
| 1094 » » » m = 1+1+a[1]; |
| 1095 » » » if(n < m) |
| 1096 » » » » goto Eshortdraw; |
| 1097 » » » fmtstrinit(&fmt); |
| 1098 » » » for(c=0; c<a[1]; c++) { |
| 1099 » » » » switch(a[2+c]) { |
| 1100 » » » » default: |
| 1101 » » » » » err = "unknown query"; |
| 1102 » » » » » goto error; |
| 1103 » » » » case 'd':» /* dpi */ |
| 1104 » » » » » fmtprint(&fmt, "%11d ", displaydpi); |
| 1105 » » » » » break; |
| 1106 » » » » } |
| 1107 » » » } |
| 1108 » » » client->readdata = (uchar*)fmtstrflush(&fmt); |
| 1109 » » » if(client->readdata == nil) |
| 1110 » » » » goto Enomem; |
| 1111 » » » client->nreaddata = strlen((char*)client->readdata); |
| 1112 » » » continue; |
1087 | 1113 |
1088 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4]
left[1] width[1] */ | 1114 /* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4]
left[1] width[1] */ |
1089 case 'l': | 1115 case 'l': |
1090 m = 1+4+4+2+4*4+2*4+1+1; | 1116 m = 1+4+4+2+4*4+2*4+1+1; |
1091 if(n < m) | 1117 if(n < m) |
1092 goto Eshortdraw; | 1118 goto Eshortdraw; |
1093 font = drawlookup(client, BGLONG(a+1), 1); | 1119 font = drawlookup(client, BGLONG(a+1), 1); |
1094 if(font == 0) | 1120 if(font == 0) |
1095 goto Enodrawimage; | 1121 goto Enodrawimage; |
1096 if(font->nfchar == 0) | 1122 if(font->nfchar == 0) |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 err = "bad argument in draw message"; | 1624 err = "bad argument in draw message"; |
1599 goto error; | 1625 goto error; |
1600 | 1626 |
1601 error: | 1627 error: |
1602 werrstr("%s", err); | 1628 werrstr("%s", err); |
1603 qunlock(&sdraw.lk); | 1629 qunlock(&sdraw.lk); |
1604 return -1; | 1630 return -1; |
1605 } | 1631 } |
1606 | 1632 |
1607 | 1633 |
OLD | NEW |