diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-17 20:57:04 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-17 23:20:01 +0100 |
commit | bc38108947a684fb6e7af99a48ebc8f79d05856a (patch) | |
tree | 90a4964699a955902f7616dfd158f09679f86f12 /src/cairo-xlib-render-compositor.c | |
parent | 4af7a1c8637f3008a2265e063ab990eec07e02dd (diff) | |
download | cairo-bc38108947a684fb6e7af99a48ebc8f79d05856a.tar.gz |
xlib/shm: Limit use of the impromptu fallback pixmap for uploads
We want to avoid unnecessary readback and so only want to use the
ShmPixmap when uploading the complete surface.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-xlib-render-compositor.c')
-rw-r--r-- | src/cairo-xlib-render-compositor.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c index f76db24a8..1fc1e345e 100644 --- a/src/cairo-xlib-render-compositor.c +++ b/src/cairo-xlib-render-compositor.c @@ -205,6 +205,28 @@ copy_image_boxes (void *_dst, return CAIRO_STATUS_SUCCESS; } +static cairo_bool_t +boxes_cover_surface (cairo_boxes_t *boxes, + cairo_xlib_surface_t *surface) +{ + cairo_box_t *b; + + if (boxes->num_boxes != 1) + return FALSE; + + b = &boxes->chunks.base[0]; + + if (_cairo_fixed_integer_part (b->p1.x) > 0 || + _cairo_fixed_integer_part (b->p1.y) > 0) + return FALSE; + + if (_cairo_fixed_integer_part (b->p2.x) < surface->width || + _cairo_fixed_integer_part (b->p2.y) < surface->height) + return FALSE; + + return TRUE; +} + static cairo_int_status_t draw_image_boxes (void *_dst, cairo_image_surface_t *image, @@ -220,7 +242,11 @@ draw_image_boxes (void *_dst, _cairo_xlib_shm_surface_get_pixmap (&image->base)) return copy_image_boxes (dst, image, boxes, dx, dy); - shm = (cairo_image_surface_t *) _cairo_xlib_surface_get_shm (dst); + shm = NULL; + if (boxes_cover_surface (boxes, dst)) + shm = (cairo_image_surface_t *) _cairo_xlib_surface_get_shm (dst, TRUE); + if (shm == NULL && dst->shm) + shm = (cairo_image_surface_t *) _cairo_xlib_surface_get_shm (dst, FALSE); if (shm) { for (chunk = &boxes->chunks; chunk; chunk = chunk->next) { for (i = 0; i < chunk->count; i++) { |