From bc820db0647040be38e693e0ca14fd49d8cf51ed Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 25 May 2018 06:53:44 +0200 Subject: [PATCH 1/2] bochs-display: add missing break MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: CID 1391291 Signed-off-by: Gerd Hoffmann Reviewed-by: Ján Tomko Reviewed-by: Philippe Mathieu-Daudé Message-id: 20180525045344.28347-1-kraxel@redhat.com --- hw/display/bochs-display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c index c33524b558..1187d77576 100644 --- a/hw/display/bochs-display.c +++ b/hw/display/bochs-display.c @@ -158,6 +158,7 @@ static int bochs_display_get_mode(BochsDisplayState *s, /* best effort: support native endianess only */ mode->format = PIXMAN_r5g6b5; mode->bytepp = 2; + break; case 32: mode->format = s->big_endian_fb ? PIXMAN_BE_x8r8g8b8 From 6bc2fd57e1fc2d1957d1ff952793c53764130218 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 25 May 2018 15:13:18 +0200 Subject: [PATCH 2/2] vga: cleanup surface handling Just set the full_update flag if we need a new DisplaySurface. Create a new surface when the flag is set instead of having two places where qemu_create_displaysurface_from() is called. Signed-off-by: Gerd Hoffmann Message-id: 20180525131318.28437-1-kraxel@redhat.com --- hw/display/vga.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index a7794f6d1f..ed476e4e80 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1548,12 +1548,31 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) } else { share_surface = false; } + if (s->line_offset != s->last_line_offset || disp_width != s->last_width || height != s->last_height || s->last_depth != depth || s->last_byteswap != byteswap || share_surface != is_buffer_shared(surface)) { + /* display parameters changed -> need new display surface */ + s->last_scr_width = disp_width; + s->last_scr_height = height; + s->last_width = disp_width; + s->last_height = height; + s->last_line_offset = s->line_offset; + s->last_depth = depth; + s->last_byteswap = byteswap; + full_update = 1; + } + if (surface_data(surface) != s->vram_ptr + (s->start_addr * 4) + && is_buffer_shared(surface)) { + /* base address changed (page flip) -> shared display surfaces + * must be updated with the new base address */ + full_update = 1; + } + + if (full_update) { if (share_surface) { surface = qemu_create_displaysurface_from(disp_width, height, format, s->line_offset, @@ -1563,23 +1582,6 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) qemu_console_resize(s->con, disp_width, height); surface = qemu_console_surface(s->con); } - s->last_scr_width = disp_width; - s->last_scr_height = height; - s->last_width = disp_width; - s->last_height = height; - s->last_line_offset = s->line_offset; - s->last_depth = depth; - s->last_byteswap = byteswap; - full_update = 1; - } else if (is_buffer_shared(surface) && - (full_update || surface_data(surface) != s->vram_ptr - + (s->start_addr * 4))) { - pixman_format_code_t format = - qemu_default_pixman_format(depth, !byteswap); - surface = qemu_create_displaysurface_from(disp_width, - height, format, s->line_offset, - s->vram_ptr + (s->start_addr * 4)); - dpy_gfx_replace_surface(s->con, surface); } if (shift_control == 0) {