--- src/cairo-xlib-surface.c | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 6d593c0..24f3b77 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -1155,6 +1155,7 @@ _draw_image_surface (cairo_xlib_surface_t *surface, cairo_status_t status; cairo_bool_t own_data; GC gc; + int format_to_masks_succeeded; ximage.width = image->width; ximage.height = image->height; @@ -1173,7 +1174,25 @@ _draw_image_surface (cairo_xlib_surface_t *surface, if (unlikely (status)) return status; - if (!_pixman_format_to_masks (image->pixman_format, &image_masks)) + format_to_masks_succeeded = _pixman_format_to_masks (image->pixman_format, &image_masks); + + if (format_to_masks_succeeded && + (image_masks.alpha_mask == surface->a_mask || surface->a_mask == 0) && + (image_masks.red_mask == surface->r_mask || surface->r_mask == 0) && + (image_masks.green_mask == surface->g_mask || surface->g_mask == 0) && + (image_masks.blue_mask == surface->b_mask || surface->b_mask == 0)) + { + int ret; + + ximage.bits_per_pixel = image_masks.bpp; + ximage.bytes_per_line = image->stride; + ximage.data = (char *)image->data; + own_data = FALSE; + + ret = XInitImage (&ximage); + assert (ret != 0); + } + else if (!format_to_masks_succeeded || surface->depth == 16) { pixman_format_code_t intermediate_format; int ret; @@ -1214,21 +1233,6 @@ _draw_image_surface (cairo_xlib_surface_t *surface, ret = XInitImage (&ximage); assert (ret != 0); } - else if ((image_masks.alpha_mask == surface->a_mask || surface->a_mask == 0) && - (image_masks.red_mask == surface->r_mask || surface->r_mask == 0) && - (image_masks.green_mask == surface->g_mask || surface->g_mask == 0) && - (image_masks.blue_mask == surface->b_mask || surface->b_mask == 0)) - { - int ret; - - ximage.bits_per_pixel = image_masks.bpp; - ximage.bytes_per_line = image->stride; - ximage.data = (char *)image->data; - own_data = FALSE; - - ret = XInitImage (&ximage); - assert (ret != 0); - } else { unsigned int stride, rowstride; -- 1.7.2.2