peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0421-qxl-properly-handle-upright-and-non-shared-surfaces.patch

56753f
From 7027fa0d3be22f48a51420a45aff13bec54fef1e Mon Sep 17 00:00:00 2001
56753f
From: Gerd Hoffmann <kraxel@redhat.com>
56753f
Date: Mon, 27 Feb 2012 11:05:09 +0100
56753f
Subject: [PATCH 421/434] qxl: properly handle upright and non-shared surfaces
56753f
56753f
Although qxl creates a shared displaysurface when the qxl surface is
56753f
upright and doesn't need to be flipped there is no guarantee that the
56753f
surface doesn't become unshared for some reason.  Rename qxl_flip to
56753f
qxl_blit and fix it to handle both flip and non-flip cases.
56753f
56753f
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
56753f
---
56753f
 hw/qxl-render.c |   20 +++++++++++++-------
56753f
 1 file changed, 13 insertions(+), 7 deletions(-)
56753f
56753f
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
56753f
index 4857838..2e10e93 100644
56753f
--- a/hw/qxl-render.c
56753f
+++ b/hw/qxl-render.c
56753f
@@ -21,25 +21,31 @@
56753f
 
56753f
 #include "qxl.h"
56753f
 
56753f
-static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
56753f
+static void qxl_blit(PCIQXLDevice *qxl, QXLRect *rect)
56753f
 {
56753f
     uint8_t *src;
56753f
     uint8_t *dst = qxl->vga.ds->surface->data;
56753f
     int len, i;
56753f
 
56753f
-    if (qxl->guest_primary.qxl_stride > 0) {
56753f
+    if (is_buffer_shared(qxl->vga.ds->surface)) {
56753f
         return;
56753f
     }
56753f
     if (!qxl->guest_primary.data) {
56753f
         dprint(qxl, 1, "%s: initializing guest_primary.data\n", __func__);
56753f
         qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram);
56753f
     }
56753f
-    dprint(qxl, 1, "%s: stride %d, [%d, %d, %d, %d]\n", __func__,
56753f
+    dprint(qxl, 2, "%s: stride %d, [%d, %d, %d, %d]\n", __func__,
56753f
             qxl->guest_primary.qxl_stride,
56753f
             rect->left, rect->right, rect->top, rect->bottom);
56753f
     src = qxl->guest_primary.data;
56753f
-    src += (qxl->guest_primary.surface.height - rect->top - 1) *
56753f
-        qxl->guest_primary.abs_stride;
56753f
+    if (qxl->guest_primary.qxl_stride < 0) {
56753f
+        /* qxl surface is upside down, walk src scanlines
56753f
+         * in reverse order to flip it */
56753f
+        src += (qxl->guest_primary.surface.height - rect->top - 1) *
56753f
+            qxl->guest_primary.abs_stride;
56753f
+    } else {
56753f
+        src += rect->top * qxl->guest_primary.abs_stride;
56753f
+    }
56753f
     dst += rect->top  * qxl->guest_primary.abs_stride;
56753f
     src += rect->left * qxl->guest_primary.bytes_pp;
56753f
     dst += rect->left * qxl->guest_primary.bytes_pp;
56753f
@@ -48,7 +54,7 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
56753f
     for (i = rect->top; i < rect->bottom; i++) {
56753f
         memcpy(dst, src, len);
56753f
         dst += qxl->guest_primary.abs_stride;
56753f
-        src -= qxl->guest_primary.abs_stride;
56753f
+        src += qxl->guest_primary.qxl_stride;
56753f
     }
56753f
 }
56753f
 
56753f
@@ -132,7 +138,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl)
56753f
         if (qemu_spice_rect_is_empty(qxl->dirty+i)) {
56753f
             break;
56753f
         }
56753f
-        qxl_flip(qxl, qxl->dirty+i);
56753f
+        qxl_blit(qxl, qxl->dirty+i);
56753f
         dpy_update(vga->ds,
56753f
                    qxl->dirty[i].left, qxl->dirty[i].top,
56753f
                    qxl->dirty[i].right - qxl->dirty[i].left,
56753f
-- 
56753f
1.7.10
56753f