aboutsummaryrefslogtreecommitdiff
path: root/ui/spice-display.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/spice-display.c')
-rw-r--r--ui/spice-display.c93
1 files changed, 81 insertions, 12 deletions
diff --git a/ui/spice-display.c b/ui/spice-display.c
index feeee73dcc..683d45429f 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -62,6 +62,70 @@ void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r)
dest->right = MAX(dest->right, r->right);
}
+void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot,
+ qxl_async_io async)
+{
+ if (async != QXL_SYNC) {
+#if SPICE_INTERFACE_QXL_MINOR >= 1
+ spice_qxl_add_memslot_async(&ssd->qxl, memslot, 0);
+#else
+ abort();
+#endif
+ } else {
+ ssd->worker->add_memslot(ssd->worker, memslot);
+ }
+}
+
+void qemu_spice_del_memslot(SimpleSpiceDisplay *ssd, uint32_t gid, uint32_t sid)
+{
+ ssd->worker->del_memslot(ssd->worker, gid, sid);
+}
+
+void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
+ QXLDevSurfaceCreate *surface,
+ qxl_async_io async)
+{
+ if (async != QXL_SYNC) {
+#if SPICE_INTERFACE_QXL_MINOR >= 1
+ spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface, 0);
+#else
+ abort();
+#endif
+ } else {
+ ssd->worker->create_primary_surface(ssd->worker, id, surface);
+ }
+}
+
+
+void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
+ uint32_t id, qxl_async_io async)
+{
+ if (async != QXL_SYNC) {
+#if SPICE_INTERFACE_QXL_MINOR >= 1
+ spice_qxl_destroy_primary_surface_async(&ssd->qxl, id, 0);
+#else
+ abort();
+#endif
+ } else {
+ ssd->worker->destroy_primary_surface(ssd->worker, id);
+ }
+}
+
+void qemu_spice_wakeup(SimpleSpiceDisplay *ssd)
+{
+ ssd->worker->wakeup(ssd->worker);
+}
+
+void qemu_spice_start(SimpleSpiceDisplay *ssd)
+{
+ ssd->worker->start(ssd->worker);
+}
+
+void qemu_spice_stop(SimpleSpiceDisplay *ssd)
+{
+ ssd->worker->stop(ssd->worker);
+}
+
static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
{
SimpleSpiceUpdate *update;
@@ -161,7 +225,7 @@ void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd)
memset(&memslot, 0, sizeof(memslot));
memslot.slot_group_id = MEMSLOT_GROUP_HOST;
memslot.virt_end = ~0;
- ssd->worker->add_memslot(ssd->worker, &memslot);
+ qemu_spice_add_memslot(ssd, &memslot, QXL_SYNC);
}
void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
@@ -181,14 +245,14 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
surface.mem = (intptr_t)ssd->buf;
surface.group_id = MEMSLOT_GROUP_HOST;
- ssd->worker->create_primary_surface(ssd->worker, 0, &surface);
+ qemu_spice_create_primary_surface(ssd, 0, &surface, QXL_SYNC);
}
void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)
{
dprint(1, "%s:\n", __FUNCTION__);
- ssd->worker->destroy_primary_surface(ssd->worker, 0);
+ qemu_spice_destroy_primary_surface(ssd, 0, QXL_SYNC);
}
void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason)
@@ -196,13 +260,23 @@ void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason)
SimpleSpiceDisplay *ssd = opaque;
if (running) {
- ssd->worker->start(ssd->worker);
+ qemu_spice_start(ssd);
} else {
- ssd->worker->stop(ssd->worker);
+ qemu_spice_stop(ssd);
}
ssd->running = running;
}
+void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
+{
+ ssd->ds = ds;
+ qemu_mutex_init(&ssd->lock);
+ ssd->mouse_x = -1;
+ ssd->mouse_y = -1;
+ ssd->bufsize = (16 * 1024 * 1024);
+ ssd->buf = qemu_malloc(ssd->bufsize);
+}
+
/* display listener callbacks */
void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
@@ -267,7 +341,7 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
if (ssd->notify) {
ssd->notify = 0;
- ssd->worker->wakeup(ssd->worker);
+ qemu_spice_wakeup(ssd);
dprint(2, "%s: notify\n", __FUNCTION__);
}
}
@@ -416,12 +490,7 @@ static DisplayChangeListener display_listener = {
void qemu_spice_display_init(DisplayState *ds)
{
assert(sdpy.ds == NULL);
- sdpy.ds = ds;
- qemu_mutex_init(&sdpy.lock);
- sdpy.mouse_x = -1;
- sdpy.mouse_y = -1;
- sdpy.bufsize = (16 * 1024 * 1024);
- sdpy.buf = qemu_malloc(sdpy.bufsize);
+ qemu_spice_display_init_common(&sdpy, ds);
register_displaychangelistener(ds, &display_listener);
sdpy.qxl.base.sif = &dpy_interface.base;