spice: split qemu_spice_create_update

Creating one function which creates a single update for a given
rectangle.  And one (for now) pretty simple wrapper around it to
queue up screen updates for the dirty region.

[ v2: also update bounding box ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2012-09-05 08:52:23 +02:00
parent b1af98ba3e
commit c60319a3aa

View file

@ -164,7 +164,8 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
#endif #endif
} }
static void qemu_spice_create_update(SimpleSpiceDisplay *ssd) static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
QXLRect *rect)
{ {
SimpleSpiceUpdate *update; SimpleSpiceUpdate *update;
QXLDrawable *drawable; QXLDrawable *drawable;
@ -174,24 +175,20 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
int by, bw, bh; int by, bw, bh;
struct timespec time_space; struct timespec time_space;
if (qemu_spice_rect_is_empty(&ssd->dirty)) {
return;
};
trace_qemu_spice_create_update( trace_qemu_spice_create_update(
ssd->dirty.left, ssd->dirty.right, rect->left, rect->right,
ssd->dirty.top, ssd->dirty.bottom); rect->top, rect->bottom);
update = g_malloc0(sizeof(*update)); update = g_malloc0(sizeof(*update));
drawable = &update->drawable; drawable = &update->drawable;
image = &update->image; image = &update->image;
cmd = &update->ext.cmd; cmd = &update->ext.cmd;
bw = ssd->dirty.right - ssd->dirty.left; bw = rect->right - rect->left;
bh = ssd->dirty.bottom - ssd->dirty.top; bh = rect->bottom - rect->top;
update->bitmap = g_malloc(bw * bh * 4); update->bitmap = g_malloc(bw * bh * 4);
drawable->bbox = ssd->dirty; drawable->bbox = *rect;
drawable->clip.type = SPICE_CLIP_TYPE_NONE; drawable->clip.type = SPICE_CLIP_TYPE_NONE;
drawable->effect = QXL_EFFECT_OPAQUE; drawable->effect = QXL_EFFECT_OPAQUE;
drawable->release_info.id = (uintptr_t)update; drawable->release_info.id = (uintptr_t)update;
@ -226,8 +223,8 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
} }
src = ds_get_data(ssd->ds) + src = ds_get_data(ssd->ds) +
ssd->dirty.top * ds_get_linesize(ssd->ds) + rect->top * ds_get_linesize(ssd->ds) +
ssd->dirty.left * ds_get_bytes_per_pixel(ssd->ds); rect->left * ds_get_bytes_per_pixel(ssd->ds);
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); qemu_pf_conv_run(ssd->conv, dst, src, bw);
@ -238,10 +235,18 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
cmd->type = QXL_CMD_DRAW; cmd->type = QXL_CMD_DRAW;
cmd->data = (uintptr_t)drawable; cmd->data = (uintptr_t)drawable;
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
QTAILQ_INSERT_TAIL(&ssd->updates, update, next); QTAILQ_INSERT_TAIL(&ssd->updates, update, next);
} }
static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
{
if (qemu_spice_rect_is_empty(&ssd->dirty)) {
return;
};
qemu_spice_create_one_update(ssd, &ssd->dirty);
memset(&ssd->dirty, 0, sizeof(ssd->dirty));
}
/* /*
* Called from spice server thread context (via interface_release_ressource) * Called from spice server thread context (via interface_release_ressource)
* We do *not* hold the global qemu mutex here, so extra care is needed * We do *not* hold the global qemu mutex here, so extra care is needed