Skip to content

Commit

Permalink
spice: stop using DisplayState
Browse files Browse the repository at this point in the history
Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
kraxel committed Mar 18, 2013
1 parent 8db9bae commit 71874c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion hw/qxl-render.c
Expand Up @@ -236,7 +236,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
return 1;
}

if (!dpy_cursor_define_supported(qxl->ssd.ds)) {
if (!dpy_cursor_define_supported(qxl->ssd.dcl.ds)) {
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion hw/qxl.c
Expand Up @@ -1782,7 +1782,7 @@ static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
case QXL_MODE_COMPAT:
case QXL_MODE_NATIVE:
qxl_render_update(qxl);
ppm_save(filename, qxl->ssd.ds->surface, errp);
ppm_save(filename, qxl->ssd.ds, errp);
break;
case QXL_MODE_VGA:
vga->screen_dump(vga, filename, cswitch, errp);
Expand Down Expand Up @@ -1881,6 +1881,7 @@ static void display_switch(DisplayChangeListener *dcl,
{
PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);

qxl->ssd.ds = surface;
if (qxl->mode == QXL_MODE_VGA) {
qemu_spice_display_switch(&qxl->ssd, surface);
}
Expand Down
2 changes: 1 addition & 1 deletion include/ui/spice-display.h
Expand Up @@ -71,7 +71,7 @@ typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;

struct SimpleSpiceDisplay {
DisplayState *ds;
DisplaySurface *ds;
DisplayChangeListener dcl;
void *buf;
int bufsize;
Expand Down
31 changes: 16 additions & 15 deletions ui/spice-display.c
Expand Up @@ -214,30 +214,30 @@ static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
{
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 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;

if (qemu_spice_rect_is_empty(&ssd->dirty)) {
return;
};

if (ssd->surface == NULL) {
ssd->surface = pixman_image_ref(ds_get_image(ssd->ds));
ssd->mirror = qemu_pixman_mirror_create(ds_get_format(ssd->ds),
ds_get_image(ssd->ds));
ssd->surface = pixman_image_ref(ssd->ds->image);
ssd->mirror = qemu_pixman_mirror_create(ssd->ds->format,
ssd->ds->image);
}

for (blk = 0; blk < blocks; blk++) {
dirty_top[blk] = -1;
}

guest = ds_get_data(ssd->ds);
guest = surface_data(ssd->ds);
mirror = (void *)pixman_image_get_data(ssd->mirror);
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) {
xoff = x * bpp;
blk = x / blksize;
Expand Down Expand Up @@ -312,11 +312,11 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
memset(&surface, 0, sizeof(surface));

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.width = ds_get_width(ssd->ds);
surface.height = ds_get_height(ssd->ds);
surface.width = surface_width(ssd->ds);
surface.height = surface_height(ssd->ds);
surface.stride = -surface.width * 4;
surface.mouse_mode = true;
surface.flags = 0;
Expand All @@ -336,7 +336,6 @@ void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)

void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
{
ssd->ds = ds;
qemu_mutex_init(&ssd->lock);
QTAILQ_INIT(&ssd->updates);
ssd->mouse_x = -1;
Expand Down Expand Up @@ -383,6 +382,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
}

qemu_mutex_lock(&ssd->lock);
ssd->ds = surface;
while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
QTAILQ_REMOVE(&ssd->updates, update, next);
qemu_spice_destroy_update(ssd, update);
Expand All @@ -398,12 +398,12 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
{
if (ssd->cursor) {
dpy_cursor_define(ssd->ds, ssd->cursor);
dpy_cursor_define(ssd->dcl.ds, ssd->cursor);
cursor_put(ssd->cursor);
ssd->cursor = NULL;
}
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_y = -1;
}
Expand All @@ -415,7 +415,7 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
vga_hw_update();

qemu_mutex_lock(&ssd->lock);
if (QTAILQ_EMPTY(&ssd->updates)) {
if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
qemu_spice_create_update(ssd);
ssd->notify++;
}
Expand Down Expand Up @@ -623,8 +623,9 @@ void qemu_spice_display_init(DisplayState *ds)
assert(ssd->worker);

qemu_spice_create_host_memslot(ssd);
qemu_spice_create_host_primary(ssd);

ssd->dcl.ops = &display_listener_ops;
register_displaychangelistener(ds, &ssd->dcl);

qemu_spice_create_host_primary(ssd);
}

0 comments on commit 71874c1

Please sign in to comment.