Commit e07d630ad249ca142edf3c0d7b1eb03d43b8002d
1 parent
3023f332
fix screendump (Stefano Stabellini)
this patch fixes the screendump functionality that was recently broken; it must be applied *after* PATCH 5, 6 and 7 of the original displaystate change patch series. In fact the other patches make much easier to solve the screendump problem because they make the console switching mechanism more robust. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6345 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
29 additions
and
22 deletions
hw/vga.c
@@ -2533,8 +2533,6 @@ int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base, | @@ -2533,8 +2533,6 @@ int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base, | ||
2533 | /********************************************************/ | 2533 | /********************************************************/ |
2534 | /* vga screen dump */ | 2534 | /* vga screen dump */ |
2535 | 2535 | ||
2536 | -static int vga_save_w, vga_save_h; | ||
2537 | - | ||
2538 | static void vga_save_dpy_update(DisplayState *s, | 2536 | static void vga_save_dpy_update(DisplayState *s, |
2539 | int x, int y, int w, int h) | 2537 | int x, int y, int w, int h) |
2540 | { | 2538 | { |
@@ -2548,30 +2546,39 @@ static void vga_save_dpy_refresh(DisplayState *s) | @@ -2548,30 +2546,39 @@ static void vga_save_dpy_refresh(DisplayState *s) | ||
2548 | { | 2546 | { |
2549 | } | 2547 | } |
2550 | 2548 | ||
2551 | -int ppm_save(const char *filename, uint8_t *data, | ||
2552 | - int w, int h, int linesize) | 2549 | +int ppm_save(const char *filename, struct DisplaySurface *ds) |
2553 | { | 2550 | { |
2554 | FILE *f; | 2551 | FILE *f; |
2555 | uint8_t *d, *d1; | 2552 | uint8_t *d, *d1; |
2556 | - unsigned int v; | 2553 | + uint32_t v; |
2557 | int y, x; | 2554 | int y, x; |
2555 | + uint8_t r, g, b; | ||
2558 | 2556 | ||
2559 | f = fopen(filename, "wb"); | 2557 | f = fopen(filename, "wb"); |
2560 | if (!f) | 2558 | if (!f) |
2561 | return -1; | 2559 | return -1; |
2562 | fprintf(f, "P6\n%d %d\n%d\n", | 2560 | fprintf(f, "P6\n%d %d\n%d\n", |
2563 | - w, h, 255); | ||
2564 | - d1 = data; | ||
2565 | - for(y = 0; y < h; y++) { | 2561 | + ds->width, ds->height, 255); |
2562 | + d1 = ds->data; | ||
2563 | + for(y = 0; y < ds->height; y++) { | ||
2566 | d = d1; | 2564 | d = d1; |
2567 | - for(x = 0; x < w; x++) { | ||
2568 | - v = *(uint32_t *)d; | ||
2569 | - fputc((v >> 16) & 0xff, f); | ||
2570 | - fputc((v >> 8) & 0xff, f); | ||
2571 | - fputc((v) & 0xff, f); | ||
2572 | - d += 4; | 2565 | + for(x = 0; x < ds->width; x++) { |
2566 | + if (ds->pf.bits_per_pixel == 32) | ||
2567 | + v = *(uint32_t *)d; | ||
2568 | + else | ||
2569 | + v = (uint32_t) (*(uint16_t *)d); | ||
2570 | + r = ((v >> ds->pf.rshift) & ds->pf.rmax) * 256 / | ||
2571 | + (ds->pf.rmax + 1); | ||
2572 | + g = ((v >> ds->pf.gshift) & ds->pf.gmax) * 256 / | ||
2573 | + (ds->pf.gmax + 1); | ||
2574 | + b = ((v >> ds->pf.bshift) & ds->pf.bmax) * 256 / | ||
2575 | + (ds->pf.bmax + 1); | ||
2576 | + fputc(r, f); | ||
2577 | + fputc(g, f); | ||
2578 | + fputc(b, f); | ||
2579 | + d += ds->pf.bytes_per_pixel; | ||
2573 | } | 2580 | } |
2574 | - d1 += linesize; | 2581 | + d1 += ds->linesize; |
2575 | } | 2582 | } |
2576 | fclose(f); | 2583 | fclose(f); |
2577 | return 0; | 2584 | return 0; |
@@ -2613,15 +2620,13 @@ static void vga_screen_dump_common(VGAState *s, const char *filename, | @@ -2613,15 +2620,13 @@ static void vga_screen_dump_common(VGAState *s, const char *filename, | ||
2613 | dcl.dpy_resize = vga_save_dpy_resize; | 2620 | dcl.dpy_resize = vga_save_dpy_resize; |
2614 | dcl.dpy_refresh = vga_save_dpy_refresh; | 2621 | dcl.dpy_refresh = vga_save_dpy_refresh; |
2615 | register_displaychangelistener(ds, &dcl); | 2622 | register_displaychangelistener(ds, &dcl); |
2616 | - ds->surface = qemu_create_displaysurface(ds_get_width(saved_ds), | ||
2617 | - ds_get_height(saved_ds), 32, 4 * ds_get_width(saved_ds)); | 2623 | + ds->surface = qemu_create_displaysurface(w, h, 32, 4 * w); |
2618 | 2624 | ||
2619 | s->ds = ds; | 2625 | s->ds = ds; |
2620 | s->graphic_mode = -1; | 2626 | s->graphic_mode = -1; |
2621 | vga_update_display(s); | 2627 | vga_update_display(s); |
2622 | 2628 | ||
2623 | - ppm_save(filename, ds_get_data(ds), vga_save_w, vga_save_h, | ||
2624 | - ds_get_linesize(ds)); | 2629 | + ppm_save(filename, ds->surface); |
2625 | 2630 | ||
2626 | qemu_free_displaysurface(ds->surface); | 2631 | qemu_free_displaysurface(ds->surface); |
2627 | s->ds = saved_ds; | 2632 | s->ds = saved_ds; |
hw/vga_int.h
@@ -202,8 +202,7 @@ void vga_dirty_log_stop(VGAState *s); | @@ -202,8 +202,7 @@ void vga_dirty_log_stop(VGAState *s); | ||
202 | uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr); | 202 | uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr); |
203 | void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val); | 203 | void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val); |
204 | void vga_invalidate_scanlines(VGAState *s, int y1, int y2); | 204 | void vga_invalidate_scanlines(VGAState *s, int y1, int y2); |
205 | -int ppm_save(const char *filename, uint8_t *data, | ||
206 | - int w, int h, int linesize); | 205 | +int ppm_save(const char *filename, struct DisplaySurface *ds); |
207 | 206 | ||
208 | void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1, | 207 | void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1, |
209 | int poffset, int w, | 208 | int poffset, int w, |
hw/vmware_vga.c
@@ -975,7 +975,10 @@ static void vmsvga_screen_dump(void *opaque, const char *filename) | @@ -975,7 +975,10 @@ static void vmsvga_screen_dump(void *opaque, const char *filename) | ||
975 | } | 975 | } |
976 | 976 | ||
977 | if (s->depth == 32) { | 977 | if (s->depth == 32) { |
978 | - ppm_save(filename, s->vram, s->width, s->height, ds_get_linesize(s->ds)); | 978 | + DisplaySurface *ds = qemu_create_displaysurface_from(s->width, |
979 | + s->height, 32, ds_get_linesize(s->ds), s->vram); | ||
980 | + ppm_save(filename, ds); | ||
981 | + qemu_free(ds); | ||
979 | } | 982 | } |
980 | } | 983 | } |
981 | 984 |