Home | History | Annotate | Download | only in rasops

Lines Matching refs:ri

66 	struct rasops_info *ri;
241 rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
244 memset(&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
247 if (ri->ri_font == NULL) {
263 if ((ri->ri_flg & RI_ENABLE_ALPHA) != 0)
265 if ((ri->ri_flg & RI_PREFER_ALPHA) != 0)
267 if ((ri->ri_flg & RI_PREFER_WIDEFONT) != 0)
270 ri->ri_width / wantcols,
290 if (ri->ri_flg & RI_ROTATE_MASK) {
291 if (ri->ri_flg & RI_ROTATE_CW)
293 else if (ri->ri_flg & RI_ROTATE_CCW)
298 if (wsfont_lock(cookie, &ri->ri_font)) {
303 ri->ri_wsfcookie = cookie;
308 if ((uintptr_t)ri->ri_bits & 3) {
314 if (ri->ri_stride & 3) {
320 if (rasops_reconfig(ri, wantrows, wantcols))
323 rasops_init_devcmap(ri);
331 rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols)
344 if (ri->ri_optfont.data != NULL) {
345 kmem_free(ri->ri_optfont.data, ri->ri_optfont.stride *
346 ri->ri_optfont.fontheight * ri->ri_optfont.numchars);
347 ri->ri_optfont.data = NULL;
351 ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
352 ri->ri_optfont.numchars = 16;
353 ri->ri_optfont.fontwidth = ri->ri_font->fontwidth;
354 ri->ri_optfont.fontheight = ri->ri_font->fontheight;
355 ri->ri_optfont.stride = ri->ri_font->stride;
356 len = ri->ri_optfont.fontheight * ri->ri_optfont.stride *
357 ri->ri_optfont.numchars;
359 if (ri->ri_font->fontwidth > 32 || ri->ri_font->fontwidth < 4) {
365 if ((ri->ri_flg & RI_NO_AUTO) == 0) {
366 ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP);
367 if (FONT_IS_ALPHA(&ri->ri_optfont))
368 rasops_make_box_chars_alpha(ri);
370 switch (ri->ri_optfont.stride) {
372 rasops_make_box_chars_8(ri);
375 rasops_make_box_chars_16(ri);
378 rasops_make_box_chars_32(ri);
381 kmem_free(ri->ri_optfont.data, len);
382 ri->ri_optfont.data = NULL;
390 memset(&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
393 bpp = (ri->ri_depth == 15 ? 16 : ri->ri_depth);
395 if ((ri->ri_flg & RI_CFGDONE) != 0) {
396 ri->ri_bits = ri->ri_origbits;
397 ri->ri_hwbits = ri->ri_hworigbits;
408 ri->ri_emuwidth = ri->ri_font->fontwidth * wantcols;
409 ri->ri_emuheight = ri->ri_font->fontheight * wantrows;
411 if (ri->ri_emuwidth > ri->ri_width)
412 ri->ri_emuwidth = ri->ri_width;
414 if (ri->ri_emuheight > ri->ri_height)
415 ri->ri_emuheight = ri->ri_height;
418 while ((ri->ri_emuwidth * bpp & 31) != 0)
419 ri->ri_emuwidth--;
422 if (ri->ri_flg & (RI_ROTATE_CW|RI_ROTATE_CCW)) {
423 ri->ri_rows = ri->ri_emuwidth / ri->ri_font->fontwidth;
424 ri->ri_cols = ri->ri_emuheight / ri->ri_font->fontheight;
428 ri->ri_cols = ri->ri_emuwidth / ri->ri_font->fontwidth;
429 ri->ri_rows = ri->ri_emuheight / ri->ri_font->fontheight;
431 ri->ri_emustride = ri->ri_emuwidth * bpp >> 3;
432 ri->ri_ccol = 0;
433 ri->ri_crow = 0;
434 ri->ri_pelbytes = bpp >> 3;
436 ri->ri_xscale = (ri->ri_font->fontwidth * bpp) >> 3;
437 ri->ri_yscale = ri->ri_font->fontheight * ri->ri_stride;
438 ri->ri_fontscale = ri->ri_font->fontheight * ri->ri_font->stride;
440 ri->ri_origbits = ri->ri_bits;
441 ri->ri_hworigbits = ri->ri_hwbits;
444 if ((ri->ri_flg & RI_CLEAR) != 0) {
445 rasops_memset32(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
446 if (ri->ri_hwbits)
447 rasops_memset32(ri->ri_hwbits, 0,
448 ri->ri_stride * ri->ri_height);
452 if ((ri->ri_flg & RI_CENTER) != 0) {
455 xoff = ((ri->ri_width * bpp >> 3) - ri->ri_emustride) >> 1;
456 if (ri->ri_depth != 24) {
468 yoff = ((ri->ri_height - ri->ri_emuheight) >> 1) *
469 ri->ri_stride;
471 ri->ri_bits += xoff;
472 ri->ri_bits += yoff;
473 if (ri->ri_hwbits != NULL) {
474 ri->ri_hwbits += xoff;
475 ri->ri_hwbits += yoff;
478 ri->ri_yorigin = (int)(ri->ri_bits - ri->ri_origbits) /
479 ri->ri_stride;
480 ri->ri_xorigin = (((int)(ri->ri_bits - ri->ri_origbits) %
481 ri->ri_stride) * 8 / bpp);
483 ri->ri_xorigin = ri->ri_yorigin = 0;
486 height = ri->ri_font->fontheight;
487 ri->ri_ul.off = rounddown(height, 16) / 16; /* offset from bottom */
488 ri->ri_ul.height = roundup(height, 16) / 16; /* height */
494 ri->ri_ops.mapchar = rasops_mapchar;
495 ri->ri_ops.copyrows = rasops_copyrows;
496 ri->ri_ops.copycols = rasops_copycols;
497 ri->ri_ops.erasecols = rasops_erasecols;
498 ri->ri_ops.eraserows = rasops_eraserows;
499 ri->ri_ops.cursor = rasops_cursor;
500 ri->ri_do_cursor = rasops_do_cursor;
502 ri->ri_caps &= ~(WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
505 if ((ri->ri_flg & RI_FORCEMONO) != 0 ||
507 ri->ri_depth < 8
509 ri->ri_depth < 4
512 ri->ri_ops.allocattr = rasops_allocattr_mono;
513 ri->ri_caps |= WSSCREEN_UNDERLINE | WSSCREEN_REVERSE;
515 ri->ri_ops.allocattr = rasops_allocattr_color;
516 ri->ri_caps |= WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
520 switch (ri->ri_depth) {
523 rasops1_init(ri);
528 rasops2_init(ri);
533 rasops4_init(ri);
538 rasops8_init(ri);
544 rasops15_init(ri);
549 rasops24_init(ri);
554 rasops32_init(ri);
558 ri->ri_flg &= ~RI_CFGDONE;
565 if (ri->ri_flg & RI_ROTATE_MASK) {
566 if (ri->ri_flg & RI_ROTATE_CW) {
567 ri->ri_real_ops = ri->ri_ops;
568 ri->ri_ops.copycols = rasops_copycols_rotated_cw;
569 ri->ri_ops.copyrows = rasops_copyrows_rotated_cw;
570 ri->ri_ops.erasecols = rasops_erasecols_rotated_cw;
571 ri->ri_ops.eraserows = rasops_eraserows_rotated_cw;
572 ri->ri_ops.putchar = rasops_putchar_rotated_cw;
573 } else if (ri->ri_flg & RI_ROTATE_CCW) {
574 ri->ri_real_ops = ri->ri_ops;
575 ri->ri_ops.copycols = rasops_copycols_rotated_ccw;
576 ri->ri_ops.copyrows = rasops_copyrows_rotated_ccw;
577 ri->ri_ops.erasecols = rasops_erasecols_rotated_ccw;
578 ri->ri_ops.eraserows = rasops_eraserows_rotated_ccw;
579 ri->ri_ops.putchar = rasops_putchar_rotated_ccw;
584 ri->ri_flg |= RI_CFGDONE;
595 struct rasops_info *ri
597 KASSERT(ri->ri_font != NULL);
599 int glyph = wsfont_map_unichar(ri->ri_font, c);
600 if (glyph < 0 || !CHAR_IN_FONT(glyph, PICK_FONT(ri, glyph))) {
693 struct rasops_info *ri = (struct rasops_info *)cookie;
708 if (src + num > ri->ri_rows)
709 num = ri->ri_rows - src;
716 if (dst + num > ri->ri_rows)
717 num = ri->ri_rows - dst;
723 src *= ri->ri_yscale;
724 dst *= ri->ri_yscale;
725 num *= ri->ri_font->fontheight;
726 stride = ri->ri_stride;
735 sp = ri->ri_bits + src;
736 dp = ri->ri_bits + dst;
737 if (ri->ri_hwbits)
738 hp = ri->ri_hwbits + dst;
741 memcpy(dp, sp, ri->ri_emustride);
742 if (ri->ri_hwbits) {
743 memcpy(hp, dp, ri->ri_emustride);
760 struct rasops_info *ri = (struct rasops_info *)cookie;
771 if ((unsigned)row >= (unsigned)ri->ri_rows)
779 if (src + num > ri->ri_cols)
780 num = ri->ri_cols - src;
787 if (dst + num > ri->ri_cols)
788 num = ri->ri_cols - dst;
794 height = ri->ri_font->fontheight;
795 row *= ri->ri_yscale;
796 num *= ri->ri_xscale;
798 sp = ri->ri_bits + row + src * ri->ri_xscale;
799 dp = ri->ri_bits + row + dst * ri->ri_xscale;
800 if (ri->ri_hwbits)
801 hp = ri->ri_hwbits + row + dst * ri->ri_xscale;
805 if (ri->ri_hwbits) {
807 hp += ri->ri_stride;
809 sp += ri->ri_stride;
810 dp += ri->ri_stride;
820 struct rasops_info *ri = (struct rasops_info *)cookie;
823 if ((ri->ri_flg & RI_CURSOR) != 0)
825 if ((ri->ri_flg & RI_CURSORCLIP) == 0)
827 ri->ri_do_cursor(ri);
830 ri->ri_crow = row;
831 ri->ri_ccol = col;
834 ri->ri_flg &= ~RI_CURSORCLIP;
835 if (row < 0 || row >= ri->ri_rows)
836 ri->ri_flg |= RI_CURSORCLIP;
837 else if (col < 0 || col >= ri->ri_cols)
838 ri->ri_flg |= RI_CURSORCLIP;
842 ri->ri_flg |= RI_CURSOR;
844 if ((ri->ri_flg & RI_CURSORCLIP) == 0)
846 ri->ri_do_cursor(ri);
848 ri->ri_flg &= ~RI_CURSOR;
855 rasops_init_devcmap(struct rasops_info *ri)
861 switch (ri->ri_depth) {
863 ri->ri_devcmap[0] = 0;
865 ri->ri_devcmap[i] = -1;
870 ri->ri_devcmap[i] = 0xaaaaaaaa;
872 ri->ri_devcmap[0] = 0;
873 ri->ri_devcmap[8] = 0x55555555;
874 ri->ri_devcmap[15] = -1;
884 ri->ri_devcmap[i] =
891 if ((ri->ri_flg & RI_8BIT_IS_RGB) == 0) {
898 ri->ri_devcmap[i] =
908 if (ri->ri_rnum <= 8)
909 c = (uint32_t)(*p >> (8 - ri->ri_rnum)) << ri->ri_rpos;
911 c = (uint32_t)(*p << (ri->ri_rnum - 8)) << ri->ri_rpos;
914 if (ri->ri_gnum <= 8)
915 c |= (uint32_t)(*p >> (8 - ri->ri_gnum)) << ri->ri_gpos;
917 c |= (uint32_t)(*p << (ri->ri_gnum - 8)) << ri->ri_gpos;
920 if (ri->ri_bnum <= 8)
921 c |= (uint32_t)(*p >> (8 - ri->ri_bnum)) << ri->ri_bpos;
923 c |= (uint32_t)(*p << (ri->ri_bnum - 8)) << ri->ri_bpos;
930 switch (ri->ri_depth) {
937 if ((ri->ri_flg & RI_BSWAP) != 0)
943 if ((ri->ri_flg & RI_BSWAP) == 0)
945 if ((ri->ri_flg & RI_BSWAP) != 0)
962 if ((ri->ri_flg & RI_BSWAP) != 0)
967 ri->ri_devcmap[i] = c;
990 struct rasops_info *ri = (struct rasops_info *)cookie;
1002 if (row + num > ri->ri_rows)
1003 num = ri->ri_rows - row;
1015 if (num == ri->ri_rows && (ri->ri_flg & RI_FULLCLEAR) != 0) {
1016 bytes = ri->ri_stride;
1017 num = ri->ri_height;
1018 rp = (uint32_t *)ri->ri_origbits;
1019 if (ri->ri_hwbits)
1020 hp = (uint32_t *)ri->ri_hworigbits;
1022 bytes = ri->ri_emustride;
1023 num *= ri->ri_font->fontheight;
1024 rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale);
1025 if (ri->ri_hwbits)
1026 hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale);
1029 bg = ATTR_BG(ri, attr);
1033 if (ri->ri_hwbits) {
1035 DELTA(hp, ri->ri_stride, uint32_t *);
1037 DELTA(rp, ri->ri_stride, uint32_t *);
1046 rasops_do_cursor(struct rasops_info *ri)
1055 if (ri->ri_flg & RI_ROTATE_MASK) {
1056 if (ri->ri_flg & RI_ROTATE_CW) {
1058 row = ri->ri_ccol;
1059 col = ri->ri_rows - ri->ri_crow - 1;
1060 } else if (ri->ri_flg & RI_ROTATE_CCW) {
1062 row = ri->ri_cols - ri->ri_ccol - 1;
1063 col = ri->ri_crow;
1065 row = ri->ri_crow;
1066 col = ri->ri_ccol;
1071 row = ri->ri_crow;
1072 col = ri->ri_ccol;
1075 height = ri->ri_font->fontheight;
1077 rp = ri->ri_bits + FBOFFSET(ri, row, col);
1078 if (ri->ri_hwbits)
1079 hp = ri->ri_hwbits + FBOFFSET(ri, row, col);
1087 if (ri->ri_xscale == 1) {
1091 if (ri->ri_hwbits) {
1093 hp += ri->ri_stride;
1095 rp += ri->ri_stride;
1107 slop2 = (ri->ri_xscale - slop1) & 3;
1108 full = (ri->ri_xscale - slop1 /* - slop2 */) >> 2;
1132 if (ri->ri_hwbits) {
1135 hp += ri->ri_stride;
1137 rp += ri->ri_stride;
1147 struct rasops_info *ri = (struct rasops_info *)cookie;
1154 if ((unsigned)row >= (unsigned)ri->ri_rows)
1162 if (col + num > ri->ri_cols)
1163 num = ri->ri_cols - col;
1169 height = ri->ri_font->fontheight;
1170 num *= ri->ri_xscale;
1172 rp = (uint32_t *)(ri->ri_bits + FBOFFSET(ri, row, col));
1173 if (ri->ri_hwbits)
1174 hp = (uint32_t *)(ri->ri_hwbits + FBOFFSET(ri, row, col));
1176 bg = ATTR_BG(ri, attr);
1180 if (ri->ri_hwbits) {
1182 DELTA(hp, ri->ri_stride, uint32_t *);
1184 DELTA(rp, ri->ri_stride, uint32_t *);
1189 rasops_make_box_chars_16(struct rasops_info *ri)
1193 uint16_t *data = (uint16_t *)ri->ri_optfont.data;
1195 vert_mask = 0xc000U >> ((ri->ri_font->fontwidth >> 1) - 1);
1196 hmask_left = 0xff00U << (8 - (ri->ri_font->fontwidth >> 1));
1197 hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
1203 mid = (ri->ri_font->fontheight + 1) >> 1;
1207 data += ri->ri_font->fontheight;
1215 for (i = mid; i < ri->ri_font->fontheight; i++)
1220 i = ri->ri_font->fontheight >> 1;
1233 rasops_make_box_chars_8(struct rasops_info *ri)
1237 uint8_t *data = (uint8_t *)ri->ri_optfont.data;
1239 vert_mask = 0xc0U >> ((ri->ri_font->fontwidth >> 1) - 1);
1240 hmask_left = 0xf0U << (4 - (ri->ri_font->fontwidth >> 1));
1241 hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
1243 mid = (ri->ri_font->fontheight + 1) >> 1;
1247 data += ri->ri_font->fontheight;
1255 for (i = mid; i < ri->ri_font->fontheight; i++)
1260 i = ri->ri_font->fontheight >> 1;
1273 rasops_make_box_chars_32(struct rasops_info *ri)
1277 uint32_t *data = (uint32_t *)ri->ri_optfont.data;
1279 vert_mask = 0xc0000000U >> ((ri->ri_font->fontwidth >> 1) - 1);
1280 hmask_left = 0xffff0000U << (16 - (ri->ri_font->fontwidth >> 1));
1281 hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
1287 mid = (ri->ri_font->fontheight + 1) >> 1;
1291 data += ri->ri_font->fontheight;
1299 for (i = mid; i < ri->ri_font->fontheight; i++)
1304 i = ri->ri_font->fontheight >> 1;
1317 rasops_make_box_chars_alpha(struct rasops_info *ri)
1320 uint8_t *data = (uint8_t *)ri->ri_optfont.data;
1323 he = ri->ri_font->fontheight;
1324 wi = ri->ri_font->fontwidth;
1331 data += ri->ri_fontscale;
1374 rasops_get_cmap(struct rasops_info *ri, uint8_t *palette, size_t bytes)
1377 if ((ri->ri_depth == 8) && ((ri->ri_flg & RI_8BIT_IS_RGB) != 0)) {
1454 struct rasops_info *ri = (struct rasops_info *)cookie;
1460 r_srccol = ri->ri_rows - srcrow - 1;
1461 r_dstcol = ri->ri_rows - dstrow - 1;
1463 r_srcrow *= ri->ri_yscale;
1464 r_dstrow *= ri->ri_yscale;
1465 height = ri->ri_font->fontheight;
1467 sp = ri->ri_bits + r_srcrow + r_srccol * ri->ri_xscale;
1468 dp = ri->ri_bits + r_dstrow + r_dstcol * ri->ri_xscale;
1471 memmove(dp, sp, ri->ri_xscale);
1472 dp += ri->ri_stride;
1473 sp += ri->ri_stride;
1480 struct rasops_info *ri = (struct rasops_info *)cookie;
1484 if (__predict_false((unsigned int)row > ri->ri_rows ||
1485 (unsigned int)col > ri->ri_cols))
1489 if (ri->ri_rows - row - 1 < 0)
1493 ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc,
1501 height = ri->ri_font->fontheight;
1503 rp = (uint16_t *)(ri->ri_bits + col * ri->ri_yscale +
1504 (ri->ri_rows - row - 1) * ri->ri_xscale);
1506 fg = (uint16_t)ATTR_FG(ri, attr);
1510 DELTA(rp, ri->ri_stride, uint16_t *);
1518 struct rasops_info *ri = (struct rasops_info *)cookie;
1522 ri->ri_ops.putchar(cookie, row, i, ' ', attr);
1529 struct rasops_info *ri = (struct rasops_info *)cookie;
1534 for (col = 0; col < ri->ri_cols; col++)
1539 for (col = 0; col < ri->ri_cols; col++)
1562 struct rasops_info *ri = (struct rasops_info *)cookie;
1566 for (col = 0; col < ri->ri_cols; col++)
1567 ri->ri_ops.putchar(cookie, rn, col, ' ', attr);
1578 struct rasops_info *ri = (struct rasops_info *)cookie;
1582 r_srcrow = ri->ri_cols - srccol - 1;
1583 r_dstrow = ri->ri_cols - dstcol - 1;
1587 r_srcrow *= ri->ri_yscale;
1588 r_dstrow *= ri->ri_yscale;
1589 height = ri->ri_font->fontheight;
1591 sp = ri->ri_bits + r_srcrow + r_srccol * ri->ri_xscale;
1592 dp = ri->ri_bits + r_dstrow + r_dstcol * ri->ri_xscale;
1595 memmove(dp, sp, ri->ri_xscale);
1596 dp += ri->ri_stride;
1597 sp += ri->ri_stride;
1604 struct rasops_info *ri = (struct rasops_info *)cookie;
1608 if (__predict_false((unsigned int)row > ri->ri_rows ||
1609 (unsigned int)col > ri->ri_cols))
1613 if (ri->ri_cols - col - 1 < 0)
1617 ri->ri_real_ops.putchar(cookie, ri->ri_cols - col - 1, row, uc,
1625 height = ri->ri_font->fontheight;
1627 rp = (uint16_t *)(ri->ri_bits +
1628 (ri->ri_cols - col - 1) * ri->ri_yscale +
1629 row * ri->ri_xscale +
1630 (ri->ri_font->fontwidth - 1) * ri->ri_pelbytes);
1632 fg = (uint16_t)ATTR_FG(ri, attr);
1636 DELTA(rp, ri->ri_stride, uint16_t *);
1645 struct rasops_info *ri = (struct rasops_info *)cookie;
1650 for (col = 0; col < ri->ri_cols; col++)
1655 for (col = 0; col < ri->ri_cols; col++)