From: Adam Borowski <kilobyte@angband.pl>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>,
linux-console@vger.kernel.org,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Adam Borowski <kilobyte@angband.pl>
Subject: [PATCH 6/6] vt: support bright backgrounds for \e[48m if unblinking
Date: Wed, 18 Jul 2018 05:03:27 +0200 [thread overview]
Message-ID: <20180718030327.579-6-kilobyte@angband.pl> (raw)
In-Reply-To: <20180718030327.579-1-kilobyte@angband.pl>
This improves schemes used by fancy new programs. For example, it lets
bright powerline segments match, and fixes images shown by catimg being
striped to the point of unreadability.
Handling of 8-color backgrounds uses stripped 16-color value instead of a
dedicated formula; this works worse for dark and better for bright inputs.
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
drivers/tty/vt/vt.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index c777f4c91df0..7fcb0ff2dccf 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1555,7 +1555,7 @@ static void rgb_from_256(int i, struct rgb *c)
c->r = c->g = c->b = i * 10 - 2312;
}
-static void rgb_foreground(struct vc_data *vc, const struct rgb *c)
+static u8 rgb_to_16(const struct rgb *c)
{
u8 hue = 0, max = max3(c->r, c->g, c->b);
@@ -1566,22 +1566,12 @@ static void rgb_foreground(struct vc_data *vc, const struct rgb *c)
if (c->b > max / 2 + 32)
hue |= 1;
- if (hue == 7 && max <= 0x70) {
- hue = 0;
- vc->vc_intensity = 2;
- } else if (max > 0xc0)
- vc->vc_intensity = 2;
+ if (hue == 7 && max <= 0x70)
+ return 8;
+ if (max > 0xc0)
+ return hue | 8;
else
- vc->vc_intensity = 1;
-
- vc->vc_color = (vc->vc_color & 0xf0) | hue;
-}
-
-static void rgb_background(struct vc_data *vc, const struct rgb *c)
-{
- /* For backgrounds, err on the dark side. */
- vc->vc_color = (vc->vc_color & 0x0f)
- | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3;
+ return hue;
}
/*
@@ -1593,10 +1583,10 @@ static void rgb_background(struct vc_data *vc, const struct rgb *c)
* Subcommands 3 (CMY) and 4 (CMYK) are so insane there's no point in
* supporting them.
*/
-static int vc_t416_color(struct vc_data *vc, int i,
- void(*set_color)(struct vc_data *vc, const struct rgb *c))
+static int vc_t416_color(struct vc_data *vc, int i, int bgshift)
{
struct rgb c;
+ u8 v;
i++;
if (i > vc->vc_npar)
@@ -1615,7 +1605,13 @@ static int vc_t416_color(struct vc_data *vc, int i,
} else
return i;
- set_color(vc, &c);
+ v = rgb_to_16(&c);
+
+ vc->vc_color = (vc->vc_color & (0xf0 >> bgshift)) | v << bgshift;
+ if (!bgshift)
+ vc->vc_intensity = (v & 8 >> 4) + 1;
+ else if (vc->vc_unblinking)
+ vc->vc_blink = v & 8 >> 4;
return i;
}
@@ -1695,10 +1691,10 @@ static void csi_m(struct vc_data *vc)
vc->vc_reverse = 0;
break;
case 38:
- i = vc_t416_color(vc, i, rgb_foreground);
+ i = vc_t416_color(vc, i, 0);
break;
case 48:
- i = vc_t416_color(vc, i, rgb_background);
+ i = vc_t416_color(vc, i, 4);
break;
case 39:
vc->vc_color = (vc->vc_def_color & 0x0f) |
--
2.18.0
next prev parent reply other threads:[~2018-07-18 3:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-18 3:01 [PATCH 0/6] vt: no blinking on console, 256/24-bit color improvements Adam Borowski
2018-07-18 3:03 ` [PATCH 1/6] vt: drop unused struct vt_struct Adam Borowski
2018-07-18 3:03 ` [PATCH 2/6] vt: add console flag "unblinking" Adam Borowski
2018-07-18 3:03 ` [PATCH 3/6] vt: let \e[100m use bright background if unblinking Adam Borowski
2018-07-18 3:03 ` [PATCH 4/6] vt: change 256-color palette to match all(?) modern terminals Adam Borowski
2018-07-18 3:03 ` [PATCH 5/6] vt: compensate for brightening the 256-color palette Adam Borowski
2018-07-18 3:03 ` Adam Borowski [this message]
2018-07-19 10:47 ` [PATCH 0/6] vt: no blinking on console, 256/24-bit color improvements Alan Cox
2018-07-19 14:28 ` Adam Borowski
2018-07-19 14:34 ` Geert Uytterhoeven
2018-07-21 7:43 ` Greg Kroah-Hartman
2018-07-21 21:38 ` Adam Borowski
2018-07-23 8:53 ` Geert Uytterhoeven
2018-07-23 10:41 ` Adam Borowski
2018-07-23 11:07 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180718030327.579-6-kilobyte@angband.pl \
--to=kilobyte@angband.pl \
--cc=b.zolnierkie@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-console@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox