From f5651b2f45e561d10be44d93d137496d08497bb9 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <8366ff5a206b0f75edd17a4a78f7c389ebb81d49.1349887753.git.minovotn@redhat.com> References: <8366ff5a206b0f75edd17a4a78f7c389ebb81d49.1349887753.git.minovotn@redhat.com> From: Gerd Hoffmann Date: Fri, 21 Sep 2012 08:26:33 +0200 Subject: [PATCH 03/11] spice: add screen mirror RH-Author: Gerd Hoffmann Message-id: <1348215994-27217-4-git-send-email-kraxel@redhat.com> Patchwork-id: 42153 O-Subject: [RHEL-6.4 qemu-kvm PATCH 3/4] spice: add screen mirror Bugzilla: 854528 RH-Acked-by: Hans de Goede RH-Acked-by: Paolo Bonzini RH-Acked-by: Alon Levy Create a screen mirror, keep there a copy of the most recent update passed on to spice-server. Signed-off-by: Gerd Hoffmann Conflicts: ui/spice-display.c upstream: a7310dd34df4d35a1c3e7ea3f4a94c60f6d5064b --- ui/spice-display.c | 32 ++++++++++++++++++++++---------- ui/spice-display.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) Signed-off-by: Michal Novotny --- ui/spice-display.c | 32 ++++++++++++++++++++++---------- ui/spice-display.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 62904bd..e2d7b24 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -164,8 +164,8 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd, QXLDrawable *drawable; QXLImage *image; QXLCommand *cmd; - uint8_t *src, *dst; - int by, bw, bh; + uint8_t *src, *mirror, *dst; + int by, bw, bh, offset, bytes; dprint(2, "%s: lr %d -> %d, tb -> %d -> %d\n", __FUNCTION__, rect->left, rect->right, @@ -204,19 +204,18 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd, image->bitmap.palette = 0; image->bitmap.format = SPICE_BITMAP_FMT_32BIT; - if (ssd->conv == NULL) { - PixelFormat dst = qemu_default_pixelformat(32); - ssd->conv = qemu_pf_conv_get(&dst, &ssd->ds->surface->pf); - assert(ssd->conv); - } - - src = ds_get_data(ssd->ds) + + offset = rect->top * ds_get_linesize(ssd->ds) + rect->left * ds_get_bytes_per_pixel(ssd->ds); + bytes = ds_get_bytes_per_pixel(ssd->ds) * bw; + src = ds_get_data(ssd->ds) + offset; + mirror = ssd->ds_mirror + offset; dst = update->bitmap; for (by = 0; by < bh; by++) { - qemu_pf_conv_run(ssd->conv, dst, src, bw); + memcpy(mirror, src, bytes); + qemu_pf_conv_run(ssd->conv, dst, mirror, bw); src += ds_get_linesize(ssd->ds); + mirror += ds_get_linesize(ssd->ds); dst += image->bitmap.stride; } @@ -231,6 +230,17 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd) if (qemu_spice_rect_is_empty(&ssd->dirty)) { return; }; + + if (ssd->conv == NULL) { + PixelFormat dst = qemu_default_pixelformat(32); + ssd->conv = qemu_pf_conv_get(&dst, &ssd->ds->surface->pf); + assert(ssd->conv); + } + if (ssd->ds_mirror == NULL) { + int size = ds_get_height(ssd->ds) * ds_get_linesize(ssd->ds); + ssd->ds_mirror = g_malloc0(size); + } + qemu_spice_create_one_update(ssd, &ssd->dirty); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); } @@ -341,6 +351,8 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd) memset(&ssd->dirty, 0, sizeof(ssd->dirty)); qemu_pf_conv_put(ssd->conv); ssd->conv = NULL; + g_free(ssd->ds_mirror); + ssd->ds_mirror = NULL; qemu_mutex_lock(&ssd->lock); while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) { diff --git a/ui/spice-display.h b/ui/spice-display.h index 03b0a3b..0b6b044 100644 --- a/ui/spice-display.h +++ b/ui/spice-display.h @@ -73,6 +73,7 @@ typedef struct SimpleSpiceUpdate SimpleSpiceUpdate; struct SimpleSpiceDisplay { DisplayState *ds; + uint8_t *ds_mirror; void *buf; int bufsize; QXLWorker *worker; -- 1.7.11.4