summaryrefslogtreecommitdiff
path: root/src/cairo-xlib-core-compositor.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-09 09:43:31 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-11 12:43:43 +0000
commit5045155de6fa7fcafc345365320f97d6a87ee063 (patch)
tree84fa1326d342816c1bc14604be5fba159ae118f6 /src/cairo-xlib-core-compositor.c
parent20a1676c28e57686dda3f7afab035d40228c0f6f (diff)
downloadcairo-5045155de6fa7fcafc345365320f97d6a87ee063.tar.gz
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>
Diffstat (limited to 'src/cairo-xlib-core-compositor.c')
-rw-r--r--src/cairo-xlib-core-compositor.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cairo-xlib-core-compositor.c b/src/cairo-xlib-core-compositor.c
index fe871ab40..191c9b93f 100644
--- a/src/cairo-xlib-core-compositor.c
+++ b/src/cairo-xlib-core-compositor.c
@@ -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,