spice: stop using DisplayState

Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2013-02-28 16:42:28 +01:00
parent 8db9bae94e
commit 71874c1751
4 changed files with 20 additions and 18 deletions

View File

@ -236,7 +236,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
return 1; return 1;
} }
if (!dpy_cursor_define_supported(qxl->ssd.ds)) { if (!dpy_cursor_define_supported(qxl->ssd.dcl.ds)) {
return 0; return 0;
} }

View File

@ -1782,7 +1782,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
case QXL_MODE_COMPAT: case QXL_MODE_COMPAT:
case QXL_MODE_NATIVE: case QXL_MODE_NATIVE:
qxl_render_update(qxl); qxl_render_update(qxl);
ppm_save(filename, qxl->ssd.ds->surface, errp); ppm_save(filename, qxl->ssd.ds, errp);
break; break;
case QXL_MODE_VGA: case QXL_MODE_VGA:
vga->screen_dump(vga, filename, cswitch, errp); vga->screen_dump(vga, filename, cswitch, errp);
@ -1881,6 +1881,7 @@ static void display_switch(DisplayChangeListener *dcl,
{ {
PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl); PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
qxl->ssd.ds = surface;
if (qxl->mode == QXL_MODE_VGA) { if (qxl->mode == QXL_MODE_VGA) {
qemu_spice_display_switch(&qxl->ssd, surface); qemu_spice_display_switch(&qxl->ssd, surface);
} }

View File

@ -71,7 +71,7 @@ typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
typedef struct SimpleSpiceUpdate SimpleSpiceUpdate; typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
struct SimpleSpiceDisplay { struct SimpleSpiceDisplay {
DisplayState *ds; DisplaySurface *ds;
DisplayChangeListener dcl; DisplayChangeListener dcl;
void *buf; void *buf;
int bufsize; int bufsize;

View File

@ -214,10 +214,10 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
static void qemu_spice_create_update(SimpleSpiceDisplay *ssd) static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
{ {
static const int blksize = 32; static const int blksize = 32;
int blocks = (ds_get_width(ssd->ds) + blksize - 1) / blksize; int blocks = (surface_width(ssd->ds) + blksize - 1) / blksize;
int dirty_top[blocks]; int dirty_top[blocks];
int y, yoff, x, xoff, blk, bw; int y, yoff, x, xoff, blk, bw;
int bpp = ds_get_bytes_per_pixel(ssd->ds); int bpp = surface_bytes_per_pixel(ssd->ds);
uint8_t *guest, *mirror; uint8_t *guest, *mirror;
if (qemu_spice_rect_is_empty(&ssd->dirty)) { if (qemu_spice_rect_is_empty(&ssd->dirty)) {
@ -225,19 +225,19 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
}; };
if (ssd->surface == NULL) { if (ssd->surface == NULL) {
ssd->surface = pixman_image_ref(ds_get_image(ssd->ds)); ssd->surface = pixman_image_ref(ssd->ds->image);
ssd->mirror = qemu_pixman_mirror_create(ds_get_format(ssd->ds), ssd->mirror = qemu_pixman_mirror_create(ssd->ds->format,
ds_get_image(ssd->ds)); ssd->ds->image);
} }
for (blk = 0; blk < blocks; blk++) { for (blk = 0; blk < blocks; blk++) {
dirty_top[blk] = -1; dirty_top[blk] = -1;
} }
guest = ds_get_data(ssd->ds); guest = surface_data(ssd->ds);
mirror = (void *)pixman_image_get_data(ssd->mirror); mirror = (void *)pixman_image_get_data(ssd->mirror);
for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) { for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) {
yoff = y * ds_get_linesize(ssd->ds); yoff = y * surface_stride(ssd->ds);
for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) { for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) {
xoff = x * bpp; xoff = x * bpp;
blk = x / blksize; blk = x / blksize;
@ -312,11 +312,11 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
memset(&surface, 0, sizeof(surface)); memset(&surface, 0, sizeof(surface));
dprint(1, "%s: %dx%d\n", __FUNCTION__, dprint(1, "%s: %dx%d\n", __FUNCTION__,
ds_get_width(ssd->ds), ds_get_height(ssd->ds)); surface_width(ssd->ds), surface_height(ssd->ds));
surface.format = SPICE_SURFACE_FMT_32_xRGB; surface.format = SPICE_SURFACE_FMT_32_xRGB;
surface.width = ds_get_width(ssd->ds); surface.width = surface_width(ssd->ds);
surface.height = ds_get_height(ssd->ds); surface.height = surface_height(ssd->ds);
surface.stride = -surface.width * 4; surface.stride = -surface.width * 4;
surface.mouse_mode = true; surface.mouse_mode = true;
surface.flags = 0; surface.flags = 0;
@ -336,7 +336,6 @@ void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)
void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds) void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
{ {
ssd->ds = ds;
qemu_mutex_init(&ssd->lock); qemu_mutex_init(&ssd->lock);
QTAILQ_INIT(&ssd->updates); QTAILQ_INIT(&ssd->updates);
ssd->mouse_x = -1; ssd->mouse_x = -1;
@ -383,6 +382,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
} }
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
ssd->ds = surface;
while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) { while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
QTAILQ_REMOVE(&ssd->updates, update, next); QTAILQ_REMOVE(&ssd->updates, update, next);
qemu_spice_destroy_update(ssd, update); qemu_spice_destroy_update(ssd, update);
@ -398,12 +398,12 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd) void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
{ {
if (ssd->cursor) { if (ssd->cursor) {
dpy_cursor_define(ssd->ds, ssd->cursor); dpy_cursor_define(ssd->dcl.ds, ssd->cursor);
cursor_put(ssd->cursor); cursor_put(ssd->cursor);
ssd->cursor = NULL; ssd->cursor = NULL;
} }
if (ssd->mouse_x != -1 && ssd->mouse_y != -1) { if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
dpy_mouse_set(ssd->ds, ssd->mouse_x, ssd->mouse_y, 1); dpy_mouse_set(ssd->dcl.ds, ssd->mouse_x, ssd->mouse_y, 1);
ssd->mouse_x = -1; ssd->mouse_x = -1;
ssd->mouse_y = -1; ssd->mouse_y = -1;
} }
@ -415,7 +415,7 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
vga_hw_update(); vga_hw_update();
qemu_mutex_lock(&ssd->lock); qemu_mutex_lock(&ssd->lock);
if (QTAILQ_EMPTY(&ssd->updates)) { if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
qemu_spice_create_update(ssd); qemu_spice_create_update(ssd);
ssd->notify++; ssd->notify++;
} }
@ -623,8 +623,9 @@ void qemu_spice_display_init(DisplayState *ds)
assert(ssd->worker); assert(ssd->worker);
qemu_spice_create_host_memslot(ssd); qemu_spice_create_host_memslot(ssd);
qemu_spice_create_host_primary(ssd);
ssd->dcl.ops = &display_listener_ops; ssd->dcl.ops = &display_listener_ops;
register_displaychangelistener(ds, &ssd->dcl); register_displaychangelistener(ds, &ssd->dcl);
qemu_spice_create_host_primary(ssd);
} }