mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
spice: add screen mirror
Create a screen mirror, keep there a copy of the most recent update passed on to spice-server. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
c60319a3aa
commit
a7310dd34d
|
@ -171,8 +171,8 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
|
||||||
QXLDrawable *drawable;
|
QXLDrawable *drawable;
|
||||||
QXLImage *image;
|
QXLImage *image;
|
||||||
QXLCommand *cmd;
|
QXLCommand *cmd;
|
||||||
uint8_t *src, *dst;
|
uint8_t *src, *mirror, *dst;
|
||||||
int by, bw, bh;
|
int by, bw, bh, offset, bytes;
|
||||||
struct timespec time_space;
|
struct timespec time_space;
|
||||||
|
|
||||||
trace_qemu_spice_create_update(
|
trace_qemu_spice_create_update(
|
||||||
|
@ -216,19 +216,18 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
|
||||||
image->bitmap.palette = 0;
|
image->bitmap.palette = 0;
|
||||||
image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
|
image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
|
||||||
|
|
||||||
if (ssd->conv == NULL) {
|
offset =
|
||||||
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) +
|
|
||||||
rect->top * ds_get_linesize(ssd->ds) +
|
rect->top * ds_get_linesize(ssd->ds) +
|
||||||
rect->left * ds_get_bytes_per_pixel(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;
|
dst = update->bitmap;
|
||||||
for (by = 0; by < bh; by++) {
|
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);
|
src += ds_get_linesize(ssd->ds);
|
||||||
|
mirror += ds_get_linesize(ssd->ds);
|
||||||
dst += image->bitmap.stride;
|
dst += image->bitmap.stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +242,17 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
|
||||||
if (qemu_spice_rect_is_empty(&ssd->dirty)) {
|
if (qemu_spice_rect_is_empty(&ssd->dirty)) {
|
||||||
return;
|
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);
|
qemu_spice_create_one_update(ssd, &ssd->dirty);
|
||||||
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
|
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
|
||||||
}
|
}
|
||||||
|
@ -358,6 +368,8 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
|
||||||
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
|
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
|
||||||
qemu_pf_conv_put(ssd->conv);
|
qemu_pf_conv_put(ssd->conv);
|
||||||
ssd->conv = NULL;
|
ssd->conv = NULL;
|
||||||
|
g_free(ssd->ds_mirror);
|
||||||
|
ssd->ds_mirror = NULL;
|
||||||
|
|
||||||
qemu_mutex_lock(&ssd->lock);
|
qemu_mutex_lock(&ssd->lock);
|
||||||
while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
|
while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
|
||||||
|
|
||||||
struct SimpleSpiceDisplay {
|
struct SimpleSpiceDisplay {
|
||||||
DisplayState *ds;
|
DisplayState *ds;
|
||||||
|
uint8_t *ds_mirror;
|
||||||
void *buf;
|
void *buf;
|
||||||
int bufsize;
|
int bufsize;
|
||||||
QXLWorker *worker;
|
QXLWorker *worker;
|
||||||
|
|
Loading…
Reference in a new issue