diff options
author | Toomas Soome <tsoome@me.com> | 2020-12-05 22:37:28 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-12-10 20:57:57 +0200 |
commit | 34e16b78b1d2e5f513ee90af24e76d9703518b4c (patch) | |
tree | 8d1db6024e00d68d1c939b7f6791ca673f54f371 | |
parent | f2c438c5058c64b7373448f239156bf60009abcb (diff) | |
download | illumos-joyent-34e16b78b1d2e5f513ee90af24e76d9703518b4c.tar.gz |
13347 loader: gfx_fb_putimage 8 bit color translation is not good
Reviewed by: Jason King <jason.brian.king@gmail.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/common/gfx_fb.c | 61 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/i386/libi386/vbe.h | 1 | ||||
-rw-r--r-- | usr/src/boot/sys/boot/i386/libi386/vidconsole.c | 16 |
4 files changed, 59 insertions, 21 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index 5661e6deab..ed9e686dd8 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -34,4 +34,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2020.12.04.2 +BOOT_VERSION = $(LOADER_VERSION)-2020.12.05.0 diff --git a/usr/src/boot/sys/boot/common/gfx_fb.c b/usr/src/boot/sys/boot/common/gfx_fb.c index 94b9c71bef..361076fc2b 100644 --- a/usr/src/boot/sys/boot/common/gfx_fb.c +++ b/usr/src/boot/sys/boot/common/gfx_fb.c @@ -27,6 +27,7 @@ #include <efilib.h> #else #include <btxv86.h> +#include <vbe.h> #endif #include <sys/tem_impl.h> #include <sys/consplat.h> @@ -1205,7 +1206,7 @@ gfx_fb_putimage(png_t *png, uint32_t ux1, uint32_t uy1, uint32_t ux2, struct vis_consdisplay da; uint32_t i, j, x, y, fheight, fwidth, color; int fbpp; - uint8_t r, g, b, a, *p; + uint8_t r, g, b, a; bool scale = false; bool trace = false; @@ -1433,40 +1434,74 @@ gfx_fb_putimage(png_t *png, uint32_t ux1, uint32_t uy1, uint32_t ux2, << gfx_fb.u.fb2.framebuffer_blue_field_position; switch (gfx_fb.framebuffer_common.framebuffer_bpp) { +#if !defined(EFI) case 8: { uint32_t best, dist, k; int diff; + /* if alpha is 0, use screen bg color */ + if (a == 0) { + text_color_t fg, bg; + + tem_get_colors( + (tem_vt_state_t)tems.ts_active, + &fg, &bg); + da.data[j] = gfx_fb_color_map(bg); + break; + } + color = 0; - best = 256 * 256 * 256; - for (k = 0; k < 16; k++) { - diff = r - cmap4_to_24.red[k]; + best = CMAP_SIZE * CMAP_SIZE * CMAP_SIZE; + for (k = 0; k < CMAP_SIZE; k++) { + diff = r - pe8[k].Red; dist = diff * diff; - diff = g - cmap4_to_24.green[k]; + diff = g - pe8[k].Green; dist += diff * diff; - diff = b - cmap4_to_24.blue[k]; + diff = b - pe8[k].Blue; dist += diff * diff; + if (dist == 0) + break; + if (dist < best) { color = k; best = dist; - if (dist == 0) - break; } } - da.data[j] = solaris_color_to_pc_color[color]; + if (k == CMAP_SIZE) + k = color; + da.data[j] = (k < 16) ? + solaris_color_to_pc_color[k] : k; break; } case 15: case 16: + /* if alpha is 0, use screen bg color */ + if (a == 0) { + text_color_t fg, bg; + + tem_get_colors( + (tem_vt_state_t)tems.ts_active, + &fg, &bg); + color = gfx_fb_color_map(bg); + } *(uint16_t *)(da.data+j) = color; break; case 24: - p = (uint8_t *)&color; - da.data[j] = p[0]; - da.data[j+1] = p[1]; - da.data[j+2] = p[2]; + /* if alpha is 0, use screen bg color */ + if (a == 0) { + text_color_t fg, bg; + + tem_get_colors( + (tem_vt_state_t)tems.ts_active, + &fg, &bg); + color = gfx_fb_color_map(bg); + } + da.data[j] = ((uint8_t *)&color)[0]; + da.data[j + 1] = ((uint8_t *)&color)[1]; + da.data[j + 2] = ((uint8_t *)&color)[2]; break; +#endif case 32: color |= a << 24; *(uint32_t *)(da.data+j) = color; diff --git a/usr/src/boot/sys/boot/i386/libi386/vbe.h b/usr/src/boot/sys/boot/i386/libi386/vbe.h index 1a9ff770d1..c775b13012 100644 --- a/usr/src/boot/sys/boot/i386/libi386/vbe.h +++ b/usr/src/boot/sys/boot/i386/libi386/vbe.h @@ -142,6 +142,7 @@ struct flatpanelinfo #define CMAP_SIZE 256 /* Number of colors in palette */ +extern struct paletteentry pe8[CMAP_SIZE]; extern int palette_format; /* high-level VBE helpers, from vbe.c */ diff --git a/usr/src/boot/sys/boot/i386/libi386/vidconsole.c b/usr/src/boot/sys/boot/i386/libi386/vidconsole.c index a1eb1b37c9..9dff446903 100644 --- a/usr/src/boot/sys/boot/i386/libi386/vidconsole.c +++ b/usr/src/boot/sys/boot/i386/libi386/vidconsole.c @@ -78,6 +78,9 @@ static vis_modechg_cb_t modechg_cb; static struct vis_modechg_arg *modechg_arg; static tem_vt_state_t tem; +/* RGB colors for 8-bit depth */ +struct paletteentry pe8[CMAP_SIZE]; + #define KEYBUFSZ 10 #define DEFAULT_FGCOLOR 7 #define DEFAULT_BGCOLOR 0 @@ -542,7 +545,6 @@ static int vidc_vbe_cons_put_cmap(struct vis_cmap *cm) { int i, rc; - struct paletteentry pe; rgb_t rgb; uint32_t c; @@ -568,8 +570,6 @@ vidc_vbe_cons_put_cmap(struct vis_cmap *cm) rgb.blue.pos = gfx_fb.u.fb2.framebuffer_blue_field_position; rgb.blue.size = gfx_fb.u.fb2.framebuffer_blue_mask_size; - pe.Alignment = 0; - /* * The first 16 colors need to be in VGA color order. */ @@ -582,10 +582,12 @@ vidc_vbe_cons_put_cmap(struct vis_cmap *cm) } else { c = rgb_color_map(&rgb, i); } - pe.Red = (c >> rgb.red.pos) & ((1 << rgb.red.size) - 1); - pe.Green = (c >> rgb.green.pos) & ((1 << rgb.green.size) - 1); - pe.Blue = (c >> rgb.blue.pos) & ((1 << rgb.blue.size) - 1); - rc = vbe_set_palette(&pe, i); + pe8[i].Red = (c >> rgb.red.pos) & ((1 << rgb.red.size) - 1); + pe8[i].Green = + (c >> rgb.green.pos) & ((1 << rgb.green.size) - 1); + pe8[i].Blue = (c >> rgb.blue.pos) & ((1 << rgb.blue.size) - 1); + pe8[i].Alignment = 0; + rc = vbe_set_palette(&pe8[i], i); } return (rc); } |