From patchwork Thu Feb 23 09:22:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 142574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 11ED2B6EE8 for ; Thu, 23 Feb 2012 20:23:01 +1100 (EST) Received: from localhost ([::1]:51591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Ut5-0007GM-Hp for incoming@patchwork.ozlabs.org; Thu, 23 Feb 2012 04:22:55 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Usz-0007Fy-Cu for qemu-devel@nongnu.org; Thu, 23 Feb 2012 04:22:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0Ust-0001rK-1b for qemu-devel@nongnu.org; Thu, 23 Feb 2012 04:22:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Uss-0001r1-Qh for qemu-devel@nongnu.org; Thu, 23 Feb 2012 04:22:42 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1N9MgFj001778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Feb 2012 04:22:42 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1N9MeXf017275; Thu, 23 Feb 2012 04:22:40 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 497DF40CA6; Thu, 23 Feb 2012 10:22:39 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 23 Feb 2012 10:22:38 +0100 Message-Id: <1329988958-14103-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1329988958-14103-1-git-send-email-kraxel@redhat.com> References: <1329988958-14103-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: alevy@redhat.com, Gerd Hoffmann Subject: [Qemu-devel] [PATCH 2/2] optimize screendump for the common non-switch case X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org switch console only if needed, also pass down whenever the console was switched or not because a displaysurface redraw is only needed in case the console was switched. Signed-off-by: Gerd Hoffmann --- console.c | 10 +++++++--- console.h | 2 +- hw/qxl.c | 4 ++-- hw/vga.c | 10 ++++++---- hw/vmware_vga.c | 4 ++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/console.c b/console.c index 135394f..b3bd14a 100644 --- a/console.c +++ b/console.c @@ -176,17 +176,21 @@ void vga_hw_invalidate(void) void vga_hw_screen_dump(const char *filename) { TextConsole *previous_active_console; + bool cswitch; previous_active_console = active_console; + cswitch = previous_active_console && previous_active_console->index != 0; /* There is currently no way of specifying which screen we want to dump, so always dump the first one. */ - console_select(0); + if (cswitch) { + console_select(0); + } if (consoles[0] && consoles[0]->hw_screen_dump) { - consoles[0]->hw_screen_dump(consoles[0]->hw, filename); + consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch); } - if (previous_active_console) { + if (cswitch) { console_select(previous_active_console->index); } } diff --git a/console.h b/console.h index 6ba0d5d..1fc8ea3 100644 --- a/console.h +++ b/console.h @@ -340,7 +340,7 @@ static inline void console_write_ch(console_ch_t *dest, uint32_t ch) typedef void (*vga_hw_update_ptr)(void *); typedef void (*vga_hw_invalidate_ptr)(void *); -typedef void (*vga_hw_screen_dump_ptr)(void *, const char *); +typedef void (*vga_hw_screen_dump_ptr)(void *, const char *, bool cswitch); typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *); DisplayState *graphic_console_init(vga_hw_update_ptr update, diff --git a/hw/qxl.c b/hw/qxl.c index e38bb29..f4c68ab 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1438,7 +1438,7 @@ static void qxl_hw_invalidate(void *opaque) vga->invalidate(vga); } -static void qxl_hw_screen_dump(void *opaque, const char *filename) +static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch) { PCIQXLDevice *qxl = opaque; VGACommonState *vga = &qxl->vga; @@ -1450,7 +1450,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename) ppm_save(filename, qxl->ssd.ds->surface); break; case QXL_MODE_VGA: - vga->screen_dump(vga, filename); + vga->screen_dump(vga, filename, cswitch); break; default: break; diff --git a/hw/vga.c b/hw/vga.c index f8f30f8..5994f43 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -162,7 +162,7 @@ static uint32_t expand4[256]; static uint16_t expand2[256]; static uint8_t expand4to8[16]; -static void vga_screen_dump(void *opaque, const char *filename); +static void vga_screen_dump(void *opaque, const char *filename, bool cswitch); static void vga_update_memory_access(VGACommonState *s) { @@ -2407,11 +2407,13 @@ int ppm_save(const char *filename, struct DisplaySurface *ds) /* save the vga display in a PPM image even if no display is available */ -static void vga_screen_dump(void *opaque, const char *filename) +static void vga_screen_dump(void *opaque, const char *filename, bool cswitch) { VGACommonState *s = opaque; - vga_invalidate_display(s); - vga_hw_update(); + if (cswitch) { + vga_invalidate_display(s); + vga_hw_update(); + } ppm_save(filename, s->ds->surface); } diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index f8afa3c..142d9f4 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -1003,11 +1003,11 @@ static void vmsvga_invalidate_display(void *opaque) /* save the vga display in a PPM image even if no display is available */ -static void vmsvga_screen_dump(void *opaque, const char *filename) +static void vmsvga_screen_dump(void *opaque, const char *filename, bool cswitch) { struct vmsvga_state_s *s = opaque; if (!s->enable) { - s->vga.screen_dump(&s->vga, filename); + s->vga.screen_dump(&s->vga, filename, cswitch); return; }