]> git.proxmox.com Git - qemu.git/commitdiff
optimize screendump for the common non-switch case
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 24 Feb 2012 11:43:45 +0000 (12:43 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 24 Feb 2012 19:36:05 +0000 (13:36 -0600)
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 <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
console.c
console.h
hw/blizzard.c
hw/g364fb.c
hw/omap_lcdc.c
hw/qxl.c
hw/tcx.c
hw/vga.c
hw/vmware_vga.c

index df058b86e7920826b01afa4ae3585a2c4213e34a..6a463f5918d58d7fc6153e87ec472c6404f445c6 100644 (file)
--- a/console.c
+++ b/console.c
@@ -176,19 +176,23 @@ 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);
     } else {
         error_report("screen dump not implemented");
     }
 
-    if (previous_active_console) {
+    if (cswitch) {
         console_select(previous_active_console->index);
     }
 }
index c33ffe0007a4307ce541537991210b041e8a50a3..a95b5812eb957384d0d01117d52d425ef43e153a 100644 (file)
--- 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,
index b2c1b22844c2bbf1d8cec23a849ff194c00ecd19..c7d844d105983b81e904190b9350c27d049039bc 100644 (file)
@@ -932,10 +932,14 @@ static void blizzard_update_display(void *opaque)
     s->my[1] = 0;
 }
 
-static void blizzard_screen_dump(void *opaque, const char *filename) {
+static void blizzard_screen_dump(void *opaque, const char *filename,
+                                 bool cswitch)
+{
     BlizzardState *s = (BlizzardState *) opaque;
 
-    blizzard_update_display(opaque);
+    if (cswitch) {
+        blizzard_update_display(opaque);
+    }
     if (s && ds_get_data(s->state))
         ppm_save(filename, s->state->surface);
 }
index 9c63bddc59a07d19282c494cd5131e110b52a4f0..3a0b68fbae1d62299e07f3b4478b78333a24c05b 100644 (file)
@@ -289,7 +289,7 @@ static void g364fb_reset(G364State *s)
     g364fb_invalidate_display(s);
 }
 
-static void g364fb_screen_dump(void *opaque, const char *filename)
+static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch)
 {
     G364State *s = opaque;
     int y, x;
index f265306556c9c3385ed23d4aeb6d40d0aff7d32a..f172093876022daf83760b863b827cc7dcf81d6a 100644 (file)
@@ -264,9 +264,12 @@ static int ppm_save(const char *filename, uint8_t *data,
     return 0;
 }
 
-static void omap_screen_dump(void *opaque, const char *filename) {
+static void omap_screen_dump(void *opaque, const char *filename, bool cswitch)
+{
     struct omap_lcd_panel_s *omap_lcd = opaque;
-    omap_update_display(opaque);
+    if (cswitch) {
+        omap_update_display(opaque);
+    }
     if (omap_lcd && ds_get_data(omap_lcd->state))
         ppm_save(filename, ds_get_data(omap_lcd->state),
                 omap_lcd->width, omap_lcd->height,
index 87ad49ad8b4cbed6f2d6dd8775e44ba483a2e4d6..f643667205e1cea9b61d0cde32ebb3376db176a9 100644 (file)
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1436,7 +1436,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;
@@ -1448,7 +1448,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;
index 2b66d8619ef24c157eceb1662bd0c3f481075ed4..ac7dcb428ce53e70ade3fd33d01aaca755911b32 100644 (file)
--- a/hw/tcx.c
+++ b/hw/tcx.c
@@ -56,8 +56,8 @@ typedef struct TCXState {
     uint8_t dac_index, dac_state;
 } TCXState;
 
-static void tcx_screen_dump(void *opaque, const char *filename);
-static void tcx24_screen_dump(void *opaque, const char *filename);
+static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch);
+static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch);
 
 static void tcx_set_dirty(TCXState *s)
 {
@@ -574,7 +574,7 @@ static int tcx_init1(SysBusDevice *dev)
     return 0;
 }
 
-static void tcx_screen_dump(void *opaque, const char *filename)
+static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch)
 {
     TCXState *s = opaque;
     FILE *f;
@@ -601,7 +601,7 @@ static void tcx_screen_dump(void *opaque, const char *filename)
     return;
 }
 
-static void tcx24_screen_dump(void *opaque, const char *filename)
+static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch)
 {
     TCXState *s = opaque;
     FILE *f;
index f8f30f8003cd9bf3c8b8f97199a5bbda78c162fc..5994f43b757afccbddd6695d9208dc0f81e334ae 100644 (file)
--- 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);
 }
index f8afa3c367a1fe3990d78a6cdf9a9cf2187d903d..142d9f4ea08c2850a9d55e29f875bae7d064cf48 100644 (file)
@@ -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;
     }