image: Fix bugs related to glyph mask creation

In addition to fixing a bug 7d8d98b91c releated to
expanding a8 glyphs into a8r8g8b8, this commit also added an
optimization where if the first glyph had format a8r8g8b8, the mask
was created in this format from the beginning instead of later
converting from a8 to a8r8g8b8.

However, the optimization had two bugs in it:

(1) The computed stride was 3 * width, not 4 * times width, and
(2) In the case where the mask was allocated on the stack, it was
    allocated as PIXMAN_a8 and not a8r8g8b8.

The commit fixes both bugs.
This commit is contained in:
Søren Sandmann Pedersen 2012-06-01 08:13:17 +01:00 committed by Chris Wilson
parent c0a92bf832
commit 4b5d3436a3

View file

@ -854,7 +854,7 @@ composite_glyphs_via_mask (void *_dst,
i = (info->extents.width + 3) & ~3;
if (scaled_glyph->surface->base.content & CAIRO_CONTENT_COLOR) {
format = PIXMAN_a8r8g8b8;
i = info->extents.width * 3;
i = info->extents.width * 4;
}
if (i * info->extents.height > (int) sizeof (buf)) {
@ -864,7 +864,7 @@ composite_glyphs_via_mask (void *_dst,
NULL, 0);
} else {
memset (buf, 0, i * info->extents.height);
mask = pixman_image_create_bits (PIXMAN_a8,
mask = pixman_image_create_bits (format,
info->extents.width,
info->extents.height,
(uint32_t *)buf, i);