spice: switch to queue for vga mode updates

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2012-09-05 08:25:08 +02:00
parent e0a1e32dbc
commit b1af98ba3e
3 changed files with 19 additions and 15 deletions

View File

@ -597,9 +597,9 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
case QXL_MODE_VGA: case QXL_MODE_VGA:
ret = false; ret = false;
qemu_mutex_lock(&qxl->ssd.lock); qemu_mutex_lock(&qxl->ssd.lock);
if (qxl->ssd.update != NULL) { update = QTAILQ_FIRST(&qxl->ssd.updates);
update = qxl->ssd.update; if (update != NULL) {
qxl->ssd.update = NULL; QTAILQ_REMOVE(&qxl->ssd.updates, update, next);
*ext = update->ext; *ext = update->ext;
ret = true; ret = true;
} }

View File

@ -164,7 +164,7 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
#endif #endif
} }
static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd) static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
{ {
SimpleSpiceUpdate *update; SimpleSpiceUpdate *update;
QXLDrawable *drawable; QXLDrawable *drawable;
@ -175,7 +175,7 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
struct timespec time_space; struct timespec time_space;
if (qemu_spice_rect_is_empty(&ssd->dirty)) { if (qemu_spice_rect_is_empty(&ssd->dirty)) {
return NULL; return;
}; };
trace_qemu_spice_create_update( trace_qemu_spice_create_update(
@ -239,7 +239,7 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
cmd->data = (uintptr_t)drawable; cmd->data = (uintptr_t)drawable;
memset(&ssd->dirty, 0, sizeof(ssd->dirty)); memset(&ssd->dirty, 0, sizeof(ssd->dirty));
return update; QTAILQ_INSERT_TAIL(&ssd->updates, update, next);
} }
/* /*
@ -315,6 +315,7 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
{ {
ssd->ds = ds; ssd->ds = ds;
qemu_mutex_init(&ssd->lock); qemu_mutex_init(&ssd->lock);
QTAILQ_INIT(&ssd->updates);
ssd->mouse_x = -1; ssd->mouse_x = -1;
ssd->mouse_y = -1; ssd->mouse_y = -1;
if (ssd->num_surfaces == 0) { if (ssd->num_surfaces == 0) {
@ -345,6 +346,8 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
void qemu_spice_display_resize(SimpleSpiceDisplay *ssd) void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
{ {
SimpleSpiceUpdate *update;
dprint(1, "%s:\n", __FUNCTION__); dprint(1, "%s:\n", __FUNCTION__);
memset(&ssd->dirty, 0, sizeof(ssd->dirty)); memset(&ssd->dirty, 0, sizeof(ssd->dirty));
@ -352,9 +355,9 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
ssd->conv = NULL; ssd->conv = NULL;
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
if (ssd->update != NULL) { while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
qemu_spice_destroy_update(ssd, ssd->update); QTAILQ_REMOVE(&ssd->updates, update, next);
ssd->update = NULL; qemu_spice_destroy_update(ssd, update);
} }
qemu_mutex_unlock(&ssd->lock); qemu_mutex_unlock(&ssd->lock);
qemu_spice_destroy_host_primary(ssd); qemu_spice_destroy_host_primary(ssd);
@ -384,8 +387,8 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
vga_hw_update(); vga_hw_update();
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
if (ssd->update == NULL) { if (QTAILQ_EMPTY(&ssd->updates)) {
ssd->update = qemu_spice_create_update(ssd); qemu_spice_create_update(ssd);
ssd->notify++; ssd->notify++;
} }
qemu_spice_cursor_refresh_unlocked(ssd); qemu_spice_cursor_refresh_unlocked(ssd);
@ -442,9 +445,9 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
dprint(3, "%s:\n", __FUNCTION__); dprint(3, "%s:\n", __FUNCTION__);
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
if (ssd->update != NULL) { update = QTAILQ_FIRST(&ssd->updates);
update = ssd->update; if (update != NULL) {
ssd->update = NULL; QTAILQ_REMOVE(&ssd->updates, update, next);
*ext = update->ext; *ext = update->ext;
ret = true; ret = true;
} }

View File

@ -92,7 +92,7 @@ struct SimpleSpiceDisplay {
* to them must be protected by the lock. * to them must be protected by the lock.
*/ */
QemuMutex lock; QemuMutex lock;
SimpleSpiceUpdate *update; QTAILQ_HEAD(, SimpleSpiceUpdate) updates;
QEMUCursor *cursor; QEMUCursor *cursor;
int mouse_x, mouse_y; int mouse_x, mouse_y;
}; };
@ -102,6 +102,7 @@ struct SimpleSpiceUpdate {
QXLImage image; QXLImage image;
QXLCommandExt ext; QXLCommandExt ext;
uint8_t *bitmap; uint8_t *bitmap;
QTAILQ_ENTRY(SimpleSpiceUpdate) next;
}; };
int qemu_spice_rect_is_empty(const QXLRect* r); int qemu_spice_rect_is_empty(const QXLRect* r);