xlib: Do not upload inplace if the image does not match the surface format

Currently we perform the conversion using XPutPixel which is hideously
slow and so it is faster to create a new surface that matches the
format correctly, upload and allow X to perform the conversion. In other
words disable the "fast" path for format mismatches.

Based on a patch by Ginn Chen <ginn.chen@oracle.com>

Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=716462
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-01-09 09:43:31 +00:00
parent 20a1676c28
commit 5045155de6

View file

@ -268,6 +268,19 @@ static cairo_bool_t image_upload_box (cairo_box_t *box, void *closure)
x, y) == CAIRO_STATUS_SUCCESS;
}
static cairo_bool_t
surface_matches_image_format (cairo_xlib_surface_t *surface,
cairo_image_surface_t *image)
{
cairo_format_masks_t format;
return (_pixman_format_to_masks (image->pixman_format, &format) &&
(format.alpha_mask == surface->a_mask || surface->a_mask == 0) &&
(format.red_mask == surface->r_mask || surface->r_mask == 0) &&
(format.green_mask == surface->g_mask || surface->g_mask == 0) &&
(format.blue_mask == surface->b_mask || surface->b_mask == 0))
}
static cairo_status_t
upload_image_inplace (cairo_xlib_surface_t *dst,
const cairo_pattern_t *source,
@ -291,6 +304,9 @@ upload_image_inplace (cairo_xlib_surface_t *dst,
if (image->depth != dst->depth)
return CAIRO_INT_STATUS_UNSUPPORTED;
if (! surface_matches_image_format (dst, image))
return CAIRO_INT_STATUS_UNSUPPORTED;
/* XXX subsurface */
if (! _cairo_matrix_is_integer_translation (&source->matrix,