From patchwork Thu Nov 1 13:04:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 196219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AB9242C0180 for ; Fri, 2 Nov 2012 01:14:37 +1100 (EST) Received: from localhost ([::1]:52457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTuSN-0004xX-Bk for incoming@patchwork.ozlabs.org; Thu, 01 Nov 2012 09:05:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTuRg-0003Sf-8r for qemu-devel@nongnu.org; Thu, 01 Nov 2012 09:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTuRd-0005rq-0r for qemu-devel@nongnu.org; Thu, 01 Nov 2012 09:04:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61029) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTuRc-0005rN-Mj for qemu-devel@nongnu.org; Thu, 01 Nov 2012 09:04:24 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA1D4ORS005829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Nov 2012 09:04:24 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA1D4MLM030213; Thu, 1 Nov 2012 09:04:23 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 7A1CD440DB; Thu, 1 Nov 2012 14:04:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 1 Nov 2012 14:04:13 +0100 Message-Id: <1351775057-3938-19-git-send-email-kraxel@redhat.com> In-Reply-To: <1351775057-3938-1-git-send-email-kraxel@redhat.com> References: <1351775057-3938-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 18/22] pixman: switch screendump function. 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 Signed-off-by: Gerd Hoffmann --- hw/vga.c | 39 +++++++++++---------------------------- 1 files changed, 11 insertions(+), 28 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index 1188463..023134e 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -2393,13 +2393,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"); @@ -2408,33 +2407,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; @@ -2442,7 +2425,7 @@ void ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp) } out: - g_free(linebuf); + qemu_pixman_image_unref(linebuf); fclose(f); return;