Lines Matching +full:pd +full:- +full:revision

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
37 * ALL pixel data is assumed to be 32-bit BGRA (byte order Blue, Green, Red,
43 * 32-bit to/from 32-bit is trivial case.
44 * 32-bit to/from 24-bit is also simple - we just drop the alpha channel.
45 * 32-bit to/from 16-bit is more complicated, because we nee to handle
46 * data loss from 32-bit to 16-bit. While reading/writing from/to video, we
47 * need to apply masks of 16-bit color components. This will preserve
48 * colors for terminal text. For 32-bit truecolor PMG images, we need to
49 * translate 32-bit colors to 15/16 bit colors and this means data loss.
54 * 32-bit to/from 8-bit is the most troublesome because 8-bit colors are
61 * used indexed colors for 8-bit colors (0-255) and for this mode we do
64 * - paletteentry RGB <-> index -
65 * BGRA BUFFER <----/ \ - VIDEO
67 * - RGB (16/24/32) -
70 * from when we set up 8-bit mode video. We cannot read palette data from
76 * Note: In 8-bit mode, We do store first 16 colors to palette registers
80 * loader is used. However, the palette map for 8-bit colors is using
81 * console color ordering - this does allow us to skip translation
151 * - blue and red are swapped (1 <-> 4)
152 * - yellow and cyan are swapped (3 <-> 6)
166 * in order to exclude buggy gop->Blt(), we want option
167 * to use direct draw to framebuffer and avoid gop->Blt.
224 *depth = -1; /* auto select */ in gfx_parse_mode_str()
236 * Returns true if we set the color from pre-existing environment, false if
286 if (gfx_fb_evalcolor("teken.fg_color", &attr->ta_fgcolor, in gfx_fb_setcolors()
289 if (gfx_fb_evalcolor("teken.bg_color", &attr->ta_bgcolor, in gfx_fb_setcolors()
333 /* colors 232-255 are a grayscale ramp */ in rgb_color_map()
348 * or we will lose color information from 32-bit to 15/16 bit translation.
356 roff = ffs(gfx_state.tg_fb.fb_mask_red) - 1; in gfx_fb_color_map()
357 goff = ffs(gfx_state.tg_fb.fb_mask_green) - 1; in gfx_fb_color_map()
358 boff = ffs(gfx_state.tg_fb.fb_mask_blue) - 1; in gfx_fb_color_map()
382 * Since UEFI does only support 32-bit colors, we do not implement it for
396 diff = r - pe8[k].Red; in rgb_to_color_index()
398 diff = g - pe8[k].Green; in rgb_to_color_index()
400 diff = b - pe8[k].Blue; in rgb_to_color_index()
504 roff = ffs(gfx_state.tg_fb.fb_mask_red) - 1; in gfxfb_blt_fill()
505 goff = ffs(gfx_state.tg_fb.fb_mask_green) - 1; in gfxfb_blt_fill()
506 boff = ffs(gfx_state.tg_fb.fb_mask_blue) - 1; in gfxfb_blt_fill()
509 data = rgb_to_color_index(p->Red, p->Green, p->Blue); in gfxfb_blt_fill()
511 data = (p->Red & in gfxfb_blt_fill()
513 data |= (p->Green & in gfxfb_blt_fill()
515 data |= (p->Blue & in gfxfb_blt_fill()
595 rp = ffs(gfx_state.tg_fb.fb_mask_red) - 1; in gfxfb_blt_video_to_buffer()
596 gp = ffs(gfx_state.tg_fb.fb_mask_green) - 1; in gfxfb_blt_video_to_buffer()
597 bp = ffs(gfx_state.tg_fb.fb_mask_blue) - 1; in gfxfb_blt_video_to_buffer()
604 ffs(rm) - 1 == 8 && rp == 16 && in gfxfb_blt_video_to_buffer()
605 ffs(gm) - 1 == 8 && gp == 8 && in gfxfb_blt_video_to_buffer()
606 ffs(bm) - 1 == 8 && bp == 0; in gfxfb_blt_video_to_buffer()
645 p->Red = (c >> rp) & rm; in gfxfb_blt_video_to_buffer()
646 p->Green = (c >> gp) & gm; in gfxfb_blt_video_to_buffer()
647 p->Blue = (c >> bp) & bm; in gfxfb_blt_video_to_buffer()
648 p->Reserved = 0; in gfxfb_blt_video_to_buffer()
695 rp = ffs(gfx_state.tg_fb.fb_mask_red) - 1; in gfxfb_blt_buffer_to_video()
696 gp = ffs(gfx_state.tg_fb.fb_mask_green) - 1; in gfxfb_blt_buffer_to_video()
697 bp = ffs(gfx_state.tg_fb.fb_mask_blue) - 1; in gfxfb_blt_buffer_to_video()
704 ffs(rm) - 1 == 8 && rp == 16 && in gfxfb_blt_buffer_to_video()
705 ffs(gm) - 1 == 8 && gp == 8 && in gfxfb_blt_buffer_to_video()
706 ffs(bm) - 1 == 8 && bp == 0; in gfxfb_blt_buffer_to_video()
725 c = rgb_to_color_index(p->Red, in gfxfb_blt_buffer_to_video()
726 p->Green, p->Blue); in gfxfb_blt_buffer_to_video()
728 c = (p->Red & rm) << rp | in gfxfb_blt_buffer_to_video()
729 (p->Green & gm) << gp | in gfxfb_blt_buffer_to_video()
730 (p->Blue & bm) << bp; in gfxfb_blt_buffer_to_video()
805 pitch = -pitch; in gfxfb_blt_video_to_video()
808 while (Height-- > 0) { in gfxfb_blt_video_to_video()
834 Width = fbX - DestinationX; in gfxfb_shadow_fill()
837 Height = fbY - DestinationY; in gfxfb_shadow_fill()
869 tpl = BS->RaiseTPL(TPL_NOTIFY); in gfxfb_blt()
874 status = gop->Blt(gop, BltBuffer, EfiBltVideoFill, in gfxfb_blt()
880 status = gop->Blt(gop, BltBuffer, in gfxfb_blt()
887 status = gop->Blt(gop, BltBuffer, EfiBltBufferToVideo, in gfxfb_blt()
893 status = gop->Blt(gop, BltBuffer, EfiBltVideoToVideo, in gfxfb_blt()
918 BS->RestoreTPL(tpl); in gfxfb_blt()
963 width = state->tg_font.vf_width; in gfx_bitblt_bitmap()
964 height = state->tg_font.vf_height; in gfx_bitblt_bitmap()
967 fgc = a->ta_fgcolor; in gfx_bitblt_bitmap()
968 bgc = a->ta_bgcolor; in gfx_bitblt_bitmap()
969 if (a->ta_format & TF_BOLD) in gfx_bitblt_bitmap()
971 if (a->ta_format & TF_BLINK) in gfx_bitblt_bitmap()
977 if (a->ta_format & TF_REVERSE) in gfx_bitblt_bitmap()
1000 gfx_mem_wr4(state->tg_glyph, in gfx_bitblt_bitmap()
1001 state->tg_glyph_size, o, cc); in gfx_bitblt_bitmap()
1014 width = state->tg_font.vf_width; in gfx_fb_printchar()
1015 height = state->tg_font.vf_height; in gfx_fb_printchar()
1016 x = state->tg_origin.tp_col + p->tp_col * width; in gfx_fb_printchar()
1017 y = state->tg_origin.tp_row + p->tp_row * height; in gfx_fb_printchar()
1019 gfx_fb_cons_display(x, y, width, height, state->tg_glyph); in gfx_fb_printchar()
1033 idx = p->tp_col + p->tp_row * state->tg_tp.tp_col; in gfx_fb_putchar()
1034 if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row) in gfx_fb_putchar()
1038 if (state->tg_cursor_visible) in gfx_fb_putchar()
1039 gfx_fb_cursor_draw(state, &state->tg_cursor, false); in gfx_fb_putchar()
1044 glyph = font_lookup(&state->tg_font, c, a); in gfx_fb_putchar()
1049 if (state->tg_cursor_visible) { in gfx_fb_putchar()
1052 c = teken_get_cursor(&state->tg_teken); in gfx_fb_putchar()
1069 if (state->tg_cursor_visible) in gfx_fb_fill()
1070 gfx_fb_cursor_draw(state, &state->tg_cursor, false); in gfx_fb_fill()
1072 glyph = font_lookup(&state->tg_font, c, a); in gfx_fb_fill()
1075 for (p.tp_row = r->tr_begin.tp_row; p.tp_row < r->tr_end.tp_row; in gfx_fb_fill()
1077 row = &screen_buffer[p.tp_row * state->tg_tp.tp_col]; in gfx_fb_fill()
1078 for (p.tp_col = r->tr_begin.tp_col; in gfx_fb_fill()
1079 p.tp_col < r->tr_end.tp_col; p.tp_col++) { in gfx_fb_fill()
1087 if (state->tg_cursor_visible) { in gfx_fb_fill()
1090 c = teken_get_cursor(&state->tg_teken); in gfx_fb_fill()
1105 if (p.tp_col >= state->tg_tp.tp_col) in gfx_fb_cursor_draw()
1106 p.tp_col = state->tg_tp.tp_col - 1; in gfx_fb_cursor_draw()
1107 if (p.tp_row >= state->tg_tp.tp_row) in gfx_fb_cursor_draw()
1108 p.tp_row = state->tg_tp.tp_row - 1; in gfx_fb_cursor_draw()
1109 idx = p.tp_col + p.tp_row * state->tg_tp.tp_col; in gfx_fb_cursor_draw()
1110 if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row) in gfx_fb_cursor_draw()
1113 glyph = font_lookup(&state->tg_font, screen_buffer[idx].c, in gfx_fb_cursor_draw()
1118 state->tg_cursor = p; in gfx_fb_cursor_draw()
1127 if (state->tg_cursor_visible) { in gfx_fb_cursor()
1128 gfx_fb_cursor_draw(state, &state->tg_cursor, false); in gfx_fb_cursor()
1150 c = teken_get_cursor(&state->tg_teken); in gfx_fb_param()
1153 state->tg_cursor_visible = true; in gfx_fb_param()
1155 state->tg_cursor_visible = false; in gfx_fb_param()
1166 if (px1->c != px2->c) in is_same_pixel()
1170 if ((px1->a.ta_format & TF_IMAGE) || in is_same_pixel()
1171 (px2->a.ta_format & TF_IMAGE)) in is_same_pixel()
1174 if (px1->a.ta_format != px2->a.ta_format) in is_same_pixel()
1176 if (px1->a.ta_fgcolor != px2->a.ta_fgcolor) in is_same_pixel()
1178 if (px1->a.ta_bgcolor != px2->a.ta_bgcolor) in is_same_pixel()
1192 width = state->tg_font.vf_width; in gfx_fb_copy_area()
1193 height = state->tg_font.vf_height; in gfx_fb_copy_area()
1195 sx = s->tr_begin.tp_col * width; in gfx_fb_copy_area()
1196 sy = s->tr_begin.tp_row * height; in gfx_fb_copy_area()
1197 dx = d->tp_col * width; in gfx_fb_copy_area()
1198 dy = d->tp_row * height; in gfx_fb_copy_area()
1200 width *= (s->tr_end.tp_col - s->tr_begin.tp_col + 1); in gfx_fb_copy_area()
1205 if (state->tg_shadow_fb == NULL) { in gfx_fb_copy_area()
1207 sx + state->tg_origin.tp_col, in gfx_fb_copy_area()
1208 sy + state->tg_origin.tp_row, in gfx_fb_copy_area()
1209 dx + state->tg_origin.tp_col, in gfx_fb_copy_area()
1210 dy + state->tg_origin.tp_row, in gfx_fb_copy_area()
1221 pitch = state->tg_fb.fb_width; in gfx_fb_copy_area()
1222 bytes = width * sizeof (*state->tg_shadow_fb); in gfx_fb_copy_area()
1230 step = -step; in gfx_fb_copy_area()
1233 while (height-- > 0) { in gfx_fb_copy_area()
1234 uint32_t *source = &state->tg_shadow_fb[sy * pitch + sx]; in gfx_fb_copy_area()
1235 uint32_t *destination = &state->tg_shadow_fb[dy * pitch + dx]; in gfx_fb_copy_area()
1239 0, 0, dx + state->tg_origin.tp_col, in gfx_fb_copy_area()
1240 dy + state->tg_origin.tp_row, width, 1, 0); in gfx_fb_copy_area()
1256 soffset = s->tp_col + s->tp_row * state->tg_tp.tp_col; in gfx_fb_copy_line()
1257 doffset = d->tp_col + d->tp_row * state->tg_tp.tp_col; in gfx_fb_copy_line()
1270 sr.tr_end.tp_col = s->tp_col + x; in gfx_fb_copy_line()
1274 sr.tr_begin.tp_col = s->tp_col + x; in gfx_fb_copy_line()
1275 sr.tr_begin.tp_row = s->tp_row; in gfx_fb_copy_line()
1276 sr.tr_end.tp_col = s->tp_col + x; in gfx_fb_copy_line()
1277 sr.tr_end.tp_row = s->tp_row; in gfx_fb_copy_line()
1278 dp.tp_col = d->tp_col + x; in gfx_fb_copy_line()
1279 dp.tp_row = d->tp_row; in gfx_fb_copy_line()
1294 int nrow, ncol, y; /* Has to be signed - >= 0 comparison */ in gfx_fb_copy()
1301 nrow = r->tr_end.tp_row - r->tr_begin.tp_row; in gfx_fb_copy()
1302 ncol = r->tr_end.tp_col - r->tr_begin.tp_col; in gfx_fb_copy()
1304 if (p->tp_row + nrow > state->tg_tp.tp_row || in gfx_fb_copy()
1305 p->tp_col + ncol > state->tg_tp.tp_col) in gfx_fb_copy()
1308 soffset = r->tr_begin.tp_col + r->tr_begin.tp_row * state->tg_tp.tp_col; in gfx_fb_copy()
1309 doffset = p->tp_col + p->tp_row * state->tg_tp.tp_col; in gfx_fb_copy()
1312 if (state->tg_cursor_visible) in gfx_fb_copy()
1313 gfx_fb_cursor_draw(state, &state->tg_cursor, false); in gfx_fb_copy()
1319 s = r->tr_begin; in gfx_fb_copy()
1322 s.tp_row = r->tr_begin.tp_row + y; in gfx_fb_copy()
1323 d.tp_row = p->tp_row + y; in gfx_fb_copy()
1328 for (y = nrow - 1; y >= 0; y--) { in gfx_fb_copy()
1329 s.tp_row = r->tr_begin.tp_row + y; in gfx_fb_copy()
1330 d.tp_row = p->tp_row + y; in gfx_fb_copy()
1337 if (state->tg_cursor_visible) { in gfx_fb_copy()
1340 c = teken_get_cursor(&state->tg_teken); in gfx_fb_copy()
1349 * blend = alpha * fg + (1.0 - alpha) * bg.
1362 blend = (alpha * fg + (0xFF - alpha) * bg); in alpha_blend()
1375 * blend = alpha * fg + (1.0 - alpha) * bg.
1382 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ps, *pd; in bitmap_cpy() local
1384 struct paletteentry *ps, *pd; in bitmap_cpy()
1390 pd = dst; in bitmap_cpy()
1397 pd[i].Red = alpha_blend(ps[i].Red, pd[i].Red, a); in bitmap_cpy()
1398 pd[i].Green = alpha_blend(ps[i].Green, pd[i].Green, a); in bitmap_cpy()
1399 pd[i].Blue = alpha_blend(ps[i].Blue, pd[i].Blue, a); in bitmap_cpy()
1400 pd[i].Reserved = a; in bitmap_cpy()
1442 (y - gfx_state.tg_origin.tp_row) * pitch + in gfx_fb_cons_display()
1443 x - gfx_state.tg_origin.tp_col); in gfx_fb_cons_display()
1493 num -= res + bit; in isqrt()
1510 if (ap->ta_format & TF_REVERSE) { in gfx_fb_getcolor()
1511 c = ap->ta_bgcolor; in gfx_fb_getcolor()
1512 if (ap->ta_format & TF_BLINK) in gfx_fb_getcolor()
1515 c = ap->ta_fgcolor; in gfx_fb_getcolor()
1516 if (ap->ta_format & TF_BOLD) in gfx_fb_getcolor()
1556 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1, in gfx_fb_drawrect()
1557 y2 - y1, 0); in gfx_fb_drawrect()
1559 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1, 1, 0); in gfx_fb_drawrect()
1560 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y2, x2 - x1, 1, 0); in gfx_fb_drawrect()
1561 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, 1, y2 - y1, 0); in gfx_fb_drawrect()
1562 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x2, y1, 1, y2 - y1, 0); in gfx_fb_drawrect()
1576 sx = x0 < x1? 1 : -1; in gfx_fb_line()
1577 sy = y0 < y1? 1 : -1; in gfx_fb_line()
1578 dx = x1 > x0? x1 - x0 : x0 - x1; in gfx_fb_line()
1579 dy = y1 > y0? y1 - y0 : y0 - y1; in gfx_fb_line()
1587 if ((e2 << 1) >= -dx) { /* x step */ in gfx_fb_line()
1599 err -= dy; in gfx_fb_line()
1603 e2 = dx-e2; in gfx_fb_line()
1633 sx = x2 - x1; in gfx_fb_bezier()
1634 sy = y2 - y1; in gfx_fb_bezier()
1635 xx = x0 - x1; in gfx_fb_bezier()
1636 yy = y0 - y1; in gfx_fb_bezier()
1637 curvature = xx*sy - yy*sx; in gfx_fb_bezier()
1644 curvature = -curvature; in gfx_fb_bezier()
1648 sx = x0 < x2? 1 : -1; in gfx_fb_bezier()
1651 sy = y0 < y2? 1 : -1; in gfx_fb_bezier()
1657 xx = -xx; in gfx_fb_bezier()
1658 yy = -yy; in gfx_fb_bezier()
1659 xy = -xy; in gfx_fb_bezier()
1660 curvature = -curvature; in gfx_fb_bezier()
1662 dx = 4 * sy * curvature * (x1 - x0) + xx - xy; in gfx_fb_bezier()
1663 dy = 4 * sx * curvature * (y0 - y1) + yy - xy; in gfx_fb_bezier()
1671 return; /* last pixel -> curve finished */ in gfx_fb_bezier()
1675 dx -= xy; in gfx_fb_bezier()
1681 dy -= xy; in gfx_fb_bezier()
1685 } while (dy < dx); /* gradient negates -> algorithm fails */ in gfx_fb_bezier()
1708 xshift = (vf_width - width) / 2; in gfx_term_drawrect()
1709 yshift = (vf_height - width) / 2; in gfx_term_drawrect()
1713 ux1--; in gfx_term_drawrect()
1715 uy1--; in gfx_term_drawrect()
1716 ux2--; in gfx_term_drawrect()
1717 uy2--; in gfx_term_drawrect()
1735 y2 += vf_height - yshift - width; in gfx_term_drawrect()
1747 x1 += vf_width - xshift - width; in gfx_term_drawrect()
1759 gfx_fb_bezier(x1 + i, y1, x1 + i, y2 + i, x2, y2 + i, width-i); in gfx_term_drawrect()
1765 y1 += vf_height - yshift; in gfx_term_drawrect()
1769 gfx_fb_bezier(x1, y1 - i, x2 + i, y1 - i, x2 + i, y2, width-i); in gfx_term_drawrect()
1775 x2 += vf_width - xshift - width; in gfx_term_drawrect()
1779 gfx_fb_bezier(x1, y1 + i, x2 + i, y1 + i, x2 + i, y2, width-i); in gfx_term_drawrect()
1784 y1 += vf_height - yshift; in gfx_term_drawrect()
1786 x2 += vf_width - xshift - width; in gfx_term_drawrect()
1789 gfx_fb_bezier(x1, y1 - i, x2 + i, y1 - i, x2 + i, y2, width-i); in gfx_term_drawrect()
1817 if (png->color_type != PNG_TRUECOLOR_ALPHA) { in gfx_fb_putimage()
1830 if (png->width > UINT16_MAX || png->height > UINT16_MAX) { in gfx_fb_putimage()
1836 if (png->width < 1 || png->height < 1) { in gfx_fb_putimage()
1849 ux2 = ux1 + png->width; in gfx_fb_putimage()
1850 uy2 = uy1 + png->height; in gfx_fb_putimage()
1854 ux2 = ux1 + (png->width * (uy2 - uy1)) / png->height; in gfx_fb_putimage()
1857 uy2 = uy1 + (png->height * (ux2 - ux1)) / png->width; in gfx_fb_putimage()
1867 fwidth = ux2 - ux1; in gfx_fb_putimage()
1868 fheight = uy2 - uy1; in gfx_fb_putimage()
1874 if (fwidth == png->width && fheight == png->height) in gfx_fb_putimage()
1879 * No top left X co-ordinate (real coordinates start at 1), in gfx_fb_putimage()
1882 ux2 = gfx_state.tg_fb.fb_width - gfx_state.tg_origin.tp_col; in gfx_fb_putimage()
1883 ux1 = ux2 - fwidth; in gfx_fb_putimage()
1888 * No top left Y co-ordinate (real coordinates start at 1), in gfx_fb_putimage()
1891 uy2 = gfx_state.tg_fb.fb_height - gfx_state.tg_origin.tp_row; in gfx_fb_putimage()
1892 uy1 = uy2 - fheight; in gfx_fb_putimage()
1908 printf("Image %ux%u -> %ux%u @%ux%u\n", in gfx_fb_putimage()
1909 png->width, png->height, fwidth, fheight, ux1, uy1); in gfx_fb_putimage()
1938 #define GETPIXEL(xx, yy) (((yy) * png->width + (xx)) * png->bpp) in gfx_fb_putimage()
1943 * Use fixed-point arithmetic with 16-bits for each of the integer and in gfx_fb_putimage()
1946 const uint32_t wcstep = ((png->width - 1) << 16) / (fwidth - 1); in gfx_fb_putimage()
1947 const uint32_t hcstep = ((png->height - 1) << 16) / (fheight - 1); in gfx_fb_putimage()
1949 rs = 8 - (fls(gfx_state.tg_fb.fb_mask_red) - in gfx_fb_putimage()
1951 gs = 8 - (fls(gfx_state.tg_fb.fb_mask_green) - in gfx_fb_putimage()
1953 bs = 8 - (fls(gfx_state.tg_fb.fb_mask_blue) - in gfx_fb_putimage()
1959 uint32_t hc1 = 0x80 - hc2; in gfx_fb_putimage()
1967 uint32_t wc1 = 0x80 - wc2; in gfx_fb_putimage()
1977 r = png->image[i]; in gfx_fb_putimage()
1978 g = png->image[i + 1]; in gfx_fb_putimage()
1979 b = png->image[i + 2]; in gfx_fb_putimage()
1980 a = png->image[i + 3]; in gfx_fb_putimage()
2011 (png->image[p00 + i] * hc1 + in gfx_fb_putimage()
2012 png->image[p01 + i] * hc2) * wc1 + in gfx_fb_putimage()
2013 (png->image[p10 + i] * hc1 + in gfx_fb_putimage()
2014 png->image[p11 + i] * hc2) * wc2) in gfx_fb_putimage()
2052 fl->font_flags = FONT_AUTO; in reset_font_flags()
2065 w = edid_info->display.max_horizontal_image_size; in edid_diagonal_squared()
2066 h = edid_info->display.max_vertical_image_size; in edid_diagonal_squared()
2146 font = fl->font_data; in gfx_get_font()
2147 if (height / font->vfbd_height < rows || in gfx_get_font()
2148 width / font->vfbd_width < cols) in gfx_get_font()
2157 if (next == NULL || next->font_data->vfbd_height < size) { in gfx_get_font()
2158 if (font->vfbd_font == NULL || in gfx_get_font()
2159 fl->font_flags == FONT_RELOAD) { in gfx_get_font()
2160 if (fl->font_load != NULL && in gfx_get_font()
2161 fl->font_name != NULL) in gfx_get_font()
2162 font = fl->font_load(fl->font_name); in gfx_get_font()
2184 if (fl->font_flags == FONT_MANUAL) { in set_font()
2185 font = fl->font_data; in set_font()
2186 if (font->vfbd_font == NULL && fl->font_load != NULL && in set_font()
2187 fl->font_name != NULL) { in set_font()
2188 font = fl->font_load(fl->font_name); in set_font()
2190 if (font == NULL || font->vfbd_font == NULL) in set_font()
2200 *rows = height / font->vfbd_height; in set_font()
2201 *cols = width / font->vfbd_width; in set_font()
2211 font = fl->font_data; in set_font()
2212 if ((*rows * font->vfbd_height <= height && in set_font()
2213 *cols * font->vfbd_width <= width) || in set_font()
2216 font->vfbd_height == DEFAULT_FONT_DATA.vfbd_height && in set_font()
2217 font->vfbd_width == DEFAULT_FONT_DATA.vfbd_width)) { in set_font()
2218 if (font->vfbd_font == NULL || in set_font()
2219 fl->font_flags == FONT_RELOAD) { in set_font()
2220 if (fl->font_load != NULL && in set_font()
2221 fl->font_name != NULL) { in set_font()
2222 font = fl->font_load(fl->font_name); in set_font()
2227 *rows = height / font->vfbd_height; in set_font()
2228 *cols = width / font->vfbd_width; in set_font()
2240 if (fl != NULL && fl->font_load != NULL && in set_font()
2241 fl->font_name != NULL) { in set_font()
2242 font = fl->font_load(fl->font_name); in set_font()
2247 *rows = height / font->vfbd_height; in set_font()
2248 *cols = width / font->vfbd_width; in set_font()
2261 gfx_state.tg_functions->tf_param(&gfx_state, TP_SHOWCURSOR, 0); in cons_clear()
2268 teken_pos_t *tp = &state->tg_tp; in setup_font()
2279 font_data = set_font(&tp->tp_row, &tp->tp_col, height, width); in setup_font()
2285 state->tg_font.vf_map[i] = in setup_font()
2286 font_data->vfbd_font->vf_map[i]; in setup_font()
2287 state->tg_font.vf_map_count[i] = in setup_font()
2288 font_data->vfbd_font->vf_map_count[i]; in setup_font()
2291 state->tg_font.vf_bytes = font_data->vfbd_font->vf_bytes; in setup_font()
2292 state->tg_font.vf_height = font_data->vfbd_font->vf_height; in setup_font()
2293 state->tg_font.vf_width = font_data->vfbd_font->vf_width; in setup_font()
2296 state->tg_font.vf_width, state->tg_font.vf_height); in setup_font()
2308 max = len - 1; in font_bisearch()
2318 return (src - map[0].vfm_src + map[0].vfm_dst); in font_bisearch()
2327 max = mid - 1; in font_bisearch()
2331 return (src - map[mid].vfm_src + map[mid].vfm_dst); in font_bisearch()
2348 if (a->ta_format & TF_BOLD) { in font_lookup()
2349 dst = font_bisearch(vf->vf_map[VFNT_MAP_BOLD], in font_lookup()
2350 vf->vf_map_count[VFNT_MAP_BOLD], c); in font_lookup()
2354 dst = font_bisearch(vf->vf_map[VFNT_MAP_NORMAL], in font_lookup()
2355 vf->vf_map_count[VFNT_MAP_NORMAL], c); in font_lookup()
2358 stride = howmany(vf->vf_width, 8) * vf->vf_height; in font_lookup()
2359 return (&vf->vf_bytes[dst * stride]); in font_lookup()
2369 if (fp->vf_map_count[n] == 0) in load_mapping()
2372 size = fp->vf_map_count[n] * sizeof(*mp); in load_mapping()
2376 fp->vf_map[n] = mp; in load_mapping()
2380 free(fp->vf_map[n]); in load_mapping()
2381 fp->vf_map[n] = NULL; in load_mapping()
2385 for (i = 0; i < fp->vf_map_count[n]; i++) { in load_mapping()
2402 if (fp->vf_map_count[n] == 0) in builtin_mapping()
2405 size = fp->vf_map_count[n] * sizeof(*mp); in builtin_mapping()
2409 fp->vf_map[n] = mp; in builtin_mapping()
2411 memcpy(mp, DEFAULT_FONT_DATA.vfbd_font->vf_map[n], size); in builtin_mapping()
2436 if (strcmp(fl->font_name, path) == 0) in load_font()
2442 bp = fl->font_data; in load_font()
2443 if (bp->vfbd_font != NULL && fl->font_flags != FONT_RELOAD) in load_font()
2446 fd = -1; in load_font()
2452 if (fl->font_flags == FONT_BUILTIN) { in load_font()
2456 fp->vf_width = DEFAULT_FONT_DATA.vfbd_width; in load_font()
2457 fp->vf_height = DEFAULT_FONT_DATA.vfbd_height; in load_font()
2459 fp->vf_bytes = malloc(DEFAULT_FONT_DATA.vfbd_uncompressed_size); in load_font()
2460 if (fp->vf_bytes == NULL) { in load_font()
2465 bp->vfbd_uncompressed_size = in load_font()
2467 bp->vfbd_compressed_size = in load_font()
2471 fp->vf_bytes, in load_font()
2474 free(fp->vf_bytes); in load_font()
2480 fp->vf_map_count[i] = in load_font()
2481 DEFAULT_FONT_DATA.vfbd_font->vf_map_count[i]; in load_font()
2486 bp->vfbd_font = fp; in load_font()
2509 fp->vf_map_count[i] = be32toh(fh.fh_map_count[i]); in load_font()
2512 fp->vf_width = fh.fh_width; in load_font()
2513 fp->vf_height = fh.fh_height; in load_font()
2515 size = howmany(fp->vf_width, 8) * fp->vf_height * glyphs; in load_font()
2516 bp->vfbd_uncompressed_size = size; in load_font()
2517 if ((fp->vf_bytes = malloc(size)) == NULL) in load_font()
2520 rv = read(fd, fp->vf_bytes, size); in load_font()
2531 if (fl->font_flags == FONT_BUILTIN) in load_font()
2532 fl->font_flags = FONT_AUTO; in load_font()
2538 * We do need to keep fl->font_data for glyph dimensions. in load_font()
2541 if (fl->font_data->vfbd_font == NULL) in load_font()
2545 free(fl->font_data->vfbd_font->vf_map[i]); in load_font()
2546 free(fl->font_data->vfbd_font->vf_bytes); in load_font()
2547 free(fl->font_data->vfbd_font); in load_font()
2548 fl->font_data->vfbd_font = NULL; in load_font()
2551 bp->vfbd_font = fp; in load_font()
2552 bp->vfbd_compressed_size = 0; in load_font()
2555 if (fd != -1) in load_font()
2561 free(fp->vf_map[i]); in load_font()
2562 free(fp->vf_bytes); in load_font()
2626 if (asprintf(&np->n_name, "%s/%s", dir, buf) < 0) { in read_list()
2695 if (fh.fh_width == entry->font_data->vfbd_width && in insert_font()
2696 fh.fh_height == entry->font_data->vfbd_height) { in insert_font()
2697 free(entry->font_name); in insert_font()
2698 entry->font_name = font_name; in insert_font()
2699 entry->font_flags = FONT_RELOAD; in insert_font()
2710 fp->font_data = calloc(sizeof(*fp->font_data), 1); in insert_font()
2711 if (fp->font_data == NULL) { in insert_font()
2716 fp->font_name = font_name; in insert_font()
2717 fp->font_flags = flags; in insert_font()
2718 fp->font_load = load_font; in insert_font()
2719 fp->font_data->vfbd_width = fh.fh_width; in insert_font()
2720 fp->font_data->vfbd_height = fh.fh_height; in insert_font()
2729 size = fp->font_data->vfbd_width * fp->font_data->vfbd_height; in insert_font()
2734 bd = entry->font_data; in insert_font()
2736 if (size > bd->vfbd_width * bd->vfbd_height) { in insert_font()
2748 size > next->font_data->vfbd_width * in insert_font()
2749 next->font_data->vfbd_height) { in insert_font()
2778 if (fl->font_data->vfbd_width == x && in font_set()
2779 fl->font_data->vfbd_height == y) in font_set()
2787 fl->font_flags = FONT_MANUAL; in font_set()
2794 printf(" %dx%d\n", fl->font_data->vfbd_width, in font_set()
2795 fl->font_data->vfbd_height); in font_set()
2824 if (insert_font(np->n_name, FONT_AUTO) == false) in autoload_font()
2825 printf("failed to add font: %s\n", np->n_name); in autoload_font()
2826 free(np->n_name); in autoload_font()
2857 while ((c = getopt(argc, argv, "l")) != -1) { in command_font()
2868 argc -= optind; in command_font()
2872 printf("Usage: loadfont [-l] | [file.fnt]\n"); in command_font()
2878 printf("font %s: %dx%d%s\n", fl->font_name, in command_font()
2879 fl->font_data->vfbd_width, in command_font()
2880 fl->font_data->vfbd_height, in command_font()
2881 fl->font_data->vfbd_font == NULL? "" : " loaded"); in command_font()
2908 if (fl->font_data->vfbd_font != NULL) { in command_font()
2910 bd = fl->font_data; in command_font()
2916 free(bd->vfbd_font->vf_map[i]); in command_font()
2917 free(fl->font_data->vfbd_font); in command_font()
2918 fl->font_data->vfbd_font = NULL; in command_font()
2919 fl->font_data->vfbd_uncompressed_size = 0; in command_font()
2920 fl->font_flags = FONT_AUTO; in command_font()
2936 if ((edid->display.supported_features in gfx_get_edid_resolution()
2943 if (edid->detailed_timings[i].pixel_clock == 0) in gfx_get_edid_resolution()
2947 rp->width = GET_EDID_INFO_WIDTH(edid, i); in gfx_get_edid_resolution()
2948 rp->height = GET_EDID_INFO_HEIGHT(edid, i); in gfx_get_edid_resolution()
2949 if (rp->width > 0 && rp->width <= EDID_MAX_PIXELS && in gfx_get_edid_resolution()
2950 rp->height > 0 && rp->height <= EDID_MAX_LINES) in gfx_get_edid_resolution()
2962 if (edid->standard_timings[i] == 0x0101) in gfx_get_edid_resolution()
2968 rp->width = HSIZE(edid->standard_timings[i]); in gfx_get_edid_resolution()
2969 switch (RATIO(edid->standard_timings[i])) { in gfx_get_edid_resolution()
2971 rp->height = HSIZE(edid->standard_timings[i]); in gfx_get_edid_resolution()
2972 if (edid->header.version > 1 || in gfx_get_edid_resolution()
2973 edid->header.revision > 2) { in gfx_get_edid_resolution()
2974 rp->height = rp->height * 10 / 16; in gfx_get_edid_resolution()
2978 rp->height = HSIZE(edid->standard_timings[i]) * 3 / 4; in gfx_get_edid_resolution()
2981 rp->height = HSIZE(edid->standard_timings[i]) * 4 / 5; in gfx_get_edid_resolution()
2984 rp->height = HSIZE(edid->standard_timings[i]) * 9 / 16; in gfx_get_edid_resolution()
2993 if (p->width * p->height < rp->width * rp->height) { in gfx_get_edid_resolution()
3036 if (gfx_state.tg_font.vf_width == fl->font_data->vfbd_width && in build_font_module()
3037 gfx_state.tg_font.vf_height == fl->font_data->vfbd_height) { in build_font_module()
3041 if (fl->font_flags == FONT_BUILTIN) in build_font_module()
3044 bd = fl->font_data; in build_font_module()
3050 fd = bd->vfbd_font; in build_font_module()
3052 fi.fi_width = fd->vf_width; in build_font_module()
3054 fi.fi_height = fd->vf_height; in build_font_module()
3056 fi.fi_bitmap_size = bd->vfbd_uncompressed_size; in build_font_module()
3061 fi.fi_map_count[i] = fd->vf_map_count[i]; in build_font_module()
3063 size += fd->vf_map_count[i] * sizeof (struct vfnt_map); in build_font_module()
3066 size += bd->vfbd_uncompressed_size; in build_font_module()
3068 fi.fi_checksum = -checksum; in build_font_module()
3080 if (fd->vf_map_count[i] != 0) { in build_font_module()
3081 addr += archsw.arch_copyin(fd->vf_map[i], addr, in build_font_module()
3082 fd->vf_map_count[i] * sizeof (struct vfnt_map)); in build_font_module()
3088 addr += archsw.arch_copyin(fd->vf_bytes, addr, fi.fi_bitmap_size); in build_font_module()