ui/console-vc: set vt100 associated pixman image
Start removing dependency on DisplaySurface for vt100 handling. Note that before, the rendering is done on the current DisplaySurface. It's not obvious the QemuTextConsole associated surface isn't changed over time, in particular if it was doing resize. But qemu_console_resize() is only implemented for QemuGraphicConsole. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Feb 19, 2026 at 11:37 UTC
62fe54d284f25daafeaa0625e2451f5bcc69ff0d
1 file changed
+25
-29
ui/console-vc.c
+25
-29
@@ -48,6 +48,8 @@ enum TTYState {
48
};
49
50
typedef struct QemuVT100 {
51
+ pixman_image_t *image;
52
+
53
int width;
54
int height;
55
int total_height;
@@ -133,28 +135,22 @@ qemu_text_console_get_label(const QemuConsole *c)
135
return tc->chr ? g_strdup(tc->chr->label) : NULL;
136
}
137
136
-static void qemu_console_fill_rect(QemuConsole *con, int posx, int posy,
137
- int width, int height, pixman_color_t color)
138
+static void image_fill_rect(pixman_image_t *image, int posx, int posy,
139
+ int width, int height, pixman_color_t color)
140
{
139
- DisplaySurface *surface = qemu_console_surface(con);
141
pixman_rectangle16_t rect = {
142
.x = posx, .y = posy, .width = width, .height = height
143
};
144
144
- assert(surface);
145
- pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface->image,
146
- &color, 1, &rect);
145
+ pixman_image_fill_rectangles(PIXMAN_OP_SRC, image, &color, 1, &rect);
146
}
147
148
/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */
150
-static void qemu_console_bitblt(QemuConsole *con,
151
- int xs, int ys, int xd, int yd, int w, int h)
149
+static void image_bitblt(pixman_image_t *image,
150
+ int xs, int ys, int xd, int yd, int w, int h)
151
{
153
- DisplaySurface *surface = qemu_console_surface(con);
154
-
155
- assert(surface);
152
pixman_image_composite(PIXMAN_OP_SRC,
157
- surface->image, NULL, surface->image,
153
+ image, NULL, image,
154
xs, ys, 0, 0, xd, yd, w, h);
155
}
156
@@ -162,10 +158,10 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, int ch,
158
TextAttributes *t_attrib)
159
{
160
static pixman_image_t *glyphs[256];
165
- DisplaySurface *surface = qemu_console_surface(s);
161
+ pixman_image_t *image = QEMU_TEXT_CONSOLE(s)->vt.image;
162
pixman_color_t fgcol, bgcol;
163
168
- assert(surface);
164
+ assert(image);
165
if (t_attrib->invers) {
166
bgcol = color_table_rgb[t_attrib->bold][t_attrib->fgcol];
167
fgcol = color_table_rgb[t_attrib->bold][t_attrib->bgcol];
@@ -177,7 +173,7 @@ static void vga_putcharxy(QemuConsole *s, int x, int y, int ch,
173
if (!glyphs[ch]) {
174
glyphs[ch] = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, ch);
175
}
180
- qemu_pixman_glyph_render(glyphs[ch], surface->image,
176
+ qemu_pixman_glyph_render(glyphs[ch], image,
177
&fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT);
178
}
179
@@ -230,20 +226,20 @@ static void console_show_cursor(QemuTextConsole *s, int show)
226
227
static void console_refresh(QemuTextConsole *s)
228
{
233
- DisplaySurface *surface = qemu_console_surface(QEMU_CONSOLE(s));
229
QemuVT100 *vt = &s->vt;
230
TextCell *c;
231
int x, y, y1;
232
+ int w = pixman_image_get_width(vt->image);
233
+ int h = pixman_image_get_height(vt->image);
234
238
- assert(surface);
235
vt->text_x[0] = 0;
236
vt->text_y[0] = 0;
237
vt->text_x[1] = vt->width - 1;
238
vt->text_y[1] = vt->height - 1;
239
vt->cursor_invalidate = 1;
240
245
- qemu_console_fill_rect(QEMU_CONSOLE(s), 0, 0, surface_width(surface), surface_height(surface),
246
- color_table_rgb[0][QEMU_COLOR_BLACK]);
241
+ image_fill_rect(vt->image, 0, 0, w, h,
242
+ color_table_rgb[0][QEMU_COLOR_BLACK]);
243
y1 = vt->y_displayed;
244
for (y = 0; y < vt->height; y++) {
245
c = vt->cells + y1 * vt->width;
@@ -257,8 +253,7 @@ static void console_refresh(QemuTextConsole *s)
253
}
254
}
255
console_show_cursor(s, 1);
260
- dpy_gfx_update(QEMU_CONSOLE(s), 0, 0,
261
- surface_width(surface), surface_height(surface));
256
+ dpy_gfx_update(QEMU_CONSOLE(s), 0, 0, w, h);
257
}
258
259
static void console_scroll(QemuTextConsole *s, int ydelta)
@@ -398,8 +393,9 @@ static void text_console_resize(QemuTextConsole *t)
393
394
assert(s->scanout.kind == SCANOUT_SURFACE);
395
401
- w = surface_width(s->surface) / FONT_WIDTH;
402
- h = surface_height(s->surface) / FONT_HEIGHT;
396
+ t->vt.image = s->surface->image;
397
+ w = pixman_image_get_width(t->vt.image) / FONT_WIDTH;
398
+ h = pixman_image_get_height(t->vt.image) / FONT_HEIGHT;
399
if (w == t->vt.width && h == t->vt.height) {
400
return;
401
}
@@ -461,12 +457,12 @@ static void vc_put_lf(VCChardev *vc)
457
vt->text_x[1] = vt->width - 1;
458
vt->text_y[1] = vt->height - 1;
459
464
- qemu_console_bitblt(QEMU_CONSOLE(s), 0, FONT_HEIGHT, 0, 0,
465
- vt->width * FONT_WIDTH,
466
- (vt->height - 1) * FONT_HEIGHT);
467
- qemu_console_fill_rect(QEMU_CONSOLE(s), 0, (vt->height - 1) * FONT_HEIGHT,
468
- vt->width * FONT_WIDTH, FONT_HEIGHT,
469
- color_table_rgb[0][TEXT_ATTRIBUTES_DEFAULT.bgcol]);
460
+ image_bitblt(vt->image, 0, FONT_HEIGHT, 0, 0,
461
+ vt->width * FONT_WIDTH,
462
+ (vt->height - 1) * FONT_HEIGHT);
463
+ image_fill_rect(vt->image, 0, (vt->height - 1) * FONT_HEIGHT,
464
+ vt->width * FONT_WIDTH, FONT_HEIGHT,
465
+ color_table_rgb[0][TEXT_ATTRIBUTES_DEFAULT.bgcol]);
466
vt->update_x0 = 0;
467
vt->update_y0 = 0;
468
vt->update_x1 = vt->width * FONT_WIDTH;