diff options
author | Toomas Soome <tsoome@me.com> | 2018-12-03 13:53:41 -0800 |
---|---|---|
committer | Joshua M. Clulow <josh@sysmgr.org> | 2018-12-03 13:53:41 -0800 |
commit | 3e90f8d31de34a9f1efdf9484f999cca7149860d (patch) | |
tree | 2ccc3d74d77ab97e58c51c4fc451a9e04877af9b /usr | |
parent | fbbcb43d3dc65baeb851d4b368f233970b5b7098 (diff) | |
download | illumos-gate-3e90f8d31de34a9f1efdf9484f999cca7149860d.tar.gz |
9998 uts: font rendering should support 16/24/32bit depths
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/uts/common/font/font.c | 114 | ||||
-rw-r--r-- | usr/src/uts/common/io/tem_safe.c | 27 | ||||
-rw-r--r-- | usr/src/uts/common/sys/font.h | 8 |
3 files changed, 142 insertions, 7 deletions
diff --git a/usr/src/uts/common/font/font.c b/usr/src/uts/common/font/font.c index bd9bd2afa7..3b2525ca3b 100644 --- a/usr/src/uts/common/font/font.c +++ b/usr/src/uts/common/font/font.c @@ -211,7 +211,117 @@ font_bit_to_pix8( } /* - * bit_to_pix24 is for 24-bit frame buffers. It will write four output bytes + * bit_to_pix16 is for 16-bit frame buffers. It will write two output bytes + * for each bit of input bitmap. It inverts the input bits before + * doing the output translation, for reverse video. + * + * Assuming foreground is 11111111 11111111 + * and background is 00000000 00000000 + * An input data byte of 0x53 will output the bit pattern + * + * 00000000 00000000 + * 11111111 11111111 + * 00000000 00000000 + * 11111111 11111111 + * 00000000 00000000 + * 00000000 00000000 + * 11111111 11111111 + * 11111111 11111111 + * + */ + +void +font_bit_to_pix16( + struct font *f, + uint16_t *dest, + uint8_t c, + uint16_t fg_color16, + uint16_t bg_color16) +{ + int row; + int byte; + int i; + uint8_t *cp; + uint16_t data, d; + int bytes_wide; + int bitsleft, nbits; + + cp = f->char_ptr[c]; + bytes_wide = (f->width + 7) / 8; + + for (row = 0; row < f->height; row++) { + bitsleft = f->width; + for (byte = 0; byte < bytes_wide; byte++) { + data = *cp++; + nbits = MIN(8, bitsleft); + bitsleft -= nbits; + for (i = 0; i < nbits; i++) { + d = ((data << i) & 0x80 ? + fg_color16 : bg_color16); + *dest++ = d; + } + } + } +} + +/* + * bit_to_pix24 is for 24-bit frame buffers. It will write three output bytes + * for each bit of input bitmap. It inverts the input bits before + * doing the output translation, for reverse video. + * + * Assuming foreground is 11111111 11111111 11111111 + * and background is 00000000 00000000 00000000 + * An input data byte of 0x53 will output the bit pattern + * + * 00000000 00000000 00000000 + * 11111111 11111111 11111111 + * 00000000 00000000 00000000 + * 11111111 11111111 11111111 + * 00000000 00000000 00000000 + * 00000000 00000000 00000000 + * 11111111 11111111 11111111 + * 11111111 11111111 11111111 + * + */ + +void +font_bit_to_pix24( + struct font *f, + uint8_t *dest, + uint8_t c, + uint32_t fg_color32, + uint32_t bg_color32) +{ + int row; + int byte; + int i; + uint8_t *cp; + uint32_t data, d; + int bytes_wide; + int bitsleft, nbits; + + cp = f->char_ptr[c]; + bytes_wide = (f->width + 7) / 8; + + for (row = 0; row < f->height; row++) { + bitsleft = f->width; + for (byte = 0; byte < bytes_wide; byte++) { + data = *cp++; + nbits = MIN(8, bitsleft); + bitsleft -= nbits; + for (i = 0; i < nbits; i++) { + d = ((data << i) & 0x80 ? + fg_color32 : bg_color32); + *dest++ = d & 0xff; + *dest++ = (d >> 8) & 0xff; + *dest++ = (d >> 16) & 0xff; + } + } + } +} + +/* + * bit_to_pix32 is for 32-bit frame buffers. It will write four output bytes * for each bit of input bitmap. It inverts the input bits before * doing the output translation, for reverse video. Note that each * 24-bit RGB value is finally stored in a 32-bit unsigned int, with the @@ -233,7 +343,7 @@ font_bit_to_pix8( */ void -font_bit_to_pix24( +font_bit_to_pix32( struct font *f, uint32_t *dest, uint8_t c, diff --git a/usr/src/uts/common/io/tem_safe.c b/usr/src/uts/common/io/tem_safe.c index 0312884465..60ff789fb3 100644 --- a/usr/src/uts/common/io/tem_safe.c +++ b/usr/src/uts/common/io/tem_safe.c @@ -153,6 +153,8 @@ static void bit_to_pix8(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color, text_color_t bg_color); static void bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color, text_color_t bg_color); +static void bit_to_pix32(struct tem_vt_state *tem, uchar_t c, + text_color_t fg_color, text_color_t bg_color); /* BEGIN CSTYLED */ /* Bk Rd Gr Br Bl Mg Cy Wh */ @@ -1601,8 +1603,13 @@ tem_safe_pix_bit2pix(struct tem_vt_state *tem, unsigned char c, fp = bit_to_pix8; break; case 24: - case 32: fp = bit_to_pix24; + break; + case 32: + fp = bit_to_pix32; + break; + default: + return; } fp(tem, c, fg, bg); @@ -2067,6 +2074,22 @@ static void bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, text_color_t bg_color4) { + uint32_t fg_color32, bg_color32; + uint8_t *dest; + + ASSERT(fg_color4 < 16 && bg_color4 < 16); + + fg_color32 = PIX4TO32(fg_color4); + bg_color32 = PIX4TO32(bg_color4); + + dest = (uint8_t *)tem->tvs_pix_data; + font_bit_to_pix24(&tems.ts_font, dest, c, fg_color32, bg_color32); +} + +static void +bit_to_pix32(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, + text_color_t bg_color4) +{ uint32_t fg_color32, bg_color32, *dest; ASSERT(fg_color4 < 16 && bg_color4 < 16); @@ -2075,7 +2098,7 @@ bit_to_pix24(struct tem_vt_state *tem, uchar_t c, text_color_t fg_color4, bg_color32 = PIX4TO32(bg_color4); dest = (uint32_t *)tem->tvs_pix_data; - font_bit_to_pix24(&tems.ts_font, dest, c, fg_color32, bg_color32); + font_bit_to_pix32(&tems.ts_font, dest, c, fg_color32, bg_color32); } static text_color_t diff --git a/usr/src/uts/common/sys/font.h b/usr/src/uts/common/sys/font.h index c4de4e9ddf..3467af6796 100644 --- a/usr/src/uts/common/sys/font.h +++ b/usr/src/uts/common/sys/font.h @@ -71,9 +71,11 @@ extern bitmap_data_t font_data_7x14; extern bitmap_data_t font_data_6x10; void set_font(struct font *, short *, short *, short, short); -void font_bit_to_pix4(struct font *, uint8_t *, uchar_t, uint8_t, uint8_t); -void font_bit_to_pix8(struct font *, uint8_t *, uchar_t, uint8_t, uint8_t); -void font_bit_to_pix24(struct font *, uint32_t *, uchar_t, uint32_t, uint32_t); +void font_bit_to_pix4(struct font *, uint8_t *, uint8_t, uint8_t, uint8_t); +void font_bit_to_pix8(struct font *, uint8_t *, uint8_t, uint8_t, uint8_t); +void font_bit_to_pix16(struct font *, uint16_t *, uint8_t, uint16_t, uint16_t); +void font_bit_to_pix24(struct font *, uint8_t *, uint8_t, uint32_t, uint32_t); +void font_bit_to_pix32(struct font *, uint32_t *, uint8_t, uint32_t, uint32_t); #ifdef __cplusplus } |