This source file includes following definitions.
- rasops1_init
- rasops1_putchar
- rasops1_putchar8
- rasops1_putchar16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/time.h>
43 #include <machine/endian.h>
44
45 #include <dev/wscons/wsdisplayvar.h>
46 #include <dev/wscons/wsconsio.h>
47 #include <dev/rasops/rasops.h>
48 #include <dev/rasops/rasops_masks.h>
49
50 void rasops1_copycols(void *, int, int, int, int);
51 void rasops1_erasecols(void *, int, int, int, long);
52 void rasops1_do_cursor(struct rasops_info *);
53 void rasops1_putchar(void *, int, int col, u_int, long);
54 #ifndef RASOPS_SMALL
55 void rasops1_putchar8(void *, int, int col, u_int, long);
56 void rasops1_putchar16(void *, int, int col, u_int, long);
57 #endif
58
59
60
61
62 void
63 rasops1_init(ri)
64 struct rasops_info *ri;
65 {
66 rasops_masks_init();
67
68 switch (ri->ri_font->fontwidth) {
69 #ifndef RASOPS_SMALL
70 case 8:
71 ri->ri_ops.putchar = rasops1_putchar8;
72 break;
73 case 16:
74 ri->ri_ops.putchar = rasops1_putchar16;
75 break;
76 #endif
77 default:
78 ri->ri_ops.putchar = rasops1_putchar;
79 break;
80 }
81
82 if ((ri->ri_font->fontwidth & 7) != 0) {
83 ri->ri_ops.erasecols = rasops1_erasecols;
84 ri->ri_ops.copycols = rasops1_copycols;
85 ri->ri_do_cursor = rasops1_do_cursor;
86 }
87 }
88
89
90
91
92 void
93 rasops1_putchar(cookie, row, col, uc, attr)
94 void *cookie;
95 int row, col;
96 u_int uc;
97 long attr;
98 {
99 u_int fs, rs, fb, bg, fg, lmask, rmask;
100 u_int32_t height, width;
101 struct rasops_info *ri;
102 int32_t *rp;
103 u_char *fr;
104
105 ri = (struct rasops_info *)cookie;
106
107 #ifdef RASOPS_CLIPPING
108
109 if ((unsigned)row >= (unsigned)ri->ri_rows)
110 return;
111
112 if ((unsigned)col >= (unsigned)ri->ri_cols)
113 return;
114 #endif
115
116 col *= ri->ri_font->fontwidth;
117 rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
118 height = ri->ri_font->fontheight;
119 width = ri->ri_font->fontwidth;
120 col = col & 31;
121 rs = ri->ri_stride;
122
123 bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
124 fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
125
126
127 if (fg == bg || uc == ' ') {
128 uc = (u_int)-1;
129 fr = 0;
130 fs = 0;
131 } else {
132 uc -= ri->ri_font->firstchar;
133 fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
134 fs = ri->ri_font->stride;
135 }
136
137
138 if ((col + width) <= 32) {
139 rmask = rasops_pmask[col][width];
140 lmask = ~rmask;
141
142 if (uc == (u_int)-1) {
143 bg &= rmask;
144
145 while (height--) {
146 *rp = (*rp & lmask) | bg;
147 DELTA(rp, rs, int32_t *);
148 }
149 } else {
150
151 if (bg) {
152 while (height--) {
153 fb = ~(fr[3] | (fr[2] << 8) |
154 (fr[1] << 16) | (fr[0] << 24));
155 *rp = (*rp & lmask)
156 | (MBE(fb >> col) & rmask);
157
158 fr += fs;
159 DELTA(rp, rs, int32_t *);
160 }
161 } else {
162 while (height--) {
163 fb = (fr[3] | (fr[2] << 8) |
164 (fr[1] << 16) | (fr[0] << 24));
165 *rp = (*rp & lmask)
166 | (MBE(fb >> col) & rmask);
167
168 fr += fs;
169 DELTA(rp, rs, int32_t *);
170 }
171 }
172 }
173
174
175 if ((attr & 1) != 0) {
176 DELTA(rp, -(ri->ri_stride << 1), int32_t *);
177 *rp = (*rp & lmask) | (fg & rmask);
178 }
179 } else {
180 lmask = ~rasops_lmask[col];
181 rmask = ~rasops_rmask[(col + width) & 31];
182
183 if (uc == (u_int)-1) {
184 width = bg & ~rmask;
185 bg = bg & ~lmask;
186
187 while (height--) {
188 rp[0] = (rp[0] & lmask) | bg;
189 rp[1] = (rp[1] & rmask) | width;
190 DELTA(rp, rs, int32_t *);
191 }
192 } else {
193 width = 32 - col;
194
195
196 if (bg) {
197 while (height--) {
198 fb = ~(fr[3] | (fr[2] << 8) |
199 (fr[1] << 16) | (fr[0] << 24));
200
201 rp[0] = (rp[0] & lmask)
202 | MBE((u_int)fb >> col);
203
204 rp[1] = (rp[1] & rmask)
205 | (MBE((u_int)fb << width) & ~rmask);
206
207 fr += fs;
208 DELTA(rp, rs, int32_t *);
209 }
210 } else {
211 while (height--) {
212 fb = (fr[3] | (fr[2] << 8) |
213 (fr[1] << 16) | (fr[0] << 24));
214
215 rp[0] = (rp[0] & lmask)
216 | MBE(fb >> col);
217
218 rp[1] = (rp[1] & rmask)
219 | (MBE(fb << width) & ~rmask);
220
221 fr += fs;
222 DELTA(rp, rs, int32_t *);
223 }
224 }
225 }
226
227
228 if ((attr & 1) != 0) {
229 DELTA(rp, -(ri->ri_stride << 1), int32_t *);
230 rp[0] = (rp[0] & lmask) | (fg & ~lmask);
231 rp[1] = (rp[1] & rmask) | (fg & ~rmask);
232 }
233 }
234 }
235
236 #ifndef RASOPS_SMALL
237
238
239
240 void
241 rasops1_putchar8(cookie, row, col, uc, attr)
242 void *cookie;
243 int row, col;
244 u_int uc;
245 long attr;
246 {
247 int height, fs, rs, bg, fg;
248 struct rasops_info *ri;
249 u_char *fr, *rp;
250
251 ri = (struct rasops_info *)cookie;
252
253 #ifdef RASOPS_CLIPPING
254
255 if ((unsigned)row >= (unsigned)ri->ri_rows)
256 return;
257
258 if ((unsigned)col >= (unsigned)ri->ri_cols)
259 return;
260 #endif
261
262 rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
263 height = ri->ri_font->fontheight;
264 rs = ri->ri_stride;
265
266 bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
267 fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
268
269
270 if (fg == bg || uc == ' ') {
271 while (height--) {
272 *rp = bg;
273 rp += rs;
274 }
275 } else {
276 uc -= ri->ri_font->firstchar;
277 fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
278 fs = ri->ri_font->stride;
279
280
281 if (bg) {
282 while (height--) {
283 *rp = ~*fr;
284 fr += fs;
285 rp += rs;
286 }
287 } else {
288 while (height--) {
289 *rp = *fr;
290 fr += fs;
291 rp += rs;
292 }
293 }
294
295 }
296
297
298 if ((attr & 1) != 0)
299 rp[-(ri->ri_stride << 1)] = fg;
300 }
301
302
303
304
305 void
306 rasops1_putchar16(cookie, row, col, uc, attr)
307 void *cookie;
308 int row, col;
309 u_int uc;
310 long attr;
311 {
312 int height, fs, rs, bg, fg;
313 struct rasops_info *ri;
314 u_char *fr, *rp;
315
316 ri = (struct rasops_info *)cookie;
317
318 #ifdef RASOPS_CLIPPING
319
320 if ((unsigned)row >= (unsigned)ri->ri_rows)
321 return;
322
323 if ((unsigned)col >= (unsigned)ri->ri_cols)
324 return;
325 #endif
326
327 rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
328 height = ri->ri_font->fontheight;
329 rs = ri->ri_stride;
330
331 bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
332 fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
333
334
335 if (fg == bg || uc == ' ') {
336 while (height--) {
337 *(int16_t *)rp = bg;
338 rp += rs;
339 }
340 } else {
341 uc -= ri->ri_font->firstchar;
342 fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
343 fs = ri->ri_font->stride;
344
345
346 if (bg) {
347 while (height--) {
348 rp[0] = ~fr[0];
349 rp[1] = ~fr[1];
350 fr += fs;
351 rp += rs;
352 }
353 } else {
354 while (height--) {
355 rp[0] = fr[0];
356 rp[1] = fr[1];
357 fr += fs;
358 rp += rs;
359 }
360 }
361 }
362
363
364 if ((attr & 1) != 0)
365 *(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
366 }
367 #endif
368
369
370
371
372 #define NAME(ident) rasops1_##ident
373 #define PIXEL_SHIFT 0
374
375 #include <dev/rasops/rasops_bitops.h>