michael@0: /* michael@0: * Copyright 2010, 2012, Soren Sandmann michael@0: * Copyright 2010, 2011, 2012, Red Hat, Inc michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice (including the next michael@0: * paragraph) shall be included in all copies or substantial portions of the michael@0: * Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: * michael@0: * Author: Soren Sandmann michael@0: */ michael@0: michael@0: #ifdef HAVE_CONFIG_H michael@0: #include michael@0: #endif michael@0: #include "pixman-private.h" michael@0: michael@0: #include michael@0: michael@0: typedef struct glyph_metrics_t glyph_metrics_t; michael@0: typedef struct glyph_t glyph_t; michael@0: michael@0: #define TOMBSTONE ((glyph_t *)0x1) michael@0: michael@0: /* XXX: These numbers are arbitrary---we've never done any measurements. michael@0: */ michael@0: #define N_GLYPHS_HIGH_WATER (16384) michael@0: #define N_GLYPHS_LOW_WATER (8192) michael@0: #define HASH_SIZE (2 * N_GLYPHS_HIGH_WATER) michael@0: #define HASH_MASK (HASH_SIZE - 1) michael@0: michael@0: struct glyph_t michael@0: { michael@0: void * font_key; michael@0: void * glyph_key; michael@0: int origin_x; michael@0: int origin_y; michael@0: pixman_image_t * image; michael@0: pixman_link_t mru_link; michael@0: }; michael@0: michael@0: struct pixman_glyph_cache_t michael@0: { michael@0: int n_glyphs; michael@0: int n_tombstones; michael@0: int freeze_count; michael@0: pixman_list_t mru; michael@0: glyph_t * glyphs[HASH_SIZE]; michael@0: }; michael@0: michael@0: static void michael@0: free_glyph (glyph_t *glyph) michael@0: { michael@0: pixman_list_unlink (&glyph->mru_link); michael@0: pixman_image_unref (glyph->image); michael@0: free (glyph); michael@0: } michael@0: michael@0: static unsigned int michael@0: hash (const void *font_key, const void *glyph_key) michael@0: { michael@0: size_t key = (size_t)font_key + (size_t)glyph_key; michael@0: michael@0: /* This hash function is based on one found on Thomas Wang's michael@0: * web page at michael@0: * michael@0: * http://www.concentric.net/~Ttwang/tech/inthash.htm michael@0: * michael@0: */ michael@0: key = (key << 15) - key - 1; michael@0: key = key ^ (key >> 12); michael@0: key = key + (key << 2); michael@0: key = key ^ (key >> 4); michael@0: key = key + (key << 3) + (key << 11); michael@0: key = key ^ (key >> 16); michael@0: michael@0: return key; michael@0: } michael@0: michael@0: static glyph_t * michael@0: lookup_glyph (pixman_glyph_cache_t *cache, michael@0: void *font_key, michael@0: void *glyph_key) michael@0: { michael@0: unsigned idx; michael@0: glyph_t *g; michael@0: michael@0: idx = hash (font_key, glyph_key); michael@0: while ((g = cache->glyphs[idx++ & HASH_MASK])) michael@0: { michael@0: if (g != TOMBSTONE && michael@0: g->font_key == font_key && michael@0: g->glyph_key == glyph_key) michael@0: { michael@0: return g; michael@0: } michael@0: } michael@0: michael@0: return NULL; michael@0: } michael@0: michael@0: static void michael@0: insert_glyph (pixman_glyph_cache_t *cache, michael@0: glyph_t *glyph) michael@0: { michael@0: unsigned idx; michael@0: glyph_t **loc; michael@0: michael@0: idx = hash (glyph->font_key, glyph->glyph_key); michael@0: michael@0: /* Note: we assume that there is room in the table. If there isn't, michael@0: * this will be an infinite loop. michael@0: */ michael@0: do michael@0: { michael@0: loc = &cache->glyphs[idx++ & HASH_MASK]; michael@0: } while (*loc && *loc != TOMBSTONE); michael@0: michael@0: if (*loc == TOMBSTONE) michael@0: cache->n_tombstones--; michael@0: cache->n_glyphs++; michael@0: michael@0: *loc = glyph; michael@0: } michael@0: michael@0: static void michael@0: remove_glyph (pixman_glyph_cache_t *cache, michael@0: glyph_t *glyph) michael@0: { michael@0: unsigned idx; michael@0: michael@0: idx = hash (glyph->font_key, glyph->glyph_key); michael@0: while (cache->glyphs[idx & HASH_MASK] != glyph) michael@0: idx++; michael@0: michael@0: cache->glyphs[idx & HASH_MASK] = TOMBSTONE; michael@0: cache->n_tombstones++; michael@0: cache->n_glyphs--; michael@0: michael@0: /* Eliminate tombstones if possible */ michael@0: if (cache->glyphs[(idx + 1) & HASH_MASK] == NULL) michael@0: { michael@0: while (cache->glyphs[idx & HASH_MASK] == TOMBSTONE) michael@0: { michael@0: cache->glyphs[idx & HASH_MASK] = NULL; michael@0: cache->n_tombstones--; michael@0: idx--; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: clear_table (pixman_glyph_cache_t *cache) michael@0: { michael@0: int i; michael@0: michael@0: for (i = 0; i < HASH_SIZE; ++i) michael@0: { michael@0: glyph_t *glyph = cache->glyphs[i]; michael@0: michael@0: if (glyph && glyph != TOMBSTONE) michael@0: free_glyph (glyph); michael@0: michael@0: cache->glyphs[i] = NULL; michael@0: } michael@0: michael@0: cache->n_glyphs = 0; michael@0: cache->n_tombstones = 0; michael@0: } michael@0: michael@0: PIXMAN_EXPORT pixman_glyph_cache_t * michael@0: pixman_glyph_cache_create (void) michael@0: { michael@0: pixman_glyph_cache_t *cache; michael@0: michael@0: if (!(cache = malloc (sizeof *cache))) michael@0: return NULL; michael@0: michael@0: memset (cache->glyphs, 0, sizeof (cache->glyphs)); michael@0: cache->n_glyphs = 0; michael@0: cache->n_tombstones = 0; michael@0: cache->freeze_count = 0; michael@0: michael@0: pixman_list_init (&cache->mru); michael@0: michael@0: return cache; michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_glyph_cache_destroy (pixman_glyph_cache_t *cache) michael@0: { michael@0: return_if_fail (cache->freeze_count == 0); michael@0: michael@0: clear_table (cache); michael@0: michael@0: free (cache); michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_glyph_cache_freeze (pixman_glyph_cache_t *cache) michael@0: { michael@0: cache->freeze_count++; michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_glyph_cache_thaw (pixman_glyph_cache_t *cache) michael@0: { michael@0: if (--cache->freeze_count == 0 && michael@0: cache->n_glyphs + cache->n_tombstones > N_GLYPHS_HIGH_WATER) michael@0: { michael@0: if (cache->n_tombstones > N_GLYPHS_HIGH_WATER) michael@0: { michael@0: /* More than half the entries are michael@0: * tombstones. Just dump the whole table. michael@0: */ michael@0: clear_table (cache); michael@0: } michael@0: michael@0: while (cache->n_glyphs > N_GLYPHS_LOW_WATER) michael@0: { michael@0: glyph_t *glyph = CONTAINER_OF (glyph_t, mru_link, cache->mru.tail); michael@0: michael@0: remove_glyph (cache, glyph); michael@0: free_glyph (glyph); michael@0: } michael@0: } michael@0: } michael@0: michael@0: PIXMAN_EXPORT const void * michael@0: pixman_glyph_cache_lookup (pixman_glyph_cache_t *cache, michael@0: void *font_key, michael@0: void *glyph_key) michael@0: { michael@0: return lookup_glyph (cache, font_key, glyph_key); michael@0: } michael@0: michael@0: PIXMAN_EXPORT const void * michael@0: pixman_glyph_cache_insert (pixman_glyph_cache_t *cache, michael@0: void *font_key, michael@0: void *glyph_key, michael@0: int origin_x, michael@0: int origin_y, michael@0: pixman_image_t *image) michael@0: { michael@0: glyph_t *glyph; michael@0: int32_t width, height; michael@0: michael@0: return_val_if_fail (cache->freeze_count > 0, NULL); michael@0: return_val_if_fail (image->type == BITS, NULL); michael@0: michael@0: width = image->bits.width; michael@0: height = image->bits.height; michael@0: michael@0: if (cache->n_glyphs >= HASH_SIZE) michael@0: return NULL; michael@0: michael@0: if (!(glyph = malloc (sizeof *glyph))) michael@0: return NULL; michael@0: michael@0: glyph->font_key = font_key; michael@0: glyph->glyph_key = glyph_key; michael@0: glyph->origin_x = origin_x; michael@0: glyph->origin_y = origin_y; michael@0: michael@0: if (!(glyph->image = pixman_image_create_bits ( michael@0: image->bits.format, width, height, NULL, -1))) michael@0: { michael@0: free (glyph); michael@0: return NULL; michael@0: } michael@0: michael@0: pixman_image_composite32 (PIXMAN_OP_SRC, michael@0: image, NULL, glyph->image, 0, 0, 0, 0, 0, 0, michael@0: width, height); michael@0: michael@0: if (PIXMAN_FORMAT_A (glyph->image->bits.format) != 0 && michael@0: PIXMAN_FORMAT_RGB (glyph->image->bits.format) != 0) michael@0: { michael@0: pixman_image_set_component_alpha (glyph->image, TRUE); michael@0: } michael@0: michael@0: pixman_list_prepend (&cache->mru, &glyph->mru_link); michael@0: michael@0: _pixman_image_validate (glyph->image); michael@0: insert_glyph (cache, glyph); michael@0: michael@0: return glyph; michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_glyph_cache_remove (pixman_glyph_cache_t *cache, michael@0: void *font_key, michael@0: void *glyph_key) michael@0: { michael@0: glyph_t *glyph; michael@0: michael@0: if ((glyph = lookup_glyph (cache, font_key, glyph_key))) michael@0: { michael@0: remove_glyph (cache, glyph); michael@0: michael@0: free_glyph (glyph); michael@0: } michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_glyph_get_extents (pixman_glyph_cache_t *cache, michael@0: int n_glyphs, michael@0: pixman_glyph_t *glyphs, michael@0: pixman_box32_t *extents) michael@0: { michael@0: int i; michael@0: michael@0: extents->x1 = extents->y1 = INT32_MAX; michael@0: extents->x2 = extents->y2 = INT32_MIN; michael@0: michael@0: for (i = 0; i < n_glyphs; ++i) michael@0: { michael@0: glyph_t *glyph = (glyph_t *)glyphs[i].glyph; michael@0: int x1, y1, x2, y2; michael@0: michael@0: x1 = glyphs[i].x - glyph->origin_x; michael@0: y1 = glyphs[i].y - glyph->origin_y; michael@0: x2 = glyphs[i].x - glyph->origin_x + glyph->image->bits.width; michael@0: y2 = glyphs[i].y - glyph->origin_y + glyph->image->bits.height; michael@0: michael@0: if (x1 < extents->x1) michael@0: extents->x1 = x1; michael@0: if (y1 < extents->y1) michael@0: extents->y1 = y1; michael@0: if (x2 > extents->x2) michael@0: extents->x2 = x2; michael@0: if (y2 > extents->y2) michael@0: extents->y2 = y2; michael@0: } michael@0: } michael@0: michael@0: /* This function returns a format that is suitable for use as a mask for the michael@0: * set of glyphs in question. michael@0: */ michael@0: PIXMAN_EXPORT pixman_format_code_t michael@0: pixman_glyph_get_mask_format (pixman_glyph_cache_t *cache, michael@0: int n_glyphs, michael@0: const pixman_glyph_t *glyphs) michael@0: { michael@0: pixman_format_code_t format = PIXMAN_a1; michael@0: int i; michael@0: michael@0: for (i = 0; i < n_glyphs; ++i) michael@0: { michael@0: const glyph_t *glyph = glyphs[i].glyph; michael@0: pixman_format_code_t glyph_format = glyph->image->bits.format; michael@0: michael@0: if (PIXMAN_FORMAT_TYPE (glyph_format) == PIXMAN_TYPE_A) michael@0: { michael@0: if (PIXMAN_FORMAT_A (glyph_format) > PIXMAN_FORMAT_A (format)) michael@0: format = glyph_format; michael@0: } michael@0: else michael@0: { michael@0: return PIXMAN_a8r8g8b8; michael@0: } michael@0: } michael@0: michael@0: return format; michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: box32_intersect (pixman_box32_t *dest, michael@0: const pixman_box32_t *box1, michael@0: const pixman_box32_t *box2) michael@0: { michael@0: dest->x1 = MAX (box1->x1, box2->x1); michael@0: dest->y1 = MAX (box1->y1, box2->y1); michael@0: dest->x2 = MIN (box1->x2, box2->x2); michael@0: dest->y2 = MIN (box1->y2, box2->y2); michael@0: michael@0: return dest->x2 > dest->x1 && dest->y2 > dest->y1; michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_composite_glyphs_no_mask (pixman_op_t op, michael@0: pixman_image_t *src, michael@0: pixman_image_t *dest, michael@0: int32_t src_x, michael@0: int32_t src_y, michael@0: int32_t dest_x, michael@0: int32_t dest_y, michael@0: pixman_glyph_cache_t *cache, michael@0: int n_glyphs, michael@0: const pixman_glyph_t *glyphs) michael@0: { michael@0: pixman_region32_t region; michael@0: pixman_format_code_t glyph_format = PIXMAN_null; michael@0: uint32_t glyph_flags = 0; michael@0: pixman_format_code_t dest_format; michael@0: uint32_t dest_flags; michael@0: pixman_composite_func_t func = NULL; michael@0: pixman_implementation_t *implementation = NULL; michael@0: pixman_composite_info_t info; michael@0: int i; michael@0: michael@0: _pixman_image_validate (src); michael@0: _pixman_image_validate (dest); michael@0: michael@0: dest_format = dest->common.extended_format_code; michael@0: dest_flags = dest->common.flags; michael@0: michael@0: pixman_region32_init (®ion); michael@0: if (!_pixman_compute_composite_region32 ( michael@0: ®ion, michael@0: src, NULL, dest, michael@0: src_x - dest_x, src_y - dest_y, 0, 0, 0, 0, michael@0: dest->bits.width, dest->bits.height)) michael@0: { michael@0: goto out; michael@0: } michael@0: michael@0: info.op = op; michael@0: info.src_image = src; michael@0: info.dest_image = dest; michael@0: info.src_flags = src->common.flags; michael@0: info.dest_flags = dest->common.flags; michael@0: michael@0: for (i = 0; i < n_glyphs; ++i) michael@0: { michael@0: glyph_t *glyph = (glyph_t *)glyphs[i].glyph; michael@0: pixman_image_t *glyph_img = glyph->image; michael@0: pixman_box32_t glyph_box; michael@0: pixman_box32_t *pbox; michael@0: uint32_t extra = FAST_PATH_SAMPLES_COVER_CLIP_NEAREST; michael@0: pixman_box32_t composite_box; michael@0: int n; michael@0: michael@0: glyph_box.x1 = dest_x + glyphs[i].x - glyph->origin_x; michael@0: glyph_box.y1 = dest_y + glyphs[i].y - glyph->origin_y; michael@0: glyph_box.x2 = glyph_box.x1 + glyph->image->bits.width; michael@0: glyph_box.y2 = glyph_box.y1 + glyph->image->bits.height; michael@0: michael@0: pbox = pixman_region32_rectangles (®ion, &n); michael@0: michael@0: info.mask_image = glyph_img; michael@0: michael@0: while (n--) michael@0: { michael@0: if (box32_intersect (&composite_box, pbox, &glyph_box)) michael@0: { michael@0: if (glyph_img->common.extended_format_code != glyph_format || michael@0: glyph_img->common.flags != glyph_flags) michael@0: { michael@0: glyph_format = glyph_img->common.extended_format_code; michael@0: glyph_flags = glyph_img->common.flags; michael@0: michael@0: _pixman_implementation_lookup_composite ( michael@0: get_implementation(), op, michael@0: src->common.extended_format_code, src->common.flags, michael@0: glyph_format, glyph_flags | extra, michael@0: dest_format, dest_flags, michael@0: &implementation, &func); michael@0: } michael@0: michael@0: info.src_x = src_x + composite_box.x1 - dest_x; michael@0: info.src_y = src_y + composite_box.y1 - dest_y; michael@0: info.mask_x = composite_box.x1 - (dest_x + glyphs[i].x - glyph->origin_x); michael@0: info.mask_y = composite_box.y1 - (dest_y + glyphs[i].y - glyph->origin_y); michael@0: info.dest_x = composite_box.x1; michael@0: info.dest_y = composite_box.y1; michael@0: info.width = composite_box.x2 - composite_box.x1; michael@0: info.height = composite_box.y2 - composite_box.y1; michael@0: michael@0: info.mask_flags = glyph_flags; michael@0: michael@0: func (implementation, &info); michael@0: } michael@0: michael@0: pbox++; michael@0: } michael@0: pixman_list_move_to_front (&cache->mru, &glyph->mru_link); michael@0: } michael@0: michael@0: out: michael@0: pixman_region32_fini (®ion); michael@0: } michael@0: michael@0: static void michael@0: add_glyphs (pixman_glyph_cache_t *cache, michael@0: pixman_image_t *dest, michael@0: int off_x, int off_y, michael@0: int n_glyphs, const pixman_glyph_t *glyphs) michael@0: { michael@0: pixman_format_code_t glyph_format = PIXMAN_null; michael@0: uint32_t glyph_flags = 0; michael@0: pixman_composite_func_t func = NULL; michael@0: pixman_implementation_t *implementation = NULL; michael@0: pixman_format_code_t dest_format; michael@0: uint32_t dest_flags; michael@0: pixman_box32_t dest_box; michael@0: pixman_composite_info_t info; michael@0: pixman_image_t *white_img = NULL; michael@0: pixman_bool_t white_src = FALSE; michael@0: int i; michael@0: michael@0: _pixman_image_validate (dest); michael@0: michael@0: dest_format = dest->common.extended_format_code; michael@0: dest_flags = dest->common.flags; michael@0: michael@0: info.op = PIXMAN_OP_ADD; michael@0: info.dest_image = dest; michael@0: info.src_x = 0; michael@0: info.src_y = 0; michael@0: info.dest_flags = dest_flags; michael@0: michael@0: dest_box.x1 = 0; michael@0: dest_box.y1 = 0; michael@0: dest_box.x2 = dest->bits.width; michael@0: dest_box.y2 = dest->bits.height; michael@0: michael@0: for (i = 0; i < n_glyphs; ++i) michael@0: { michael@0: glyph_t *glyph = (glyph_t *)glyphs[i].glyph; michael@0: pixman_image_t *glyph_img = glyph->image; michael@0: pixman_box32_t glyph_box; michael@0: pixman_box32_t composite_box; michael@0: michael@0: if (glyph_img->common.extended_format_code != glyph_format || michael@0: glyph_img->common.flags != glyph_flags) michael@0: { michael@0: pixman_format_code_t src_format, mask_format; michael@0: michael@0: glyph_format = glyph_img->common.extended_format_code; michael@0: glyph_flags = glyph_img->common.flags; michael@0: michael@0: if (glyph_format == dest->bits.format) michael@0: { michael@0: src_format = glyph_format; michael@0: mask_format = PIXMAN_null; michael@0: info.src_flags = glyph_flags | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST; michael@0: info.mask_flags = FAST_PATH_IS_OPAQUE; michael@0: info.mask_image = NULL; michael@0: white_src = FALSE; michael@0: } michael@0: else michael@0: { michael@0: if (!white_img) michael@0: { michael@0: static const pixman_color_t white = { 0xffff, 0xffff, 0xffff, 0xffff }; michael@0: michael@0: if (!(white_img = pixman_image_create_solid_fill (&white))) michael@0: goto out; michael@0: michael@0: _pixman_image_validate (white_img); michael@0: } michael@0: michael@0: src_format = PIXMAN_solid; michael@0: mask_format = glyph_format; michael@0: info.src_flags = white_img->common.flags; michael@0: info.mask_flags = glyph_flags | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST; michael@0: info.src_image = white_img; michael@0: white_src = TRUE; michael@0: } michael@0: michael@0: _pixman_implementation_lookup_composite ( michael@0: get_implementation(), PIXMAN_OP_ADD, michael@0: src_format, info.src_flags, michael@0: mask_format, info.mask_flags, michael@0: dest_format, dest_flags, michael@0: &implementation, &func); michael@0: } michael@0: michael@0: glyph_box.x1 = glyphs[i].x - glyph->origin_x + off_x; michael@0: glyph_box.y1 = glyphs[i].y - glyph->origin_y + off_y; michael@0: glyph_box.x2 = glyph_box.x1 + glyph->image->bits.width; michael@0: glyph_box.y2 = glyph_box.y1 + glyph->image->bits.height; michael@0: michael@0: if (box32_intersect (&composite_box, &glyph_box, &dest_box)) michael@0: { michael@0: int src_x = composite_box.x1 - glyph_box.x1; michael@0: int src_y = composite_box.y1 - glyph_box.y1; michael@0: michael@0: if (white_src) michael@0: info.mask_image = glyph_img; michael@0: else michael@0: info.src_image = glyph_img; michael@0: michael@0: info.mask_x = info.src_x = src_x; michael@0: info.mask_y = info.src_y = src_y; michael@0: info.dest_x = composite_box.x1; michael@0: info.dest_y = composite_box.y1; michael@0: info.width = composite_box.x2 - composite_box.x1; michael@0: info.height = composite_box.y2 - composite_box.y1; michael@0: michael@0: func (implementation, &info); michael@0: michael@0: pixman_list_move_to_front (&cache->mru, &glyph->mru_link); michael@0: } michael@0: } michael@0: michael@0: out: michael@0: if (white_img) michael@0: pixman_image_unref (white_img); michael@0: } michael@0: michael@0: /* Conceptually, for each glyph, (white IN glyph) is PIXMAN_OP_ADDed to an michael@0: * infinitely big mask image at the position such that the glyph origin point michael@0: * is positioned at the (glyphs[i].x, glyphs[i].y) point. michael@0: * michael@0: * Then (mask_x, mask_y) in the infinite mask and (src_x, src_y) in the source michael@0: * image are both aligned with (dest_x, dest_y) in the destination image. Then michael@0: * these three images are composited within the michael@0: * michael@0: * (dest_x, dest_y, dst_x + width, dst_y + height) michael@0: * michael@0: * rectangle. michael@0: * michael@0: * TODO: michael@0: * - Trim the mask to the destination clip/image? michael@0: * - Trim composite region based on sources, when the op ignores 0s. michael@0: */ michael@0: PIXMAN_EXPORT void michael@0: pixman_composite_glyphs (pixman_op_t op, michael@0: pixman_image_t *src, michael@0: pixman_image_t *dest, michael@0: pixman_format_code_t mask_format, michael@0: int32_t src_x, michael@0: int32_t src_y, michael@0: int32_t mask_x, michael@0: int32_t mask_y, michael@0: int32_t dest_x, michael@0: int32_t dest_y, michael@0: int32_t width, michael@0: int32_t height, michael@0: pixman_glyph_cache_t *cache, michael@0: int n_glyphs, michael@0: const pixman_glyph_t *glyphs) michael@0: { michael@0: pixman_image_t *mask; michael@0: michael@0: if (!(mask = pixman_image_create_bits (mask_format, width, height, NULL, -1))) michael@0: return; michael@0: michael@0: if (PIXMAN_FORMAT_A (mask_format) != 0 && michael@0: PIXMAN_FORMAT_RGB (mask_format) != 0) michael@0: { michael@0: pixman_image_set_component_alpha (mask, TRUE); michael@0: } michael@0: michael@0: add_glyphs (cache, mask, - mask_x, - mask_y, n_glyphs, glyphs); michael@0: michael@0: pixman_image_composite32 (op, src, mask, dest, michael@0: src_x, src_y, michael@0: 0, 0, michael@0: dest_x, dest_y, michael@0: width, height); michael@0: michael@0: pixman_image_unref (mask); michael@0: }