bug 974575 - support color glyphs in cairo_image_surface's _composite_glyphs function. r=jrmuizel
☠☠ backed out by 5cc5d321b2b6 ☠ ☠
authorJonathan Kew <jkew@mozilla.com>
Wed, 05 Mar 2014 18:33:21 +0000
changeset 189284 23ab61f4bba1858d8434d034e3af4ae6dd1eddd6
parent 189283 d0f6a0106f432b6b1ea131450103d57d94f3e93c
child 189285 dc13389afbe51fbfe7ace429c50006c6c9bf76c0
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs974575
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 974575 - support color glyphs in cairo_image_surface's _composite_glyphs function. r=jrmuizel
gfx/cairo/cairo/src/cairo-image-surface.c
--- a/gfx/cairo/cairo/src/cairo-image-surface.c
+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
@@ -3953,26 +3953,16 @@ static cairo_status_t
     composite_glyphs_info_t *info = closure;
     cairo_scaled_glyph_t *glyph_cache[64];
     pixman_op_t pixman_op = _pixman_operator (op);
     pixman_image_t *src = NULL;
     int src_x = 0, src_y = 0;
     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;
 
     _cairo_scaled_font_freeze_cache (info->font);
     for (i = 0; i < info->num_glyphs; i++) {
 	int x, y;
 	cairo_image_surface_t *glyph_surface;
 	cairo_scaled_glyph_t *scaled_glyph;
@@ -4013,27 +4003,53 @@ static cairo_status_t
 
 	    y1 = y;
 	    if (y1 < extents->y)
 		y1 = extents->y;
 	    y2 = y + glyph_surface->height;
 	    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;
 }
 
 static cairo_int_status_t
 _cairo_image_surface_glyphs (void			*abstract_surface,
 			     cairo_operator_t		 op,
 			     const cairo_pattern_t	*source,