mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
console: simplify screendump
Screendumps are alot simpler as we can update non-active QemuConsoles now. So we only need to update the QemuConsole we want write out, then dump the DisplaySurface content into a ppm file. Done. No console switching needed. No special support code in the gfx card emulation needed. Zap it all. Also move ppm_save out of the vga code and next to the qmp_screendump function. For now screen dumping is limited to console #0 (like it used to be), even though it is dead simple to extend it to other consoles. I wanna finish the console cleanup before setting new qapi interfaces into stone. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
This commit is contained in:
parent
321f048d24
commit
2c62f08ddb
26 changed files with 74 additions and 452 deletions
|
@ -227,90 +227,6 @@ static void omap_update_display(void *opaque)
|
|||
omap_lcd->invalidate = 0;
|
||||
}
|
||||
|
||||
static void omap_ppm_save(const char *filename, uint8_t *data,
|
||||
int w, int h, int linesize, Error **errp)
|
||||
{
|
||||
FILE *f;
|
||||
uint8_t *d, *d1;
|
||||
unsigned int v;
|
||||
int ret, y, x, bpp;
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
error_setg(errp, "failed to open file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
ret = fprintf(f, "P6\n%d %d\n%d\n", w, h, 255);
|
||||
if (ret < 0) {
|
||||
goto write_err;
|
||||
}
|
||||
d1 = data;
|
||||
bpp = linesize / w;
|
||||
for (y = 0; y < h; y ++) {
|
||||
d = d1;
|
||||
for (x = 0; x < w; x ++) {
|
||||
v = *(uint32_t *) d;
|
||||
switch (bpp) {
|
||||
case 2:
|
||||
ret = fputc((v >> 8) & 0xf8, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v >> 3) & 0xfc, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v << 3) & 0xf8, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
default:
|
||||
ret = fputc((v >> 16) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v >> 8) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
d += bpp;
|
||||
}
|
||||
d1 += linesize;
|
||||
}
|
||||
out:
|
||||
fclose(f);
|
||||
return;
|
||||
|
||||
write_err:
|
||||
error_setg(errp, "failed to write to file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
unlink(filename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
struct omap_lcd_panel_s *omap_lcd = opaque;
|
||||
DisplaySurface *surface = qemu_console_surface(omap_lcd->con);
|
||||
|
||||
omap_update_display(opaque);
|
||||
if (omap_lcd && surface_data(surface))
|
||||
omap_ppm_save(filename, surface_data(surface),
|
||||
omap_lcd->width, omap_lcd->height,
|
||||
surface_stride(surface), errp);
|
||||
}
|
||||
|
||||
static void omap_invalidate_display(void *opaque) {
|
||||
struct omap_lcd_panel_s *omap_lcd = opaque;
|
||||
omap_lcd->invalidate = 1;
|
||||
|
@ -487,7 +403,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem,
|
|||
|
||||
s->con = graphic_console_init(omap_update_display,
|
||||
omap_invalidate_display,
|
||||
omap_screen_dump, NULL, s);
|
||||
NULL, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue