From 1370fa3380676f7d545aa221637c15abb3398058 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Mon, 27 Mar 2017 10:48:28 +0000 Subject: [PATCH] Oops, my fix for bright colors broke bright black some more (in cases that used to work via the bold hack). Fix the table entry for bright black. Fix spelling of plain black in nearby table entries (use the macro for black everywhere everywhere). Fix the currently-unused non-bright color table to not have bright colors in entries 9-15. Improve nearby comments. Start converting to the xterm terminology and default rendering of "bright" instead of "light" for bright colors. Syscons wasn't affected by the bug since I optimized it a little by converting colors 0-15 directly. This also fixes the layering of the conversion for these colors. Apply the same optimization to vt (actually the layer above it). This also moves the conversion 1 closer to the correct layer for colors 0-15. The optimization of just avoiding 2 calls to a trivial function is worth about 10% for simple output to the virtual buffer with occasional rendering. The optimization is so large because the 2 calls are done on every character, so although there are too many other calls and other instructions per character, there are only about 10 times as many. Old versions of syscons were about 10 times faster for simple output, by using a fast path with about 12 instructions per character. Rendering to even slow hardware takes relatively little time provided it is rarely actually done. --- sys/kern/subr_terminal.c | 13 +++++++++++-- sys/teken/teken.c | 16 ++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/sys/kern/subr_terminal.c b/sys/kern/subr_terminal.c index 9f7f95856b7a..484408e980a3 100644 --- a/sys/kern/subr_terminal.c +++ b/sys/kern/subr_terminal.c @@ -146,9 +146,18 @@ static const teken_attr_t default_message = { TCOLOR_BG(_c & 7) | ((_c & 8) << 20); \ }) +#define TCOLOR_256TO16(color) __extension__ ({ \ + teken_color_t _c; \ + \ + _c = (color); \ + if (_c >= 16) \ + _c = teken_256to16(_c); \ + _c; \ +}) + #define TCHAR_CREATE(c, a) ((c) | TFORMAT((a)->ta_format) | \ - TCOLOR_FG_FUDGED(teken_256to16((a)->ta_fgcolor)) | \ - TCOLOR_BG_FUDGED(teken_256to16((a)->ta_bgcolor))) + TCOLOR_FG_FUDGED(TCOLOR_256TO16((a)->ta_fgcolor)) | \ + TCOLOR_BG_FUDGED(TCOLOR_256TO16((a)->ta_bgcolor))) static void terminal_init(struct terminal *tm) diff --git a/sys/teken/teken.c b/sys/teken/teken.c index 6a9842d53848..5a8177762be8 100644 --- a/sys/teken/teken.c +++ b/sys/teken/teken.c @@ -491,11 +491,11 @@ teken_state_numbers(teken_t *t, teken_char_t c) * be twice as large as green in (0, 1, 2). */ static const teken_color_t teken_256to8tab[] = { - /* xterm-16+ 8 dark colors: */ - 0, r, g, y, b, m, c, w, + /* xterm normal colors: */ + k, r, g, y, b, m, c, w, - /* xterm-16+ 8 light colors: */ - 0, R, G, Y, B, M, C, W, + /* xterm bright colors: */ + k, r, g, y, b, m, c, w, /* Red0 submap. */ k, b, b, b, b, b, @@ -559,11 +559,11 @@ static const teken_color_t teken_256to8tab[] = { * used for different fine tuning of the tables. */ static const teken_color_t teken_256to16tab[] = { - /* xterm-16+ 8 dark colors: */ - 0, r, g, y, b, m, c, w, + /* xterm normal colors: */ + k, r, g, y, b, m, c, w, - /* xterm-16+ 8 light colors: */ - 0, R, G, Y, B, M, C, W, + /* xterm bright colors: */ + K, R, G, Y, B, M, C, W, /* Red0 submap. */ k, b, b, b, b, b,