Lines Matching +full:early +full:- +full:to +full:- +full:mid
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * The workhorse here is gfxfb_blt(). It is implemented to mimic UEFI
32 * GOP Blt, and allows us to fill the rectangle on screen, copy
33 * rectangle from video to buffer and buffer to video and video to video.
34 * Such implementation does allow us to have almost identical implementation
37 * ALL pixel data is assumed to be 32-bit BGRA (byte order Blue, Green, Red,
38 * Alpha) format, this allows us to only handle RGB data and not to worry
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.
50 * There are different algorithms how to perform such color space reduction,
51 * we are currently using bitwise right shift to reduce color space and so far
52 * this technique seems to be sufficient (see also gfx_fb_putimage(), the
54 * 32-bit to/from 8-bit is the most troublesome because 8-bit colors are
56 * color index values to RGB. To write to video, we again need to translate
57 * RGB to color index. Additionally, we need to translate between VGA and
61 * used indexed colors for 8-bit colors (0-255) and for this mode we do
62 * need to perform translation to/from BGRA and index values.
64 * - paletteentry RGB <-> index -
65 * BGRA BUFFER <----/ \ - VIDEO
67 * - RGB (16/24/32) -
69 * To perform index to RGB translation, we use palette table generated
70 * from when we set up 8-bit mode video. We cannot read palette data from
73 * BGRA to index is implemented in rgb_to_color_index() by searching
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
82 * from VGA colors to console colors, while we are reading RGB data.
149 * - blue and red are swapped (1 <-> 4)
150 * - yellow and cyan are swapped (3 <-> 6)
182 * Setup font list to have builtin font.
195 * Utility function to parse gfx mode line strings.
214 *depth = -1; /* auto select */
261 /* colors 232-255 are a grayscale ramp */
275 * 15/16 bit depth needs to use mask size from mode,
276 * or we will lose color information from 32-bit to 15/16 bit translation.
284 roff = ffs(gfx_state.tg_fb.fb_mask_red) - 1;
285 goff = ffs(gfx_state.tg_fb.fb_mask_green) - 1;
286 boff = ffs(gfx_state.tg_fb.fb_mask_blue) - 1;
308 * Get indexed color from RGB. This function is used to write data to video
309 * memory when the adapter is set to use indexed colors.
310 * Since UEFI does only support 32-bit colors, we do not implement it for
324 diff = r - pe8[k].Red;
326 diff = g - pe8[k].Green;
328 diff = b - pe8[k].Blue;
432 roff = ffs(gfx_state.tg_fb.fb_mask_red) - 1;
433 goff = ffs(gfx_state.tg_fb.fb_mask_green) - 1;
434 boff = ffs(gfx_state.tg_fb.fb_mask_blue) - 1;
437 data = rgb_to_color_index(p->Red, p->Green, p->Blue);
439 data = (p->Red &
441 data |= (p->Green &
443 data |= (p->Blue &
523 rp = ffs(gfx_state.tg_fb.fb_mask_red) - 1;
524 gp = ffs(gfx_state.tg_fb.fb_mask_green) - 1;
525 bp = ffs(gfx_state.tg_fb.fb_mask_blue) - 1;
532 ffs(rm) - 1 == 8 && rp == 16 &&
533 ffs(gm) - 1 == 8 && gp == 8 &&
534 ffs(bm) - 1 == 8 && bp == 0;
573 p->Red = (c >> rp) & rm;
574 p->Green = (c >> gp) & gm;
575 p->Blue = (c >> bp) & bm;
576 p->Reserved = 0;
623 rp = ffs(gfx_state.tg_fb.fb_mask_red) - 1;
624 gp = ffs(gfx_state.tg_fb.fb_mask_green) - 1;
625 bp = ffs(gfx_state.tg_fb.fb_mask_blue) - 1;
632 ffs(rm) - 1 == 8 && rp == 16 &&
633 ffs(gm) - 1 == 8 && gp == 8 &&
634 ffs(bm) - 1 == 8 && bp == 0;
653 c = rgb_to_color_index(p->Red,
654 p->Green, p->Blue);
656 c = (p->Red & rm) << rp |
657 (p->Green & gm) << gp |
658 (p->Blue & bm) << bp;
733 pitch = -pitch;
736 while (Height-- > 0) {
762 Width = fbX - DestinationX;
765 Height = fbY - DestinationY;
790 * We assume Blt() does work, if not, we will need to build exception
797 tpl = BS->RaiseTPL(TPL_NOTIFY);
802 status = gop->Blt(gop, BltBuffer, EfiBltVideoFill,
808 status = gop->Blt(gop, BltBuffer,
815 status = gop->Blt(gop, BltBuffer, EfiBltBufferToVideo,
821 status = gop->Blt(gop, BltBuffer, EfiBltVideoToVideo,
846 BS->RestoreTPL(tpl);
891 width = state->tg_font.vf_width;
892 height = state->tg_font.vf_height;
895 fgc = a->ta_fgcolor;
896 bgc = a->ta_bgcolor;
897 if (a->ta_format & TF_BOLD)
899 if (a->ta_format & TF_BLINK)
905 if (a->ta_format & TF_REVERSE)
928 gfx_mem_wr4(state->tg_glyph,
929 state->tg_glyph_size, o, cc);
942 width = state->tg_font.vf_width;
943 height = state->tg_font.vf_height;
944 x = state->tg_origin.tp_col + p->tp_col * width;
945 y = state->tg_origin.tp_row + p->tp_row * height;
947 gfx_fb_cons_display(x, y, width, height, state->tg_glyph);
951 * Store char with its attribute to buffer and put it on screen.
961 idx = p->tp_col + p->tp_row * state->tg_tp.tp_col;
962 if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row)
966 if (state->tg_cursor_visible)
967 gfx_fb_cursor_draw(state, &state->tg_cursor, false);
972 glyph = font_lookup(&state->tg_font, c, a);
977 if (state->tg_cursor_visible) {
980 c = teken_get_cursor(&state->tg_teken);
995 if (state->tg_cursor_visible)
996 gfx_fb_cursor_draw(state, &state->tg_cursor, false);
998 glyph = font_lookup(&state->tg_font, c, a);
1001 for (p.tp_row = r->tr_begin.tp_row; p.tp_row < r->tr_end.tp_row;
1003 row = &screen_buffer[p.tp_row * state->tg_tp.tp_col];
1004 for (p.tp_col = r->tr_begin.tp_col;
1005 p.tp_col < r->tr_end.tp_col; p.tp_col++) {
1013 if (state->tg_cursor_visible) {
1016 c = teken_get_cursor(&state->tg_teken);
1029 if (p.tp_col >= state->tg_tp.tp_col)
1030 p.tp_col = state->tg_tp.tp_col - 1;
1031 if (p.tp_row >= state->tg_tp.tp_row)
1032 p.tp_row = state->tg_tp.tp_row - 1;
1033 idx = p.tp_col + p.tp_row * state->tg_tp.tp_col;
1034 if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row)
1037 glyph = font_lookup(&state->tg_font, screen_buffer[idx].c,
1042 state->tg_cursor = p;
1051 if (state->tg_cursor_visible) {
1052 gfx_fb_cursor_draw(state, &state->tg_cursor, false);
1069 * so must map 2 to 0.
1074 c = teken_get_cursor(&state->tg_teken);
1077 state->tg_cursor_visible = true;
1079 state->tg_cursor_visible = false;
1090 if (px1->c != px2->c)
1094 if ((px1->a.ta_format & TF_IMAGE) ||
1095 (px2->a.ta_format & TF_IMAGE))
1098 if (px1->a.ta_format != px2->a.ta_format)
1100 if (px1->a.ta_fgcolor != px2->a.ta_fgcolor)
1102 if (px1->a.ta_bgcolor != px2->a.ta_bgcolor)
1116 width = state->tg_font.vf_width;
1117 height = state->tg_font.vf_height;
1119 sx = s->tr_begin.tp_col * width;
1120 sy = s->tr_begin.tp_row * height;
1121 dx = d->tp_col * width;
1122 dy = d->tp_row * height;
1124 width *= (s->tr_end.tp_col - s->tr_begin.tp_col + 1);
1127 * With no shadow fb, use video to video copy.
1129 if (state->tg_shadow_fb == NULL) {
1131 sx + state->tg_origin.tp_col,
1132 sy + state->tg_origin.tp_row,
1133 dx + state->tg_origin.tp_col,
1134 dy + state->tg_origin.tp_row,
1140 * With shadow fb, we need to copy data on both shadow and video,
1141 * to preserve the consistency. We only read data from shadow fb.
1145 pitch = state->tg_fb.fb_width;
1146 bytes = width * sizeof (*state->tg_shadow_fb);
1149 * To handle overlapping areas, set up reverse copy here.
1154 step = -step;
1157 while (height-- > 0) {
1158 uint32_t *source = &state->tg_shadow_fb[sy * pitch + sx];
1159 uint32_t *destination = &state->tg_shadow_fb[dy * pitch + dx];
1163 0, 0, dx + state->tg_origin.tp_col,
1164 dy + state->tg_origin.tp_row, width, 1, 0);
1180 soffset = s->tp_col + s->tp_row * state->tg_tp.tp_col;
1181 doffset = d->tp_col + d->tp_row * state->tg_tp.tp_col;
1194 sr.tr_end.tp_col = s->tp_col + x;
1198 sr.tr_begin.tp_col = s->tp_col + x;
1199 sr.tr_begin.tp_row = s->tp_row;
1200 sr.tr_end.tp_col = s->tp_col + x;
1201 sr.tr_end.tp_row = s->tp_row;
1202 dp.tp_col = d->tp_col + x;
1203 dp.tp_row = d->tp_row;
1218 int nrow, ncol, y; /* Has to be signed - >= 0 comparison */
1222 * correct order, to make sure we don't overwrite our own data.
1225 nrow = r->tr_end.tp_row - r->tr_begin.tp_row;
1226 ncol = r->tr_end.tp_col - r->tr_begin.tp_col;
1228 if (p->tp_row + nrow > state->tg_tp.tp_row ||
1229 p->tp_col + ncol > state->tg_tp.tp_col)
1232 soffset = r->tr_begin.tp_col + r->tr_begin.tp_row * state->tg_tp.tp_col;
1233 doffset = p->tp_col + p->tp_row * state->tg_tp.tp_col;
1236 if (state->tg_cursor_visible)
1237 gfx_fb_cursor_draw(state, &state->tg_cursor, false);
1243 s = r->tr_begin;
1246 s.tp_row = r->tr_begin.tp_row + y;
1247 d.tp_row = p->tp_row + y;
1252 for (y = nrow - 1; y >= 0; y--) {
1253 s.tp_row = r->tr_begin.tp_row + y;
1254 d.tp_row = p->tp_row + y;
1261 if (state->tg_cursor_visible) {
1264 c = teken_get_cursor(&state->tg_teken);
1273 * blend = alpha * fg + (1.0 - alpha) * bg.
1286 blend = (alpha * fg + (0xFF - alpha) * bg);
1299 * blend = alpha * fg + (1.0 - alpha) * bg.
1356 * If we do have shadow fb, we will use shadow to render data,
1357 * and copy shadow to video.
1366 (y - gfx_state.tg_origin.tp_row) * pitch +
1367 x - gfx_state.tg_origin.tp_col);
1377 * Common data to display is glyph, use preallocated
1417 num -= res + bit;
1434 if (ap->ta_format & TF_REVERSE) {
1435 c = ap->ta_bgcolor;
1436 if (ap->ta_format & TF_BLINK)
1439 c = ap->ta_fgcolor;
1440 if (ap->ta_format & TF_BOLD)
1480 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1,
1481 y2 - y1, 0);
1483 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1, 1, 0);
1484 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y2, x2 - x1, 1, 0);
1485 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, 1, y2 - y1, 0);
1486 gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x2, y1, 1, y2 - y1, 0);
1500 sx = x0 < x1? 1 : -1;
1501 sy = y0 < y1? 1 : -1;
1502 dx = x1 > x0? x1 - x0 : x0 - x1;
1503 dy = y1 > y0? y1 - y0 : y0 - y1;
1511 if ((e2 << 1) >= -dx) { /* x step */
1523 err -= dy;
1527 e2 = dx-e2;
1543 * quadratic Bézier curve limited to gradients without sign change.
1557 sx = x2 - x1;
1558 sy = y2 - y1;
1559 xx = x0 - x1;
1560 yy = y0 - y1;
1561 curvature = xx*sy - yy*sx;
1568 curvature = -curvature;
1572 sx = x0 < x2? 1 : -1;
1575 sy = y0 < y2? 1 : -1;
1581 xx = -xx;
1582 yy = -yy;
1583 xy = -xy;
1584 curvature = -curvature;
1586 dx = 4 * sy * curvature * (x1 - x0) + xx - xy;
1587 dy = 4 * sx * curvature * (y0 - y1) + yy - xy;
1595 return; /* last pixel -> curve finished */
1599 dx -= xy;
1605 dy -= xy;
1609 } while (dy < dx); /* gradient negates -> algorithm fails */
1632 xshift = (vf_width - width) / 2;
1633 yshift = (vf_height - width) / 2;
1637 ux1--;
1639 uy1--;
1640 ux2--;
1641 uy2--;
1659 y2 += vf_height - yshift - width;
1671 x1 += vf_width - xshift - width;
1683 gfx_fb_bezier(x1 + i, y1, x1 + i, y2 + i, x2, y2 + i, width-i);
1689 y1 += vf_height - yshift;
1693 gfx_fb_bezier(x1, y1 - i, x2 + i, y1 - i, x2 + i, y2, width-i);
1699 x2 += vf_width - xshift - width;
1703 gfx_fb_bezier(x1, y1 + i, x2 + i, y1 + i, x2 + i, y2, width-i);
1708 y1 += vf_height - yshift;
1710 x2 += vf_width - xshift - width;
1713 gfx_fb_bezier(x1, y1 - i, x2 + i, y1 - i, x2 + i, y2, width-i);
1741 if (png->color_type != PNG_TRUECOLOR_ALPHA) {
1754 if (png->width > UINT16_MAX || png->height > UINT16_MAX) {
1760 if (png->width < 1 || png->height < 1) {
1773 ux2 = ux1 + png->width;
1774 uy2 = uy1 + png->height;
1777 /* Set ux2 from uy2/uy1 to maintain aspect ratio */
1778 ux2 = ux1 + (png->width * (uy2 - uy1)) / png->height;
1780 /* Set uy2 from ux2/ux1 to maintain aspect ratio */
1781 uy2 = uy1 + (png->height * (ux2 - ux1)) / png->width;
1791 fwidth = ux2 - ux1;
1792 fheight = uy2 - uy1;
1798 if (fwidth == png->width && fheight == png->height)
1803 * No top left X co-ordinate (real coordinates start at 1),
1806 ux2 = gfx_state.tg_fb.fb_width - gfx_state.tg_origin.tp_col;
1807 ux1 = ux2 - fwidth;
1812 * No top left Y co-ordinate (real coordinates start at 1),
1815 uy2 = gfx_state.tg_fb.fb_height - gfx_state.tg_origin.tp_row;
1816 uy1 = uy2 - fheight;
1832 printf("Image %ux%u -> %ux%u @%ux%u\n",
1833 png->width, png->height, fwidth, fheight, ux1, uy1);
1861 /* Helper to calculate the pixel index from the source png */
1862 #define GETPIXEL(xx, yy) (((yy) * png->width + (xx)) * png->bpp)
1866 * in the source image that correspond to a single pixel in the target.
1867 * Use fixed-point arithmetic with 16-bits for each of the integer and
1870 const uint32_t wcstep = ((png->width - 1) << 16) / (fwidth - 1);
1871 const uint32_t hcstep = ((png->height - 1) << 16) / (fheight - 1);
1873 rs = 8 - (fls(gfx_state.tg_fb.fb_mask_red) -
1875 gs = 8 - (fls(gfx_state.tg_fb.fb_mask_green) -
1877 bs = 8 - (fls(gfx_state.tg_fb.fb_mask_blue) -
1883 uint32_t hc1 = 0x80 - hc2;
1891 uint32_t wc1 = 0x80 - wc2;
1901 r = png->image[i];
1902 g = png->image[i + 1];
1903 b = png->image[i + 2];
1904 a = png->image[i + 3];
1915 * image, combine them to produce a single
1930 * the >> 14 below is a quick way to divide by
1935 (png->image[p00 + i] * hc1 +
1936 png->image[p01 + i] * hc2) * wc1 +
1937 (png->image[p10 + i] * hc1 +
1938 png->image[p11 + i] * hc2) * wc2)
1968 * Reset font flags to FONT_AUTO.
1976 fl->font_flags = FONT_AUTO;
1989 w = edid_info->display.max_horizontal_image_size;
1990 h = edid_info->display.max_vertical_image_size;
2004 * translate cm to inch, note we scale by 100 here.
2072 if (next == NULL || next->font_data->vfbd_height < size) {
2073 font = fl->font_data;
2074 if (font->vfbd_font == NULL ||
2075 fl->font_flags == FONT_RELOAD) {
2076 if (fl->font_load != NULL &&
2077 fl->font_name != NULL)
2078 font = fl->font_load(fl->font_name);
2099 if (fl->font_flags == FONT_MANUAL) {
2100 font = fl->font_data;
2101 if (font->vfbd_font == NULL && fl->font_load != NULL &&
2102 fl->font_name != NULL) {
2103 font = fl->font_load(fl->font_name);
2105 if (font == NULL || font->vfbd_font == NULL)
2115 *rows = height / font->vfbd_height;
2116 *cols = width / font->vfbd_width;
2126 font = fl->font_data;
2127 if ((*rows * font->vfbd_height <= height &&
2128 *cols * font->vfbd_width <= width) ||
2131 font->vfbd_height == DEFAULT_FONT_DATA.vfbd_height &&
2132 font->vfbd_width == DEFAULT_FONT_DATA.vfbd_width)) {
2133 if (font->vfbd_font == NULL ||
2134 fl->font_flags == FONT_RELOAD) {
2135 if (fl->font_load != NULL &&
2136 fl->font_name != NULL) {
2137 font = fl->font_load(fl->font_name);
2142 *rows = height / font->vfbd_height;
2143 *cols = width / font->vfbd_width;
2152 * falling back to builtin.
2155 if (fl != NULL && fl->font_load != NULL &&
2156 fl->font_name != NULL) {
2157 font = fl->font_load(fl->font_name);
2162 *rows = height / font->vfbd_height;
2163 *cols = width / font->vfbd_width;
2176 gfx_state.tg_functions->tf_param(&gfx_state, TP_SHOWCURSOR, 0);
2183 teken_pos_t *tp = &state->tg_tp;
2192 * to fit on the screen.
2194 font_data = set_font(&tp->tp_row, &tp->tp_col, height, width);
2200 state->tg_font.vf_map[i] =
2201 font_data->vfbd_font->vf_map[i];
2202 state->tg_font.vf_map_count[i] =
2203 font_data->vfbd_font->vf_map_count[i];
2206 state->tg_font.vf_bytes = font_data->vfbd_font->vf_bytes;
2207 state->tg_font.vf_height = font_data->vfbd_font->vf_height;
2208 state->tg_font.vf_width = font_data->vfbd_font->vf_width;
2211 state->tg_font.vf_width, state->tg_font.vf_height);
2220 unsigned min, mid, max;
2223 max = len - 1;
2233 return (src - map[0].vfm_src + map[0].vfm_dst);
2240 mid = (min + max) / 2;
2241 if (src < map[mid].vfm_src)
2242 max = mid - 1;
2243 else if (src > map[mid].vfm_src + map[mid].vfm_len)
2244 min = mid + 1;
2246 return (src - map[mid].vfm_src + map[mid].vfm_dst);
2263 if (a->ta_format & TF_BOLD) {
2264 dst = font_bisearch(vf->vf_map[VFNT_MAP_BOLD],
2265 vf->vf_map_count[VFNT_MAP_BOLD], c);
2269 dst = font_bisearch(vf->vf_map[VFNT_MAP_NORMAL],
2270 vf->vf_map_count[VFNT_MAP_NORMAL], c);
2273 stride = howmany(vf->vf_width, 8) * vf->vf_height;
2274 return (&vf->vf_bytes[dst * stride]);
2284 if (fp->vf_map_count[n] == 0)
2287 size = fp->vf_map_count[n] * sizeof(*mp);
2291 fp->vf_map[n] = mp;
2295 free(fp->vf_map[n]);
2296 fp->vf_map[n] = NULL;
2300 for (i = 0; i < fp->vf_map_count[n]; i++) {
2317 if (fp->vf_map_count[n] == 0)
2320 size = fp->vf_map_count[n] * sizeof(*mp);
2324 fp->vf_map[n] = mp;
2326 memcpy(mp, DEFAULT_FONT_DATA.vfbd_font->vf_map[n], size);
2333 * are compressed and we do need to uncompress them.
2334 * Having single load_font() for both cases will help us to simplify
2351 if (strcmp(fl->font_name, path) == 0)
2357 bp = fl->font_data;
2358 if (bp->vfbd_font != NULL && fl->font_flags != FONT_RELOAD)
2361 fd = -1;
2365 * previous loads to be released.
2367 if (fl->font_flags == FONT_BUILTIN) {
2371 fp->vf_width = DEFAULT_FONT_DATA.vfbd_width;
2372 fp->vf_height = DEFAULT_FONT_DATA.vfbd_height;
2374 fp->vf_bytes = malloc(DEFAULT_FONT_DATA.vfbd_uncompressed_size);
2375 if (fp->vf_bytes == NULL) {
2380 bp->vfbd_uncompressed_size =
2382 bp->vfbd_compressed_size =
2386 fp->vf_bytes,
2389 free(fp->vf_bytes);
2395 fp->vf_map_count[i] =
2396 DEFAULT_FONT_DATA.vfbd_font->vf_map_count[i];
2401 bp->vfbd_font = fp;
2424 fp->vf_map_count[i] = be32toh(fh.fh_map_count[i]);
2427 fp->vf_width = fh.fh_width;
2428 fp->vf_height = fh.fh_height;
2430 size = howmany(fp->vf_width, 8) * fp->vf_height * glyphs;
2431 bp->vfbd_uncompressed_size = size;
2432 if ((fp->vf_bytes = malloc(size)) == NULL)
2435 rv = read(fd, fp->vf_bytes, size);
2446 if (fl->font_flags == FONT_BUILTIN)
2447 fl->font_flags = FONT_AUTO;
2453 * We do need to keep fl->font_data for glyph dimensions.
2456 if (fl->font_data->vfbd_font == NULL)
2460 free(fl->font_data->vfbd_font->vf_map[i]);
2461 free(fl->font_data->vfbd_font->vf_bytes);
2462 free(fl->font_data->vfbd_font);
2463 fl->font_data->vfbd_font = NULL;
2466 bp->vfbd_font = fp;
2467 bp->vfbd_compressed_size = 0;
2470 if (fd != -1)
2476 free(fp->vf_map[i]);
2477 free(fp->vf_bytes);
2541 if (asprintf(&np->n_name, "%s/%s", dir, buf) < 0) {
2573 * initial console. Since this will happen very early,
2574 * we assume asprintf will not fail. Once we have access to
2610 if (fh.fh_width == entry->font_data->vfbd_width &&
2611 fh.fh_height == entry->font_data->vfbd_height) {
2612 free(entry->font_name);
2613 entry->font_name = font_name;
2614 entry->font_flags = FONT_RELOAD;
2625 fp->font_data = calloc(sizeof(*fp->font_data), 1);
2626 if (fp->font_data == NULL) {
2631 fp->font_name = font_name;
2632 fp->font_flags = flags;
2633 fp->font_load = load_font;
2634 fp->font_data->vfbd_width = fh.fh_width;
2635 fp->font_data->vfbd_height = fh.fh_height;
2644 size = fp->font_data->vfbd_width * fp->font_data->vfbd_height;
2649 bd = entry->font_data;
2651 if (size > bd->vfbd_width * bd->vfbd_height) {
2663 size > next->font_data->vfbd_width *
2664 next->font_data->vfbd_height) {
2683 * Attempt to extract values from "XxY" string. In case of error,
2693 if (fl->font_data->vfbd_width == x &&
2694 fl->font_data->vfbd_height == y)
2702 fl->font_flags = FONT_MANUAL;
2709 printf(" %dx%d\n", fl->font_data->vfbd_width,
2710 fl->font_data->vfbd_height);
2739 if (insert_font(np->n_name, FONT_AUTO) == false)
2740 printf("failed to add font: %s\n", np->n_name);
2741 free(np->n_name);
2772 while ((c = getopt(argc, argv, "l")) != -1) {
2783 argc -= optind;
2787 printf("Usage: loadfont [-l] | [file.fnt]\n");
2793 printf("font %s: %dx%d%s\n", fl->font_name,
2794 fl->font_data->vfbd_width,
2795 fl->font_data->vfbd_height,
2796 fl->font_data->vfbd_font == NULL? "" : " loaded");
2808 printf("loadfont error: failed to load: %s\n", name);
2823 if (fl->font_data->vfbd_font != NULL) {
2825 bd = fl->font_data;
2831 free(bd->vfbd_font->vf_map[i]);
2832 free(fl->font_data->vfbd_font);
2833 fl->font_data->vfbd_font = NULL;
2834 fl->font_data->vfbd_uncompressed_size = 0;
2835 fl->font_flags = FONT_AUTO;
2851 if ((edid->display.supported_features
2858 if (edid->detailed_timings[i].pixel_clock == 0)
2862 rp->width = GET_EDID_INFO_WIDTH(edid, i);
2863 rp->height = GET_EDID_INFO_HEIGHT(edid, i);
2864 if (rp->width > 0 && rp->width <= EDID_MAX_PIXELS &&
2865 rp->height > 0 && rp->height <= EDID_MAX_LINES)
2877 if (edid->standard_timings[i] == 0x0101)
2883 rp->width = HSIZE(edid->standard_timings[i]);
2884 switch (RATIO(edid->standard_timings[i])) {
2886 rp->height = HSIZE(edid->standard_timings[i]);
2887 if (edid->header.version > 1 ||
2888 edid->header.revision > 2) {
2889 rp->height = rp->height * 10 / 16;
2893 rp->height = HSIZE(edid->standard_timings[i]) * 3 / 4;
2896 rp->height = HSIZE(edid->standard_timings[i]) * 4 / 5;
2899 rp->height = HSIZE(edid->standard_timings[i]) * 9 / 16;
2908 if (p->width * p->height < rp->width * rp->height) {
2951 if (gfx_state.tg_font.vf_width == fl->font_data->vfbd_width &&
2952 gfx_state.tg_font.vf_height == fl->font_data->vfbd_height) {
2956 if (fl->font_flags == FONT_BUILTIN)
2959 bd = fl->font_data;
2965 fd = bd->vfbd_font;
2967 fi.fi_width = fd->vf_width;
2969 fi.fi_height = fd->vf_height;
2971 fi.fi_bitmap_size = bd->vfbd_uncompressed_size;
2976 fi.fi_map_count[i] = fd->vf_map_count[i];
2978 size += fd->vf_map_count[i] * sizeof (struct vfnt_map);
2981 size += bd->vfbd_uncompressed_size;
2983 fi.fi_checksum = -checksum;
2997 if (fd->vf_map_count[i] != 0) {
2998 addr += archsw.arch_copyin(fd->vf_map[i], addr,
2999 fd->vf_map_count[i] * sizeof (struct vfnt_map));
3005 addr += archsw.arch_copyin(fd->vf_bytes, addr, fi.fi_bitmap_size);