Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ui/vc: drop have_text
If there are no "text" listener, the callback will simply be ignored.
The rest of text handling can be done cheaply.

This allows to remove some dependency on DisplayState from VC
implementation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230830093843.3531473-6-marcandre.lureau@redhat.com>
  • Loading branch information
elmarco authored and Patchew Applier committed Sep 1, 2023
1 parent f1f7a1e commit 1774227
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions ui/console.c
Expand Up @@ -133,7 +133,6 @@ struct DisplayState {
uint64_t update_interval;
bool refreshing;
bool have_gfx;
bool have_text;

QLIST_HEAD(, DisplayChangeListener) listeners;
};
Expand Down Expand Up @@ -185,7 +184,6 @@ static void gui_setup_refresh(DisplayState *ds)
DisplayChangeListener *dcl;
bool need_timer = false;
bool have_gfx = false;
bool have_text = false;

QLIST_FOREACH(dcl, &ds->listeners, next) {
if (dcl->ops->dpy_refresh != NULL) {
Expand All @@ -194,9 +192,6 @@ static void gui_setup_refresh(DisplayState *ds)
if (dcl->ops->dpy_gfx_update != NULL) {
have_gfx = true;
}
if (dcl->ops->dpy_text_update != NULL) {
have_text = true;
}
}

if (need_timer && ds->gui_timer == NULL) {
Expand All @@ -209,7 +204,6 @@ static void gui_setup_refresh(DisplayState *ds)
}

ds->have_gfx = have_gfx;
ds->have_text = have_text;
}

void graphic_hw_update_done(QemuConsole *con)
Expand Down Expand Up @@ -456,9 +450,7 @@ static void update_xy(QemuConsole *s, int x, int y)
TextCell *c;
int y1, y2;

if (s->ds->have_text) {
text_update_xy(s, x, y);
}
text_update_xy(s, x, y);

y1 = (s->y_base + y) % s->total_height;
y2 = y1 - s->y_displayed;
Expand All @@ -482,9 +474,7 @@ static void console_show_cursor(QemuConsole *s, int show)
int y, y1;
int x = s->x;

if (s->ds->have_text) {
s->cursor_invalidate = 1;
}
s->cursor_invalidate = 1;

if (x >= s->width) {
x = s->width - 1;
Expand Down Expand Up @@ -513,13 +503,11 @@ static void console_refresh(QemuConsole *s)
TextCell *c;
int x, y, y1;

if (s->ds->have_text) {
s->text_x[0] = 0;
s->text_y[0] = 0;
s->text_x[1] = s->width - 1;
s->text_y[1] = s->height - 1;
s->cursor_invalidate = 1;
}
s->text_x[0] = 0;
s->text_y[0] = 0;
s->text_x[1] = s->width - 1;
s->text_y[1] = s->height - 1;
s->cursor_invalidate = 1;

vga_fill_rect(s, 0, 0, surface_width(surface), surface_height(surface),
color_table_rgb[0][QEMU_COLOR_BLACK]);
Expand Down Expand Up @@ -594,12 +582,10 @@ static void console_put_lf(QemuConsole *s)
c++;
}
if (s->y_displayed == s->y_base) {
if (s->ds->have_text) {
s->text_x[0] = 0;
s->text_y[0] = 0;
s->text_x[1] = s->width - 1;
s->text_y[1] = s->height - 1;
}
s->text_x[0] = 0;
s->text_y[0] = 0;
s->text_x[1] = s->width - 1;
s->text_y[1] = s->height - 1;

vga_bitblt(s, 0, FONT_HEIGHT, 0, 0,
s->width * FONT_WIDTH,
Expand Down Expand Up @@ -1069,9 +1055,7 @@ void console_select(unsigned int index)
displaychangelistener_display_console(dcl, s, NULL);
}
}
if (ds->have_text) {
dpy_text_resize(s, s->width, s->height);
}
dpy_text_resize(s, s->width, s->height);
text_console_update_cursor(NULL);
}
}
Expand Down Expand Up @@ -1239,7 +1223,7 @@ static void text_console_invalidate(void *opaque)
{
QemuConsole *s = (QemuConsole *) opaque;

if (s->ds->have_text && s->console_type == TEXT_CONSOLE) {
if (s->console_type == TEXT_CONSOLE) {
text_console_resize(s);
}
console_refresh(s);
Expand Down

0 comments on commit 1774227

Please sign in to comment.