[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/14] pixman: switch screendump function.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 10/14] pixman: switch screendump function. |
Date: |
Wed, 17 Oct 2012 15:29:10 +0200 |
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/vga.c | 39 +++++++++++----------------------------
1 files changed, 11 insertions(+), 28 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index 4d34469..4ffd57c 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2417,13 +2417,12 @@ void vga_init_vbe(VGACommonState *s, MemoryRegion
*system_memory)
void ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp)
{
+ int width = pixman_image_get_width(ds->image);
+ int height = pixman_image_get_height(ds->image);
FILE *f;
- uint8_t *d, *d1;
- uint32_t v;
- int y, x;
- uint8_t r, g, b;
+ int y;
int ret;
- char *linebuf, *pbuf;
+ pixman_image_t *linebuf;
trace_ppm_save(filename, ds);
f = fopen(filename, "wb");
@@ -2432,33 +2431,17 @@ void ppm_save(const char *filename, struct
DisplaySurface *ds, Error **errp)
strerror(errno));
return;
}
- ret = fprintf(f, "P6\n%d %d\n%d\n", ds->width, ds->height, 255);
+ ret = fprintf(f, "P6\n%d %d\n%d\n", width, height, 255);
if (ret < 0) {
linebuf = NULL;
goto write_err;
}
- linebuf = g_malloc(ds->width * 3);
- d1 = ds->data;
- for(y = 0; y < ds->height; y++) {
- d = d1;
- pbuf = linebuf;
- for(x = 0; x < ds->width; x++) {
- if (ds->pf.bits_per_pixel == 32)
- v = *(uint32_t *)d;
- else
- v = (uint32_t) (*(uint16_t *)d);
- /* Limited to 8 or fewer bits per channel: */
- r = ((v >> ds->pf.rshift) & ds->pf.rmax) << (8 - ds->pf.rbits);
- g = ((v >> ds->pf.gshift) & ds->pf.gmax) << (8 - ds->pf.gbits);
- b = ((v >> ds->pf.bshift) & ds->pf.bmax) << (8 - ds->pf.bbits);
- *pbuf++ = r;
- *pbuf++ = g;
- *pbuf++ = b;
- d += ds->pf.bytes_per_pixel;
- }
- d1 += ds->linesize;
+ linebuf = qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
+ for (y = 0; y < height; y++) {
+ qemu_pixman_linebuf_fill(linebuf, ds->image, width, y);
clearerr(f);
- ret = fwrite(linebuf, 1, pbuf - linebuf, f);
+ ret = fwrite(pixman_image_get_data(linebuf), 1,
+ pixman_image_get_stride(linebuf), f);
(void)ret;
if (ferror(f)) {
goto write_err;
@@ -2466,7 +2449,7 @@ void ppm_save(const char *filename, struct DisplaySurface
*ds, Error **errp)
}
out:
- g_free(linebuf);
+ qemu_pixman_image_unref(linebuf);
fclose(f);
return;
--
1.7.1
- [Qemu-devel] [PATCH 00/14] pixman patch series., Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 09/14] vga: stop direct access to DisplaySurface fields., Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 04/14] pixman: helper functions, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 13/14] pixman/vnc: remove dead code., Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 01/14] console: remove DisplayAllocator, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 05/14] pixman: add pixman image to DisplaySurface, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 02/14] pixman: add submodule, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 08/14] qxl: stop direct access to DisplaySurface fields., Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 10/14] pixman: switch screendump function.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 06/14] console: make qemu_alloc_display static, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 12/14] pixman/vnc: remove rgb_prepare_row* functions, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 07/14] console: don't set PixelFormat alpha fields for 32bpp, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 03/14] pixman: windup in configure & makefiles, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 14/14] pixman: drop obsolete fields from DisplaySurface, Gerd Hoffmann, 2012/10/17
- [Qemu-devel] [PATCH 11/14] pixman/vnc: use pixman images in vnc., Gerd Hoffmann, 2012/10/17