michael@0: /* michael@0: * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. michael@0: * Copyright © 2004 Keith Packard michael@0: * michael@0: * Permission to use, copy, modify, distribute, and sell this software and its michael@0: * documentation for any purpose is hereby granted without fee, provided that michael@0: * the above copyright notice appear in all copies and that both that michael@0: * copyright notice and this permission notice appear in supporting michael@0: * documentation, and that the name of Keith Packard not be used in michael@0: * advertising or publicity pertaining to distribution of the software without michael@0: * specific, written prior permission. Keith Packard makes no michael@0: * representations about the suitability of this software for any purpose. It michael@0: * is provided "as is" without express or implied warranty. michael@0: * michael@0: * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, michael@0: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO michael@0: * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR michael@0: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, michael@0: * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER michael@0: * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR michael@0: * PERFORMANCE OF THIS SOFTWARE. michael@0: */ michael@0: michael@0: #ifdef HAVE_CONFIG_H michael@0: #include michael@0: #endif michael@0: michael@0: #include michael@0: #include michael@0: #include "pixman-private.h" michael@0: michael@0: /* michael@0: * Compute the smallest value greater than or equal to y which is on a michael@0: * grid row. michael@0: */ michael@0: michael@0: PIXMAN_EXPORT pixman_fixed_t michael@0: pixman_sample_ceil_y (pixman_fixed_t y, int n) michael@0: { michael@0: pixman_fixed_t f = pixman_fixed_frac (y); michael@0: pixman_fixed_t i = pixman_fixed_floor (y); michael@0: michael@0: f = DIV (f - Y_FRAC_FIRST (n) + (STEP_Y_SMALL (n) - pixman_fixed_e), STEP_Y_SMALL (n)) * STEP_Y_SMALL (n) + michael@0: Y_FRAC_FIRST (n); michael@0: michael@0: if (f > Y_FRAC_LAST (n)) michael@0: { michael@0: if (pixman_fixed_to_int (i) == 0x7fff) michael@0: { michael@0: f = 0xffff; /* saturate */ michael@0: } michael@0: else michael@0: { michael@0: f = Y_FRAC_FIRST (n); michael@0: i += pixman_fixed_1; michael@0: } michael@0: } michael@0: return (i | f); michael@0: } michael@0: michael@0: /* michael@0: * Compute the largest value strictly less than y which is on a michael@0: * grid row. michael@0: */ michael@0: PIXMAN_EXPORT pixman_fixed_t michael@0: pixman_sample_floor_y (pixman_fixed_t y, michael@0: int n) michael@0: { michael@0: pixman_fixed_t f = pixman_fixed_frac (y); michael@0: pixman_fixed_t i = pixman_fixed_floor (y); michael@0: michael@0: f = DIV (f - pixman_fixed_e - Y_FRAC_FIRST (n), STEP_Y_SMALL (n)) * STEP_Y_SMALL (n) + michael@0: Y_FRAC_FIRST (n); michael@0: michael@0: if (f < Y_FRAC_FIRST (n)) michael@0: { michael@0: if (pixman_fixed_to_int (i) == 0x8000) michael@0: { michael@0: f = 0; /* saturate */ michael@0: } michael@0: else michael@0: { michael@0: f = Y_FRAC_LAST (n); michael@0: i -= pixman_fixed_1; michael@0: } michael@0: } michael@0: return (i | f); michael@0: } michael@0: michael@0: /* michael@0: * Step an edge by any amount (including negative values) michael@0: */ michael@0: PIXMAN_EXPORT void michael@0: pixman_edge_step (pixman_edge_t *e, michael@0: int n) michael@0: { michael@0: pixman_fixed_48_16_t ne; michael@0: michael@0: e->x += n * e->stepx; michael@0: michael@0: ne = e->e + n * (pixman_fixed_48_16_t) e->dx; michael@0: michael@0: if (n >= 0) michael@0: { michael@0: if (ne > 0) michael@0: { michael@0: int nx = (ne + e->dy - 1) / e->dy; michael@0: e->e = ne - nx * (pixman_fixed_48_16_t) e->dy; michael@0: e->x += nx * e->signdx; michael@0: } michael@0: } michael@0: else michael@0: { michael@0: if (ne <= -e->dy) michael@0: { michael@0: int nx = (-ne) / e->dy; michael@0: e->e = ne + nx * (pixman_fixed_48_16_t) e->dy; michael@0: e->x -= nx * e->signdx; michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* michael@0: * A private routine to initialize the multi-step michael@0: * elements of an edge structure michael@0: */ michael@0: static void michael@0: _pixman_edge_multi_init (pixman_edge_t * e, michael@0: int n, michael@0: pixman_fixed_t *stepx_p, michael@0: pixman_fixed_t *dx_p) michael@0: { michael@0: pixman_fixed_t stepx; michael@0: pixman_fixed_48_16_t ne; michael@0: michael@0: ne = n * (pixman_fixed_48_16_t) e->dx; michael@0: stepx = n * e->stepx; michael@0: michael@0: if (ne > 0) michael@0: { michael@0: int nx = ne / e->dy; michael@0: ne -= nx * (pixman_fixed_48_16_t)e->dy; michael@0: stepx += nx * e->signdx; michael@0: } michael@0: michael@0: *dx_p = ne; michael@0: *stepx_p = stepx; michael@0: } michael@0: michael@0: /* michael@0: * Initialize one edge structure given the line endpoints and a michael@0: * starting y value michael@0: */ michael@0: PIXMAN_EXPORT void michael@0: pixman_edge_init (pixman_edge_t *e, michael@0: int n, michael@0: pixman_fixed_t y_start, michael@0: pixman_fixed_t x_top, michael@0: pixman_fixed_t y_top, michael@0: pixman_fixed_t x_bot, michael@0: pixman_fixed_t y_bot) michael@0: { michael@0: pixman_fixed_t dx, dy; michael@0: michael@0: e->x = x_top; michael@0: e->e = 0; michael@0: dx = x_bot - x_top; michael@0: dy = y_bot - y_top; michael@0: e->dy = dy; michael@0: e->dx = 0; michael@0: michael@0: if (dy) michael@0: { michael@0: if (dx >= 0) michael@0: { michael@0: e->signdx = 1; michael@0: e->stepx = dx / dy; michael@0: e->dx = dx % dy; michael@0: e->e = -dy; michael@0: } michael@0: else michael@0: { michael@0: e->signdx = -1; michael@0: e->stepx = -(-dx / dy); michael@0: e->dx = -dx % dy; michael@0: e->e = 0; michael@0: } michael@0: michael@0: _pixman_edge_multi_init (e, STEP_Y_SMALL (n), michael@0: &e->stepx_small, &e->dx_small); michael@0: michael@0: _pixman_edge_multi_init (e, STEP_Y_BIG (n), michael@0: &e->stepx_big, &e->dx_big); michael@0: } michael@0: pixman_edge_step (e, y_start - y_top); michael@0: } michael@0: michael@0: /* michael@0: * Initialize one edge structure given a line, starting y value michael@0: * and a pixel offset for the line michael@0: */ michael@0: PIXMAN_EXPORT void michael@0: pixman_line_fixed_edge_init (pixman_edge_t * e, michael@0: int n, michael@0: pixman_fixed_t y, michael@0: const pixman_line_fixed_t *line, michael@0: int x_off, michael@0: int y_off) michael@0: { michael@0: pixman_fixed_t x_off_fixed = pixman_int_to_fixed (x_off); michael@0: pixman_fixed_t y_off_fixed = pixman_int_to_fixed (y_off); michael@0: const pixman_point_fixed_t *top, *bot; michael@0: michael@0: if (line->p1.y <= line->p2.y) michael@0: { michael@0: top = &line->p1; michael@0: bot = &line->p2; michael@0: } michael@0: else michael@0: { michael@0: top = &line->p2; michael@0: bot = &line->p1; michael@0: } michael@0: michael@0: pixman_edge_init (e, n, y, michael@0: top->x + x_off_fixed, michael@0: top->y + y_off_fixed, michael@0: bot->x + x_off_fixed, michael@0: bot->y + y_off_fixed); michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_add_traps (pixman_image_t * image, michael@0: int16_t x_off, michael@0: int16_t y_off, michael@0: int ntrap, michael@0: const pixman_trap_t *traps) michael@0: { michael@0: int bpp; michael@0: int height; michael@0: michael@0: pixman_fixed_t x_off_fixed; michael@0: pixman_fixed_t y_off_fixed; michael@0: pixman_edge_t l, r; michael@0: pixman_fixed_t t, b; michael@0: michael@0: _pixman_image_validate (image); michael@0: michael@0: height = image->bits.height; michael@0: bpp = PIXMAN_FORMAT_BPP (image->bits.format); michael@0: michael@0: x_off_fixed = pixman_int_to_fixed (x_off); michael@0: y_off_fixed = pixman_int_to_fixed (y_off); michael@0: michael@0: while (ntrap--) michael@0: { michael@0: t = traps->top.y + y_off_fixed; michael@0: if (t < 0) michael@0: t = 0; michael@0: t = pixman_sample_ceil_y (t, bpp); michael@0: michael@0: b = traps->bot.y + y_off_fixed; michael@0: if (pixman_fixed_to_int (b) >= height) michael@0: b = pixman_int_to_fixed (height) - 1; michael@0: b = pixman_sample_floor_y (b, bpp); michael@0: michael@0: if (b >= t) michael@0: { michael@0: /* initialize edge walkers */ michael@0: pixman_edge_init (&l, bpp, t, michael@0: traps->top.l + x_off_fixed, michael@0: traps->top.y + y_off_fixed, michael@0: traps->bot.l + x_off_fixed, michael@0: traps->bot.y + y_off_fixed); michael@0: michael@0: pixman_edge_init (&r, bpp, t, michael@0: traps->top.r + x_off_fixed, michael@0: traps->top.y + y_off_fixed, michael@0: traps->bot.r + x_off_fixed, michael@0: traps->bot.y + y_off_fixed); michael@0: michael@0: pixman_rasterize_edges (image, &l, &r, t, b); michael@0: } michael@0: michael@0: traps++; michael@0: } michael@0: } michael@0: michael@0: #if 0 michael@0: static void michael@0: dump_image (pixman_image_t *image, michael@0: const char * title) michael@0: { michael@0: int i, j; michael@0: michael@0: if (!image->type == BITS) michael@0: printf ("%s is not a regular image\n", title); michael@0: michael@0: if (!image->bits.format == PIXMAN_a8) michael@0: printf ("%s is not an alpha mask\n", title); michael@0: michael@0: printf ("\n\n\n%s: \n", title); michael@0: michael@0: for (i = 0; i < image->bits.height; ++i) michael@0: { michael@0: uint8_t *line = michael@0: (uint8_t *)&(image->bits.bits[i * image->bits.rowstride]); michael@0: michael@0: for (j = 0; j < image->bits.width; ++j) michael@0: printf ("%c", line[j] ? '#' : ' '); michael@0: michael@0: printf ("\n"); michael@0: } michael@0: } michael@0: #endif michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_add_trapezoids (pixman_image_t * image, michael@0: int16_t x_off, michael@0: int y_off, michael@0: int ntraps, michael@0: const pixman_trapezoid_t *traps) michael@0: { michael@0: int i; michael@0: michael@0: #if 0 michael@0: dump_image (image, "before"); michael@0: #endif michael@0: michael@0: for (i = 0; i < ntraps; ++i) michael@0: { michael@0: const pixman_trapezoid_t *trap = &(traps[i]); michael@0: michael@0: if (!pixman_trapezoid_valid (trap)) michael@0: continue; michael@0: michael@0: pixman_rasterize_trapezoid (image, trap, x_off, y_off); michael@0: } michael@0: michael@0: #if 0 michael@0: dump_image (image, "after"); michael@0: #endif michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_rasterize_trapezoid (pixman_image_t * image, michael@0: const pixman_trapezoid_t *trap, michael@0: int x_off, michael@0: int y_off) michael@0: { michael@0: int bpp; michael@0: int height; michael@0: michael@0: pixman_fixed_t y_off_fixed; michael@0: pixman_edge_t l, r; michael@0: pixman_fixed_t t, b; michael@0: michael@0: return_if_fail (image->type == BITS); michael@0: michael@0: _pixman_image_validate (image); michael@0: michael@0: if (!pixman_trapezoid_valid (trap)) michael@0: return; michael@0: michael@0: height = image->bits.height; michael@0: bpp = PIXMAN_FORMAT_BPP (image->bits.format); michael@0: michael@0: y_off_fixed = pixman_int_to_fixed (y_off); michael@0: michael@0: t = trap->top + y_off_fixed; michael@0: if (t < 0) michael@0: t = 0; michael@0: t = pixman_sample_ceil_y (t, bpp); michael@0: michael@0: b = trap->bottom + y_off_fixed; michael@0: if (pixman_fixed_to_int (b) >= height) michael@0: b = pixman_int_to_fixed (height) - 1; michael@0: b = pixman_sample_floor_y (b, bpp); michael@0: michael@0: if (b >= t) michael@0: { michael@0: /* initialize edge walkers */ michael@0: pixman_line_fixed_edge_init (&l, bpp, t, &trap->left, x_off, y_off); michael@0: pixman_line_fixed_edge_init (&r, bpp, t, &trap->right, x_off, y_off); michael@0: michael@0: pixman_rasterize_edges (image, &l, &r, t, b); michael@0: } michael@0: } michael@0: michael@0: static const pixman_bool_t zero_src_has_no_effect[PIXMAN_N_OPERATORS] = michael@0: { michael@0: FALSE, /* Clear 0 0 */ michael@0: FALSE, /* Src 1 0 */ michael@0: TRUE, /* Dst 0 1 */ michael@0: TRUE, /* Over 1 1-Aa */ michael@0: TRUE, /* OverReverse 1-Ab 1 */ michael@0: FALSE, /* In Ab 0 */ michael@0: FALSE, /* InReverse 0 Aa */ michael@0: FALSE, /* Out 1-Ab 0 */ michael@0: TRUE, /* OutReverse 0 1-Aa */ michael@0: TRUE, /* Atop Ab 1-Aa */ michael@0: FALSE, /* AtopReverse 1-Ab Aa */ michael@0: TRUE, /* Xor 1-Ab 1-Aa */ michael@0: TRUE, /* Add 1 1 */ michael@0: }; michael@0: michael@0: static pixman_bool_t michael@0: get_trap_extents (pixman_op_t op, pixman_image_t *dest, michael@0: const pixman_trapezoid_t *traps, int n_traps, michael@0: pixman_box32_t *box) michael@0: { michael@0: int i; michael@0: michael@0: /* When the operator is such that a zero source has an michael@0: * effect on the underlying image, we have to michael@0: * composite across the entire destination michael@0: */ michael@0: if (!zero_src_has_no_effect [op]) michael@0: { michael@0: box->x1 = 0; michael@0: box->y1 = 0; michael@0: box->x2 = dest->bits.width; michael@0: box->y2 = dest->bits.height; michael@0: return TRUE; michael@0: } michael@0: michael@0: box->x1 = INT32_MAX; michael@0: box->y1 = INT32_MAX; michael@0: box->x2 = INT32_MIN; michael@0: box->y2 = INT32_MIN; michael@0: michael@0: for (i = 0; i < n_traps; ++i) michael@0: { michael@0: const pixman_trapezoid_t *trap = &(traps[i]); michael@0: int y1, y2; michael@0: michael@0: if (!pixman_trapezoid_valid (trap)) michael@0: continue; michael@0: michael@0: y1 = pixman_fixed_to_int (trap->top); michael@0: if (y1 < box->y1) michael@0: box->y1 = y1; michael@0: michael@0: y2 = pixman_fixed_to_int (pixman_fixed_ceil (trap->bottom)); michael@0: if (y2 > box->y2) michael@0: box->y2 = y2; michael@0: michael@0: #define EXTEND_MIN(x) \ michael@0: if (pixman_fixed_to_int ((x)) < box->x1) \ michael@0: box->x1 = pixman_fixed_to_int ((x)); michael@0: #define EXTEND_MAX(x) \ michael@0: if (pixman_fixed_to_int (pixman_fixed_ceil ((x))) > box->x2) \ michael@0: box->x2 = pixman_fixed_to_int (pixman_fixed_ceil ((x))); michael@0: michael@0: #define EXTEND(x) \ michael@0: EXTEND_MIN(x); \ michael@0: EXTEND_MAX(x); michael@0: michael@0: EXTEND(trap->left.p1.x); michael@0: EXTEND(trap->left.p2.x); michael@0: EXTEND(trap->right.p1.x); michael@0: EXTEND(trap->right.p2.x); michael@0: } michael@0: michael@0: if (box->x1 >= box->x2 || box->y1 >= box->y2) michael@0: return FALSE; michael@0: michael@0: return TRUE; michael@0: } michael@0: michael@0: /* michael@0: * pixman_composite_trapezoids() michael@0: * michael@0: * All the trapezoids are conceptually rendered to an infinitely big image. michael@0: * The (0, 0) coordinates of this image are then aligned with the (x, y) michael@0: * coordinates of the source image, and then both images are aligned with michael@0: * the (x, y) coordinates of the destination. Then these three images are michael@0: * composited across the entire destination. michael@0: */ michael@0: PIXMAN_EXPORT void michael@0: pixman_composite_trapezoids (pixman_op_t op, michael@0: pixman_image_t * src, michael@0: pixman_image_t * dst, michael@0: pixman_format_code_t mask_format, michael@0: int x_src, michael@0: int y_src, michael@0: int x_dst, michael@0: int y_dst, michael@0: int n_traps, michael@0: const pixman_trapezoid_t * traps) michael@0: { michael@0: int i; michael@0: michael@0: return_if_fail (PIXMAN_FORMAT_TYPE (mask_format) == PIXMAN_TYPE_A); michael@0: michael@0: if (n_traps <= 0) michael@0: return; michael@0: michael@0: _pixman_image_validate (src); michael@0: _pixman_image_validate (dst); michael@0: michael@0: if (op == PIXMAN_OP_ADD && michael@0: (src->common.flags & FAST_PATH_IS_OPAQUE) && michael@0: (mask_format == dst->common.extended_format_code) && michael@0: !(dst->common.have_clip_region)) michael@0: { michael@0: for (i = 0; i < n_traps; ++i) michael@0: { michael@0: const pixman_trapezoid_t *trap = &(traps[i]); michael@0: michael@0: if (!pixman_trapezoid_valid (trap)) michael@0: continue; michael@0: michael@0: pixman_rasterize_trapezoid (dst, trap, x_dst, y_dst); michael@0: } michael@0: } michael@0: else michael@0: { michael@0: pixman_image_t *tmp; michael@0: pixman_box32_t box; michael@0: int i; michael@0: michael@0: if (!get_trap_extents (op, dst, traps, n_traps, &box)) michael@0: return; michael@0: michael@0: if (!(tmp = pixman_image_create_bits ( michael@0: mask_format, box.x2 - box.x1, box.y2 - box.y1, NULL, -1))) michael@0: return; michael@0: michael@0: for (i = 0; i < n_traps; ++i) michael@0: { michael@0: const pixman_trapezoid_t *trap = &(traps[i]); michael@0: michael@0: if (!pixman_trapezoid_valid (trap)) michael@0: continue; michael@0: michael@0: pixman_rasterize_trapezoid (tmp, trap, - box.x1, - box.y1); michael@0: } michael@0: michael@0: pixman_image_composite (op, src, tmp, dst, michael@0: x_src + box.x1, y_src + box.y1, michael@0: 0, 0, michael@0: x_dst + box.x1, y_dst + box.y1, michael@0: box.x2 - box.x1, box.y2 - box.y1); michael@0: michael@0: pixman_image_unref (tmp); michael@0: } michael@0: } michael@0: michael@0: static int michael@0: greater_y (const pixman_point_fixed_t *a, const pixman_point_fixed_t *b) michael@0: { michael@0: if (a->y == b->y) michael@0: return a->x > b->x; michael@0: return a->y > b->y; michael@0: } michael@0: michael@0: /* michael@0: * Note that the definition of this function is a bit odd because michael@0: * of the X coordinate space (y increasing downwards). michael@0: */ michael@0: static int michael@0: clockwise (const pixman_point_fixed_t *ref, michael@0: const pixman_point_fixed_t *a, michael@0: const pixman_point_fixed_t *b) michael@0: { michael@0: pixman_point_fixed_t ad, bd; michael@0: michael@0: ad.x = a->x - ref->x; michael@0: ad.y = a->y - ref->y; michael@0: bd.x = b->x - ref->x; michael@0: bd.y = b->y - ref->y; michael@0: michael@0: return ((pixman_fixed_32_32_t) bd.y * ad.x - michael@0: (pixman_fixed_32_32_t) ad.y * bd.x) < 0; michael@0: } michael@0: michael@0: static void michael@0: triangle_to_trapezoids (const pixman_triangle_t *tri, pixman_trapezoid_t *traps) michael@0: { michael@0: const pixman_point_fixed_t *top, *left, *right, *tmp; michael@0: michael@0: top = &tri->p1; michael@0: left = &tri->p2; michael@0: right = &tri->p3; michael@0: michael@0: if (greater_y (top, left)) michael@0: { michael@0: tmp = left; michael@0: left = top; michael@0: top = tmp; michael@0: } michael@0: michael@0: if (greater_y (top, right)) michael@0: { michael@0: tmp = right; michael@0: right = top; michael@0: top = tmp; michael@0: } michael@0: michael@0: if (clockwise (top, right, left)) michael@0: { michael@0: tmp = right; michael@0: right = left; michael@0: left = tmp; michael@0: } michael@0: michael@0: /* michael@0: * Two cases: michael@0: * michael@0: * + + michael@0: * / \ / \ michael@0: * / \ / \ michael@0: * / + + \ michael@0: * / -- -- \ michael@0: * / -- -- \ michael@0: * / --- --- \ michael@0: * +-- --+ michael@0: */ michael@0: michael@0: traps->top = top->y; michael@0: traps->left.p1 = *top; michael@0: traps->left.p2 = *left; michael@0: traps->right.p1 = *top; michael@0: traps->right.p2 = *right; michael@0: michael@0: if (right->y < left->y) michael@0: traps->bottom = right->y; michael@0: else michael@0: traps->bottom = left->y; michael@0: michael@0: traps++; michael@0: michael@0: *traps = *(traps - 1); michael@0: michael@0: if (right->y < left->y) michael@0: { michael@0: traps->top = right->y; michael@0: traps->bottom = left->y; michael@0: traps->right.p1 = *right; michael@0: traps->right.p2 = *left; michael@0: } michael@0: else michael@0: { michael@0: traps->top = left->y; michael@0: traps->bottom = right->y; michael@0: traps->left.p1 = *left; michael@0: traps->left.p2 = *right; michael@0: } michael@0: } michael@0: michael@0: static pixman_trapezoid_t * michael@0: convert_triangles (int n_tris, const pixman_triangle_t *tris) michael@0: { michael@0: pixman_trapezoid_t *traps; michael@0: int i; michael@0: michael@0: if (n_tris <= 0) michael@0: return NULL; michael@0: michael@0: traps = pixman_malloc_ab (n_tris, 2 * sizeof (pixman_trapezoid_t)); michael@0: if (!traps) michael@0: return NULL; michael@0: michael@0: for (i = 0; i < n_tris; ++i) michael@0: triangle_to_trapezoids (&(tris[i]), traps + 2 * i); michael@0: michael@0: return traps; michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_composite_triangles (pixman_op_t op, michael@0: pixman_image_t * src, michael@0: pixman_image_t * dst, michael@0: pixman_format_code_t mask_format, michael@0: int x_src, michael@0: int y_src, michael@0: int x_dst, michael@0: int y_dst, michael@0: int n_tris, michael@0: const pixman_triangle_t * tris) michael@0: { michael@0: pixman_trapezoid_t *traps; michael@0: michael@0: if ((traps = convert_triangles (n_tris, tris))) michael@0: { michael@0: pixman_composite_trapezoids (op, src, dst, mask_format, michael@0: x_src, y_src, x_dst, y_dst, michael@0: n_tris * 2, traps); michael@0: michael@0: free (traps); michael@0: } michael@0: } michael@0: michael@0: PIXMAN_EXPORT void michael@0: pixman_add_triangles (pixman_image_t *image, michael@0: int32_t x_off, michael@0: int32_t y_off, michael@0: int n_tris, michael@0: const pixman_triangle_t *tris) michael@0: { michael@0: pixman_trapezoid_t *traps; michael@0: michael@0: if ((traps = convert_triangles (n_tris, tris))) michael@0: { michael@0: pixman_add_trapezoids (image, x_off, y_off, michael@0: n_tris * 2, traps); michael@0: michael@0: free (traps); michael@0: } michael@0: }