diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-17 21:33:54 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-17 23:43:26 +0100 |
commit | c068691ff57c2f6cd750a54db17393c0e132cb00 (patch) | |
tree | 572c6165864275dc7b1a0d002a80dd88899ef8e9 /src/cairo-xlib-surface-shm.c | |
parent | bc38108947a684fb6e7af99a48ebc8f79d05856a (diff) | |
download | cairo-c068691ff57c2f6cd750a54db17393c0e132cb00.tar.gz |
xlib/shm: Use an impromptu upload ShmSegment
Reduce the number of copies required for uploading large image data.
Ultimately we want the client to allocate the similar-image itself to
acheive zero copy, this is just an intermediate step for legacy clients.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-xlib-surface-shm.c')
-rw-r--r-- | src/cairo-xlib-surface-shm.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/cairo-xlib-surface-shm.c b/src/cairo-xlib-surface-shm.c index cdb91c836..c8a8ebd4f 100644 --- a/src/cairo-xlib-surface-shm.c +++ b/src/cairo-xlib-surface-shm.c @@ -561,9 +561,7 @@ _cairo_xlib_shm_surface_finish (void *abstract_surface) shm->info->last_request = shm->active; _pqueue_push (&display->shm->info, shm->info); } else { - cairo_xlib_shm_t *pool = shm->info->pool; - - _cairo_mempool_free (&pool->mem, shm->info->mem); + _cairo_mempool_free (&shm->info->pool->mem, shm->info->mem); free (shm->info); _cairo_xlib_shm_pool_cleanup (display); @@ -673,6 +671,8 @@ _cairo_xlib_shm_surface_create (cairo_xlib_surface_t *other, shm->active = shm->info->last_request; shm->idle = -5; + assert (shm->active == 0 || will_sync); + cairo_device_release (&display->base); return shm; @@ -939,9 +939,25 @@ out: } cairo_surface_t * -_cairo_xlib_surface_create_shm_image (cairo_xlib_surface_t *surface, - pixman_format_code_t format, - int width, int height) +_cairo_xlib_surface_create_shm (cairo_xlib_surface_t *other, + pixman_format_code_t format, + int width, int height) +{ + cairo_surface_t *surface; + + surface = NULL; + if (has_shm (other)) + surface = &_cairo_xlib_shm_surface_create (other, format, + width, height, FALSE, + has_shm_pixmaps (other))->image.base; + + return surface; +} + +cairo_surface_t * +_cairo_xlib_surface_create_shm__image (cairo_xlib_surface_t *surface, + pixman_format_code_t format, + int width, int height) { if (! has_shm(surface)) return NULL; @@ -958,13 +974,10 @@ _cairo_xlib_surface_create_similar_shm (void *other, { cairo_surface_t *surface; - surface = NULL; - if (has_shm (other)) - surface = &_cairo_xlib_shm_surface_create (other, - _cairo_format_to_pixman_format_code (format), - width, height, FALSE, - has_shm_pixmaps (other))->image.base; - if (surface == NULL) + surface = _cairo_xlib_surface_create_shm (other, + _cairo_format_to_pixman_format_code (format), + width, height); + if (surface == NULL) surface = cairo_image_surface_create (format, width, height); return surface; |