Received: from eggs.gnu.org ([208.118.235.92]:40044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsN1-0005X6-5o for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:53:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCsMs-0007wg-Al for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:52:58 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 28 Mar 2012 14:52:31 +0200 Message-Id: <1332939159-16434-29-git-send-email-afaerber@suse.de> In-Reply-To: <1332939159-16434-1-git-send-email-afaerber@suse.de> References: <1332939159-16434-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH stable-0.15 28/36] qxl: stride fixup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Bruce Rogers , kvm@suse.de, qemu-stable@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gerd Hoffmann From: Gerd Hoffmann spice uses negative stride value to signal the bitmap is upside down. The qxl renderer (used for scl, vnc and screenshots) wants a positive value because it is easier to work with. The positive value is then stored in the very same variable, which has the drawback that the upside-down test works only once. Fix by using two variables. Signed-off-by: Gerd Hoffmann (cherry picked from commit 0e2487bd6f56445b43307536a465ee2ba810aed9) Signed-off-by: Bruce Rogers [AF: backported] Signed-off-by: Andreas F=C3=A4rber --- hw/qxl-render.c | 23 ++++++++++++----------- hw/qxl.h | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/qxl-render.c b/hw/qxl-render.c index 1316066..104d79b 100644 --- a/hw/qxl-render.c +++ b/hw/qxl-render.c @@ -28,16 +28,16 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect= ) int len, i; =20 src +=3D (qxl->guest_primary.surface.height - rect->top - 1) * - qxl->guest_primary.stride; - dst +=3D rect->top * qxl->guest_primary.stride; + qxl->guest_primary.abs_stride; + dst +=3D rect->top * qxl->guest_primary.abs_stride; src +=3D rect->left * qxl->guest_primary.bytes_pp; dst +=3D rect->left * qxl->guest_primary.bytes_pp; len =3D (rect->right - rect->left) * qxl->guest_primary.bytes_pp; =20 for (i =3D rect->top; i < rect->bottom; i++) { memcpy(dst, src, len); - dst +=3D qxl->guest_primary.stride; - src -=3D qxl->guest_primary.stride; + dst +=3D qxl->guest_primary.abs_stride; + src -=3D qxl->guest_primary.abs_stride; } } =20 @@ -45,7 +45,8 @@ void qxl_render_resize(PCIQXLDevice *qxl) { QXLSurfaceCreate *sc =3D &qxl->guest_primary.surface; =20 - qxl->guest_primary.stride =3D sc->stride; + qxl->guest_primary.qxl_stride =3D sc->stride; + qxl->guest_primary.abs_stride =3D abs(sc->stride); qxl->guest_primary.resized++; switch (sc->format) { case SPICE_SURFACE_FMT_16_555: @@ -87,11 +88,11 @@ void qxl_render_update(PCIQXLDevice *qxl) qemu_free_displaysurface(vga->ds); =20 qxl->guest_primary.data =3D qemu_get_ram_ptr(qxl->vga.vram_offse= t); - if (qxl->guest_primary.stride < 0) { + if (qxl->guest_primary.qxl_stride < 0) { /* spice surface is upside down -> need extra buffer to flip= */ - qxl->guest_primary.stride =3D -qxl->guest_primary.stride; - qxl->guest_primary.flipped =3D qemu_malloc(qxl->guest_primar= y.surface.width * - qxl->guest_primary.= stride); + qxl->guest_primary.flipped =3D + qemu_malloc(qxl->guest_primary.surface.width * + qxl->guest_primary.abs_stride); ptr =3D qxl->guest_primary.flipped; } else { ptr =3D qxl->guest_primary.data; @@ -100,7 +101,7 @@ void qxl_render_update(PCIQXLDevice *qxl) __FUNCTION__, qxl->guest_primary.surface.width, qxl->guest_primary.surface.height, - qxl->guest_primary.stride, + qxl->guest_primary.qxl_stride, qxl->guest_primary.bytes_pp, qxl->guest_primary.bits_pp, qxl->guest_primary.flipped ? "yes" : "no"); @@ -108,7 +109,7 @@ void qxl_render_update(PCIQXLDevice *qxl) qemu_create_displaysurface_from(qxl->guest_primary.surface.w= idth, qxl->guest_primary.surface.h= eight, qxl->guest_primary.bits_pp, - qxl->guest_primary.stride, + qxl->guest_primary.abs_strid= e, ptr); dpy_resize(vga->ds); } diff --git a/hw/qxl.h b/hw/qxl.h index f6c450d..c05998a 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -42,7 +42,8 @@ typedef struct PCIQXLDevice { QXLSurfaceCreate surface; uint32_t commands; uint32_t resized; - int32_t stride; + int32_t qxl_stride; + uint32_t abs_stride; uint32_t bits_pp; uint32_t bytes_pp; uint8_t *data, *flipped; --=20 1.7.7