From 3a0e99a68b968ff7f9484f38bd78d9f06f890585 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Tue, 4 Mar 2014 05:37:40 +0000 Subject: [PATCH] bug 974575 - support color glyphs in cairo_image_surface's _composite_glyphs function. r=jrmuizel --- gfx/cairo/cairo/src/cairo-image-surface.c | 50 +++++++++++++++-------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c index e36d22ae635b..a655f4d67f46 100644 --- a/gfx/cairo/cairo/src/cairo-image-surface.c +++ b/gfx/cairo/cairo/src/cairo-image-surface.c @@ -3958,16 +3958,6 @@ _composite_glyphs (void *closure, cairo_status_t status; int i; - if (pattern != NULL) { - src = _pixman_image_for_pattern (pattern, FALSE, extents, &src_x, &src_y); - src_x -= dst_x; - src_y -= dst_y; - } else { - src = _pixman_white_image (); - } - if (unlikely (src == NULL)) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - memset (glyph_cache, 0, sizeof (glyph_cache)); status = CAIRO_STATUS_SUCCESS; @@ -4018,17 +4008,43 @@ _composite_glyphs (void *closure, if (y2 > extents->y + extents->height) y2 = extents->y + extents->height; - pixman_image_composite32 (pixman_op, - src, glyph_surface->pixman_image, dst, - x1 + src_x, y1 + src_y, - x1 - x, y1 - y, - x1 - dst_x, y1 - dst_y, - x2 - x1, y2 - y1); + if (glyph_surface->format == CAIRO_FORMAT_A8 || + glyph_surface->format == CAIRO_FORMAT_A1) + { + if (unlikely (src == NULL)) { + if (pattern != NULL) { + src = _pixman_image_for_pattern (pattern, FALSE, extents, &src_x, &src_y); + src_x -= dst_x; + src_y -= dst_y; + } else { + src = _pixman_white_image (); + } + if (unlikely (src == NULL)) { + status = _cairo_error (CAIRO_STATUS_NO_MEMORY); + break; + } + } + + pixman_image_composite32 (pixman_op, + src, glyph_surface->pixman_image, dst, + x1 + src_x, y1 + src_y, + x1 - x, y1 - y, + x1 - dst_x, y1 - dst_y, + x2 - x1, y2 - y1); + } else { + pixman_image_composite32 (pixman_op, + glyph_surface->pixman_image, NULL, dst, + x1 - x, y1 - y, + 0, 0, + x1 - dst_x, y1 - dst_y, + x2 - x1, y2 - y1); + } } } _cairo_scaled_font_thaw_cache (info->font); - pixman_image_unref (src); + if (src != NULL) + pixman_image_unref (src); return status; }