dcavalca / rpms / qemu

Forked from rpms/qemu 11 months ago
Clone

Blame 0227-qxl-stride-fixup.patch

cd9d16
From a3cc0cf8b185043fbd1f9b893c1c20f90efb1d06 Mon Sep 17 00:00:00 2001
cd9d16
From: Gerd Hoffmann <kraxel@redhat.com>
cd9d16
Date: Fri, 21 Oct 2011 15:59:07 +0200
cd9d16
Subject: [PATCH] qxl: stride fixup
cd9d16
MIME-Version: 1.0
cd9d16
Content-Type: text/plain; charset=UTF-8
cd9d16
Content-Transfer-Encoding: 8bit
cd9d16
cd9d16
spice uses negative stride value to signal the bitmap is upside down.
cd9d16
The qxl renderer (used for scl, vnc and screenshots) wants a positive
cd9d16
value because it is easier to work with.  The positive value is then
cd9d16
stored in the very same variable, which has the drawback that the
cd9d16
upside-down test works only once.  Fix by using two variables.
cd9d16
cd9d16
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
cd9d16
(cherry picked from commit 0e2487bd6f56445b43307536a465ee2ba810aed9)
cd9d16
cd9d16
Signed-off-by: Bruce Rogers <brogers@suse.com>
cd9d16
[AF: backported]
cd9d16
Signed-off-by: Andreas Färber <afaerber@suse.de>
cd9d16
---
cd9d16
 hw/qxl-render.c | 23 ++++++++++++-----------
cd9d16
 hw/qxl.h        |  3 ++-
cd9d16
 2 files changed, 14 insertions(+), 12 deletions(-)
cd9d16
cd9d16
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
cd9d16
index 1316066..104d79b 100644
cd9d16
--- a/hw/qxl-render.c
cd9d16
+++ b/hw/qxl-render.c
cd9d16
@@ -28,16 +28,16 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
cd9d16
     int len, i;
cd9d16
 
cd9d16
     src += (qxl->guest_primary.surface.height - rect->top - 1) *
cd9d16
-        qxl->guest_primary.stride;
cd9d16
-    dst += rect->top  * qxl->guest_primary.stride;
cd9d16
+        qxl->guest_primary.abs_stride;
cd9d16
+    dst += rect->top  * qxl->guest_primary.abs_stride;
cd9d16
     src += rect->left * qxl->guest_primary.bytes_pp;
cd9d16
     dst += rect->left * qxl->guest_primary.bytes_pp;
cd9d16
     len  = (rect->right - rect->left) * qxl->guest_primary.bytes_pp;
cd9d16
 
cd9d16
     for (i = rect->top; i < rect->bottom; i++) {
cd9d16
         memcpy(dst, src, len);
cd9d16
-        dst += qxl->guest_primary.stride;
cd9d16
-        src -= qxl->guest_primary.stride;
cd9d16
+        dst += qxl->guest_primary.abs_stride;
cd9d16
+        src -= qxl->guest_primary.abs_stride;
cd9d16
     }
cd9d16
 }
cd9d16
 
cd9d16
@@ -45,7 +45,8 @@ void qxl_render_resize(PCIQXLDevice *qxl)
cd9d16
 {
cd9d16
     QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
cd9d16
 
cd9d16
-    qxl->guest_primary.stride = sc->stride;
cd9d16
+    qxl->guest_primary.qxl_stride = sc->stride;
cd9d16
+    qxl->guest_primary.abs_stride = abs(sc->stride);
cd9d16
     qxl->guest_primary.resized++;
cd9d16
     switch (sc->format) {
cd9d16
     case SPICE_SURFACE_FMT_16_555:
cd9d16
@@ -87,11 +88,11 @@ void qxl_render_update(PCIQXLDevice *qxl)
cd9d16
         qemu_free_displaysurface(vga->ds);
cd9d16
 
cd9d16
         qxl->guest_primary.data = qemu_get_ram_ptr(qxl->vga.vram_offset);
cd9d16
-        if (qxl->guest_primary.stride < 0) {
cd9d16
+        if (qxl->guest_primary.qxl_stride < 0) {
cd9d16
             /* spice surface is upside down -> need extra buffer to flip */
cd9d16
-            qxl->guest_primary.stride = -qxl->guest_primary.stride;
cd9d16
-            qxl->guest_primary.flipped = qemu_malloc(qxl->guest_primary.surface.width *
cd9d16
-                                                     qxl->guest_primary.stride);
cd9d16
+            qxl->guest_primary.flipped =
cd9d16
+                qemu_malloc(qxl->guest_primary.surface.width *
cd9d16
+                            qxl->guest_primary.abs_stride);
cd9d16
             ptr = qxl->guest_primary.flipped;
cd9d16
         } else {
cd9d16
             ptr = qxl->guest_primary.data;
cd9d16
@@ -100,7 +101,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
cd9d16
                __FUNCTION__,
cd9d16
                qxl->guest_primary.surface.width,
cd9d16
                qxl->guest_primary.surface.height,
cd9d16
-               qxl->guest_primary.stride,
cd9d16
+               qxl->guest_primary.qxl_stride,
cd9d16
                qxl->guest_primary.bytes_pp,
cd9d16
                qxl->guest_primary.bits_pp,
cd9d16
                qxl->guest_primary.flipped ? "yes" : "no");
cd9d16
@@ -108,7 +109,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
cd9d16
             qemu_create_displaysurface_from(qxl->guest_primary.surface.width,
cd9d16
                                             qxl->guest_primary.surface.height,
cd9d16
                                             qxl->guest_primary.bits_pp,
cd9d16
-                                            qxl->guest_primary.stride,
cd9d16
+                                            qxl->guest_primary.abs_stride,
cd9d16
                                             ptr);
cd9d16
         dpy_resize(vga->ds);
cd9d16
     }
cd9d16
diff --git a/hw/qxl.h b/hw/qxl.h
cd9d16
index f6c450d..c05998a 100644
cd9d16
--- a/hw/qxl.h
cd9d16
+++ b/hw/qxl.h
cd9d16
@@ -42,7 +42,8 @@ typedef struct PCIQXLDevice {
cd9d16
         QXLSurfaceCreate surface;
cd9d16
         uint32_t       commands;
cd9d16
         uint32_t       resized;
cd9d16
-        int32_t        stride;
cd9d16
+        int32_t        qxl_stride;
cd9d16
+        uint32_t       abs_stride;
cd9d16
         uint32_t       bits_pp;
cd9d16
         uint32_t       bytes_pp;
cd9d16
         uint8_t        *data, *flipped;
cd9d16
-- 
cd9d16
1.7.11.2
cd9d16