From nobody Sun Nov 2 03:01:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527254060551941.722211746306; Fri, 25 May 2018 06:14:20 -0700 (PDT) Received: from localhost ([::1]:43935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMCXz-00025v-GY for importer@patchew.org; Fri, 25 May 2018 09:14:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMCXA-0001od-BX for qemu-devel@nongnu.org; Fri, 25 May 2018 09:13:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMCX5-000229-8n for qemu-devel@nongnu.org; Fri, 25 May 2018 09:13:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59686 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fMCX5-00021k-3T for qemu-devel@nongnu.org; Fri, 25 May 2018 09:13:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B68EA4022414 for ; Fri, 25 May 2018 13:13:22 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7603D2024CA1; Fri, 25 May 2018 13:13:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9686E3EB9D; Fri, 25 May 2018 15:13:20 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 15:13:18 +0200 Message-Id: <20180525131318.28437-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 25 May 2018 13:13:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 25 May 2018 13:13:22 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] vga: cleanup surface handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D false; } + if (s->line_offset !=3D s->last_line_offset || disp_width !=3D s->last_width || height !=3D s->last_height || s->last_depth !=3D depth || s->last_byteswap !=3D byteswap || share_surface !=3D is_buffer_shared(surface)) { + /* display parameters changed -> need new display surface */ + s->last_scr_width =3D disp_width; + s->last_scr_height =3D height; + s->last_width =3D disp_width; + s->last_height =3D height; + s->last_line_offset =3D s->line_offset; + s->last_depth =3D depth; + s->last_byteswap =3D byteswap; + full_update =3D 1; + } + if (surface_data(surface) !=3D 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 =3D 1; + } + + if (full_update) { if (share_surface) { surface =3D 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 =3D qemu_console_surface(s->con); } - s->last_scr_width =3D disp_width; - s->last_scr_height =3D height; - s->last_width =3D disp_width; - s->last_height =3D height; - s->last_line_offset =3D s->line_offset; - s->last_depth =3D depth; - s->last_byteswap =3D byteswap; - full_update =3D 1; - } else if (is_buffer_shared(surface) && - (full_update || surface_data(surface) !=3D s->vram_ptr - + (s->start_addr * 4))) { - pixman_format_code_t format =3D - qemu_default_pixman_format(depth, !byteswap); - surface =3D 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); } =20 if (shift_control =3D=3D 0) { --=20 2.9.3