Commit c4cc4ccd authored by Brendan Shanks's avatar Brendan Shanks Committed by Jeremy White

Use separate buffer for primary surface to fix graphical corruption

The 'display->fullscreen' SHM segment was previously being used for both
x11spice's internal change scanning and as the spice primary surface.
I don't think spice wants anything else writing to the primary surface,
and this caused sporadic test failures and graphical corruption.

Create a separate SHM segment 'display->primary' and use it only for the
primary surface.
Signed-off-by: Brendan Shanks's avatarBrendan Shanks <bshanks@codeweavers.com>
Acked-by: Jeremy White's avatarJeremy White <jwhite@codeweavers.com>
parent e2bcd346
......@@ -461,12 +461,25 @@ void destroy_shm_image(display_t *d, shm_image_t *shmi)
int display_create_screen_images(display_t *d)
{
/* 'primary' and 'fullscreen' don't need to be SHM, normal buffers would work
* fine. Using SHM for all buffers is simpler though, and has no real downsides.
*/
d->primary = create_shm_image(d, 0, 0);
if (!d->primary) {
return X11SPICE_ERR_NOSHM;
}
d->fullscreen = create_shm_image(d, 0, 0);
if (!d->fullscreen)
if (!d->fullscreen) {
destroy_shm_image(d, d->primary);
d->primary = NULL;
return X11SPICE_ERR_NOSHM;
}
d->scanline = create_shm_image(d, 0, 1);
if (!d->scanline) {
destroy_shm_image(d, d->primary);
d->primary = NULL;
destroy_shm_image(d, d->fullscreen);
d->fullscreen = NULL;
return X11SPICE_ERR_NOSHM;
......@@ -477,6 +490,11 @@ int display_create_screen_images(display_t *d)
void display_destroy_screen_images(display_t *d)
{
if (d->primary) {
destroy_shm_image(d, d->primary);
d->primary = NULL;
}
if (d->fullscreen) {
destroy_shm_image(d, d->fullscreen);
d->fullscreen = NULL;
......
......@@ -55,6 +55,7 @@ typedef struct {
const xcb_query_extension_reply_t *xfixes_ext;
shm_image_t *primary;
shm_image_t *fullscreen;
shm_image_t *scanline;
......
......@@ -61,7 +61,7 @@ typedef struct {
/*----------------------------------------------------------------------------
** Prototypes
**--------------------------------------------------------------------------*/
int spice_start(spice_t *s, options_t *options, shm_image_t *fullscreen);
int spice_start(spice_t *s, options_t *options, shm_image_t *primary);
void spice_end(spice_t *s);
int spice_create_primary(spice_t *s, int w, int h, int bytes_per_line, void *shmaddr);
void spice_destroy_primary(spice_t *s);
......
......@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
/*------------------------------------------------------------------------
** Start up a spice server
**----------------------------------------------------------------------*/
rc = spice_start(&session.spice, &session.options, session.display.fullscreen);
rc = spice_start(&session.spice, &session.options, session.display.primary);
if (rc)
goto exit;
spice_started = 1;
......
......@@ -352,7 +352,7 @@ int session_recreate_primary(session_t *s)
rc = display_create_screen_images(&s->display);
if (rc == 0) {
shm_image_t *f = s->display.fullscreen;
shm_image_t *f = s->display.primary;
rc = spice_create_primary(&s->spice, f->w, f->h, f->bytes_per_line, f->shmaddr);
}
......
......@@ -633,7 +633,7 @@ static int try_listen(spice_t *s, options_t *options)
return 0;
}
int spice_start(spice_t *s, options_t *options, shm_image_t *fullscreen)
int spice_start(spice_t *s, options_t *options, shm_image_t *primary)
{
int rc;
......@@ -678,8 +678,8 @@ int spice_start(spice_t *s, options_t *options, shm_image_t *fullscreen)
spice_server_vm_start(s->server);
rc = spice_create_primary(s, fullscreen->w, fullscreen->h,
fullscreen->bytes_per_line, fullscreen->shmaddr);
rc = spice_create_primary(s, primary->w, primary->h,
primary->bytes_per_line, primary->shmaddr);
return rc;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment