diff options
author | Søren Sandmann <ssp@redhat.com> | 2010-10-19 15:43:07 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-01-26 08:12:19 -0500 |
commit | efd9f6a3e379ed02c3eec059e7f26f54a82649e1 (patch) | |
tree | c401c5570b9718735087474623ff5232c780dd1f | |
parent | 31d4f0ce6208c78db4782c0d39dbe29fb8e25168 (diff) |
Move the surface lists into qxl_screen_t
That way things don't break horribly if you have multiple graphics cards
-rw-r--r-- | src/qxl.h | 13 | ||||
-rw-r--r-- | src/qxl_driver.c | 4 | ||||
-rw-r--r-- | src/qxl_surface.c | 56 |
3 files changed, 34 insertions, 39 deletions
@@ -691,12 +691,8 @@ struct _qxl_screen_t uint8_t vram_mem_slot; - union - { - PixmapPtr copy_source; - Pixel solid_pixel; - RegionRec access_region; - } u; + qxl_surface_t * all_surfaces; + qxl_surface_t * free_surfaces; }; static inline uint64_t @@ -769,7 +765,7 @@ void qxl_surface_destroy (qxl_surface_t *surface); /* Call this when the notification comes back from the device * that the surface has been destroyed */ -void qxl_surface_recycle (uint32_t id); +void qxl_surface_recycle (qxl_screen_t *qxl, uint32_t id); /* send anything pending to the other side */ void qxl_surface_flush (qxl_surface_t *surface); @@ -801,7 +797,8 @@ void qxl_surface_copy (qxl_surface_t *dest, Bool qxl_surface_put_image (qxl_surface_t *dest, int x, int y, int width, int height, const char *src, int src_pitch); -void qxl_surface_unref (uint32_t surface_id); +void qxl_surface_unref (qxl_screen_t *qxl, + uint32_t surface_id); extern DevPrivateKeyRec uxa_pixmap_index; diff --git a/src/qxl_driver.c b/src/qxl_driver.c index 81a3623..3f3f99a 100644 --- a/src/qxl_driver.c +++ b/src/qxl_driver.c @@ -86,7 +86,7 @@ qxl_garbage_collect (qxl_screen_t *qxl) if (image->descriptor.type == QXL_IMAGE_TYPE_SURFACE) { - qxl_surface_unref (image->u.surface_id); + qxl_surface_unref (qxl, image->u.surface_id); qxl_free (qxl->mem, image); } else @@ -96,7 +96,7 @@ qxl_garbage_collect (qxl_screen_t *qxl) } else if (is_surface && surface_cmd->type == QXL_SURFACE_CMD_DESTROY) { - qxl_surface_recycle (surface_cmd->surface_id); + qxl_surface_recycle (qxl, surface_cmd->surface_id); } id = info->next; diff --git a/src/qxl_surface.c b/src/qxl_surface.c index 359a1c9..e02c17e 100644 --- a/src/qxl_surface.c +++ b/src/qxl_surface.c @@ -26,9 +26,6 @@ struct qxl_surface_t } u; }; -static qxl_surface_t *all_surfaces; -static qxl_surface_t *free_surfaces; - #if 0 void qxl_surface_free_all (qxl_screen_t *qxl) @@ -49,12 +46,12 @@ qxl_surface_init (qxl_screen_t *qxl, int n_surfaces) { int i; - if (!all_surfaces) - all_surfaces = calloc (n_surfaces, sizeof (qxl_surface_t)); + if (!qxl->all_surfaces) + qxl->all_surfaces = calloc (n_surfaces, sizeof (qxl_surface_t)); else - memset (all_surfaces, 0, n_surfaces * sizeof (qxl_surface_t)); + memset (qxl->all_surfaces, 0, n_surfaces * sizeof (qxl_surface_t)); - free_surfaces = NULL; + qxl->free_surfaces = NULL; #if 0 ErrorF ("surface init\n"); @@ -62,39 +59,39 @@ qxl_surface_init (qxl_screen_t *qxl, int n_surfaces) for (i = 0; i < n_surfaces; ++i) { - all_surfaces[i].id = i; - all_surfaces[i].qxl = qxl; - all_surfaces[i].dev_image = NULL; - all_surfaces[i].host_image = NULL; + qxl->all_surfaces[i].id = i; + qxl->all_surfaces[i].qxl = qxl; + qxl->all_surfaces[i].dev_image = NULL; + qxl->all_surfaces[i].host_image = NULL; - REGION_INIT (NULL, &(all_surfaces[i].access_region), (BoxPtr)NULL, 0); + REGION_INIT (NULL, &(qxl->all_surfaces[i].access_region), (BoxPtr)NULL, 0); if (i) /* surface 0 is the primary surface */ { - all_surfaces[i].next = free_surfaces; - free_surfaces = &(all_surfaces[i]); - all_surfaces[i].in_use = FALSE; + qxl->all_surfaces[i].next = qxl->free_surfaces; + qxl->free_surfaces = &(qxl->all_surfaces[i]); + qxl->all_surfaces[i].in_use = FALSE; } } } static qxl_surface_t * -surface_new (void) +surface_new (qxl_screen_t *qxl) { qxl_surface_t *result = NULL; - if (free_surfaces) + if (qxl->free_surfaces) { qxl_surface_t *s; - result = free_surfaces; - free_surfaces = free_surfaces->next; + result = qxl->free_surfaces; + qxl->free_surfaces = qxl->free_surfaces->next; result->next = NULL; result->in_use = TRUE; result->ref_count = 1; - for (s = free_surfaces; s; s = s->next) + for (s = qxl->free_surfaces; s; s = s->next) { if (s->id == result->id) ErrorF ("huh: %d to be returned, but %d is in list\n", @@ -108,14 +105,14 @@ surface_new (void) } static void -surface_free (qxl_surface_t *surface) +surface_free (qxl_screen_t *qxl, qxl_surface_t *surface) { #if 0 ErrorF (" Adding %d to free list\n", surface->id); #endif - surface->next = free_surfaces; - free_surfaces = surface; + surface->next = qxl->free_surfaces; + qxl->free_surfaces = surface; } qxl_surface_t * @@ -357,7 +354,7 @@ qxl_surface_create (qxl_screen_t *qxl, } retry: - surface = surface_new(); + surface = surface_new (qxl); if (!surface) { if (!qxl_handle_oom (qxl)) @@ -533,17 +530,17 @@ qxl_surface_destroy (qxl_surface_t *surface) } void -qxl_surface_unref (uint32_t id) +qxl_surface_unref (qxl_screen_t *qxl, uint32_t id) { - qxl_surface_t *surface = all_surfaces + id; + qxl_surface_t *surface = qxl->all_surfaces + id; qxl_surface_destroy (surface); } void -qxl_surface_recycle (uint32_t id) +qxl_surface_recycle (qxl_screen_t *qxl, uint32_t id) { - qxl_surface_t *surface = all_surfaces + id; + qxl_surface_t *surface = qxl->all_surfaces + id; #if 0 ErrorF ("recycle %d\n", id); @@ -553,7 +550,8 @@ qxl_surface_recycle (uint32_t id) ErrorF ("freeing %p\n", surface->address); #endif qxl_free (surface->qxl->surf_mem, surface->address); - surface_free (surface); + + surface_free (qxl, surface); } /* send anything pending to the other side */ |