From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 17/18] console: zap color_table
Date: Tue, 12 Mar 2013 11:32:48 +0100 [thread overview]
Message-ID: <1363084369-27517-18-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1363084369-27517-1-git-send-email-kraxel@redhat.com>
qemu_create_surface hands out 32bpp surfaces.
So we can just use color_table_rgb directly.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/console.c | 83 +++++-----------------------------------------------------
1 file changed, 6 insertions(+), 77 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index e1a5dd1..d98d510 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -208,42 +208,6 @@ void vga_hw_text_update(console_ch_t *chardata)
active_console->hw_text_update(active_console->hw, chardata);
}
-/* convert a RGBA color to a color index usable in graphic primitives */
-static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
-{
- unsigned int r, g, b, color;
-
- switch(ds_get_bits_per_pixel(ds)) {
-#if 0
- case 8:
- r = (rgba >> 16) & 0xff;
- g = (rgba >> 8) & 0xff;
- b = (rgba) & 0xff;
- color = (rgb_to_index[r] * 6 * 6) +
- (rgb_to_index[g] * 6) +
- (rgb_to_index[b]);
- break;
-#endif
- case 15:
- r = (rgba >> 16) & 0xff;
- g = (rgba >> 8) & 0xff;
- b = (rgba) & 0xff;
- color = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
- break;
- case 16:
- r = (rgba >> 16) & 0xff;
- g = (rgba >> 8) & 0xff;
- b = (rgba) & 0xff;
- color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
- break;
- case 32:
- default:
- color = rgba;
- break;
- }
- return color;
-}
-
static void vga_fill_rect (DisplayState *ds,
int posx, int posy, int width, int height, uint32_t color)
{
@@ -358,8 +322,6 @@ static const uint32_t dmask4[4] = {
PAT(0xffffffff),
};
-static uint32_t color_table[2][8];
-
#ifndef CONFIG_CURSES
enum color_names {
COLOR_BLACK = 0,
@@ -396,23 +358,6 @@ static const uint32_t color_table_rgb[2][8] = {
}
};
-static inline unsigned int col_expand(DisplayState *ds, unsigned int col)
-{
- switch(ds_get_bits_per_pixel(ds)) {
- case 8:
- col |= col << 8;
- col |= col << 16;
- break;
- case 15:
- case 16:
- col |= col << 16;
- break;
- default:
- break;
- }
-
- return col;
-}
#ifdef DEBUG_CONSOLE
static void console_print_text_attributes(TextAttributes *t_attrib, char ch)
{
@@ -461,11 +406,11 @@ static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
#endif
if (t_attrib->invers) {
- bgcol = color_table[t_attrib->bold][t_attrib->fgcol];
- fgcol = color_table[t_attrib->bold][t_attrib->bgcol];
+ bgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol];
+ fgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol];
} else {
- fgcol = color_table[t_attrib->bold][t_attrib->fgcol];
- bgcol = color_table[t_attrib->bold][t_attrib->bgcol];
+ fgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol];
+ bgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol];
}
bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
@@ -650,7 +595,7 @@ static void console_refresh(QemuConsole *s)
if (s->ds->have_gfx) {
vga_fill_rect(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds),
- color_table[0][COLOR_BLACK]);
+ color_table_rgb[0][COLOR_BLACK]);
y1 = s->y_displayed;
for (y = 0; y < s->height; y++) {
c = s->cells + y1 * s->width;
@@ -740,7 +685,7 @@ static void console_put_lf(QemuConsole *s)
(s->height - 1) * FONT_HEIGHT);
vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT,
s->width * FONT_WIDTH, FONT_HEIGHT,
- color_table[0][s->t_attrib_default.bgcol]);
+ color_table_rgb[0][s->t_attrib_default.bgcol]);
s->update_x0 = 0;
s->update_y0 = 0;
s->update_x1 = s->width * FONT_WIDTH;
@@ -1570,17 +1515,6 @@ int is_fixedsize_console(void)
return active_console && active_console->console_type != TEXT_CONSOLE;
}
-void console_color_init(DisplayState *ds)
-{
- int i, j;
- for (j = 0; j < 2; j++) {
- for (i = 0; i < 8; i++) {
- color_table[j][i] = col_expand(ds,
- vga_get_color(ds, color_table_rgb[j][i]));
- }
- }
-}
-
static void text_console_set_echo(CharDriverState *chr, bool echo)
{
QemuConsole *s = chr->opaque;
@@ -1601,7 +1535,6 @@ static void text_console_update_cursor(void *opaque)
static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
{
QemuConsole *s;
- static int color_inited;
s = chr->opaque;
@@ -1612,10 +1545,6 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
s->kbd_timer = qemu_new_timer_ms(rt_clock, kbd_send_chars, s);
s->ds = ds;
- if (!color_inited) {
- color_inited = 1;
- console_color_init(s->ds);
- }
s->y_displayed = 0;
s->y_base = 0;
s->total_height = DEFAULT_BACKSCROLL;
--
1.7.9.7
next prev parent reply other threads:[~2013-03-12 10:41 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 10:32 [Qemu-devel] [PATCH 00/18] console: data structures overhaul Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 01/18] console: fix displaychangelisteners interface Gerd Hoffmann
2013-03-18 17:49 ` Niel van der Westhuizen
2013-03-18 18:00 ` Peter Maydell
2013-03-12 10:32 ` [Qemu-devel] [PATCH 02/18] console: kill DisplayState->opaque Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 03/18] spice: zap sdpy global Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 04/18] qxl: zap qxl0 global Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 05/18] qxl: better vga init in enter_vga_mode Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 06/18] sdl: drop dead code Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 07/18] console: rework DisplaySurface handling [vga emu side] Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 08/18] console: rework DisplaySurface handling [dcl/ui side] Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 09/18] console: add surface_*() getters Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 10/18] gtk: stop using DisplayState Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 11/18] vnc: " Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 12/18] sdl: " Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 13/18] spice: " Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 14/18] cocoa: " Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 15/18] console: zap displaystate from dcl callbacks Gerd Hoffmann
2013-03-12 10:32 ` [Qemu-devel] [PATCH 16/18] console: stop using DisplayState in gfx hardware emulation Gerd Hoffmann
2013-03-25 7:50 ` Jan Kiszka
2013-03-25 7:55 ` Gerd Hoffmann
2013-03-25 7:59 ` Jan Kiszka
2013-03-25 8:21 ` Gerd Hoffmann
2013-03-25 8:28 ` Jan Kiszka
2013-03-25 8:39 ` Gerd Hoffmann
2013-03-25 8:40 ` Jan Kiszka
2013-03-25 9:10 ` Gerd Hoffmann
2013-03-25 9:32 ` Jan Kiszka
2013-03-25 9:48 ` Gerd Hoffmann
2013-03-25 9:55 ` Jan Kiszka
2013-03-25 10:00 ` Jan Kiszka
2013-03-25 10:37 ` Gerd Hoffmann
[not found] ` <5150572D.6090201@gmail.com>
2013-03-25 13:56 ` Igor Mitsyanko
2013-03-25 20:30 ` Gerd Hoffmann
2013-03-26 0:02 ` BALATON Zoltan
2013-03-26 8:26 ` Jan Kiszka
2013-04-03 11:50 ` Gerd Hoffmann
2013-04-10 8:31 ` Jan Kiszka
2013-04-16 7:42 ` Gerd Hoffmann
2013-04-20 14:04 ` Jan Kiszka
2013-03-12 10:32 ` Gerd Hoffmann [this message]
2013-03-12 10:32 ` [Qemu-devel] [PATCH 18/18] console: remove ds_get_* helper functions Gerd Hoffmann
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=1363084369-27517-18-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).