diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-02-11 08:57:42 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-02-18 06:21:37 -0500 |
commit | 3598ec26ecf761488e2ac1536553eaf3bb361e72 (patch) | |
tree | 88c8ffe0b497b1971d4e6e0e60a341244eb28283 | |
parent | 964c7e7cd20a6ed414fdf92b71fdc83db91d7578 (diff) |
Add new public function pixman_add_triangles()
This allows some more code to be deleted from the X server. The
implementation consists of converting to trapezoids, and is shared
with pixman_composite_triangles().
-rw-r--r-- | pixman/pixman-trap.c | 61 | ||||
-rw-r--r-- | pixman/pixman.h | 7 |
2 files changed, 51 insertions, 17 deletions
diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c index adf822c2..2957a2bc 100644 --- a/pixman/pixman-trap.c +++ b/pixman/pixman-trap.c @@ -595,6 +595,25 @@ triangle_to_trapezoids (const pixman_triangle_t *tri, pixman_trapezoid_t *traps) } } +static pixman_trapezoid_t * +convert_triangles (int n_tris, const pixman_triangle_t *tris) +{ + pixman_trapezoid_t *traps; + int i; + + if (n_tris <= 0) + return NULL; + + traps = pixman_malloc_ab (n_tris, 2 * sizeof (pixman_trapezoid_t)); + if (!traps) + return NULL; + + for (i = 0; i < n_tris; ++i) + triangle_to_trapezoids (&(tris[i]), traps + 2 * i); + + return traps; +} + PIXMAN_EXPORT void pixman_composite_triangles (pixman_op_t op, pixman_image_t * src, @@ -607,22 +626,32 @@ pixman_composite_triangles (pixman_op_t op, int n_tris, const pixman_triangle_t * tris) { - pixman_trapezoid_t *trapezoids; - int i; + pixman_trapezoid_t *traps; - if (n_tris <= 0) - return; - - trapezoids = malloc (2 * n_tris * sizeof (pixman_trapezoid_t)); - if (!trapezoids) - return; + if ((traps = convert_triangles (n_tris, tris))) + { + pixman_composite_trapezoids (op, src, dst, mask_format, + x_src, y_src, x_dst, y_dst, + n_tris * 2, traps); + + free (traps); + } +} - for (i = 0; i < n_tris; ++i) - triangle_to_trapezoids (&(tris[i]), trapezoids + 2 * i); - - pixman_composite_trapezoids (op, src, dst, mask_format, - x_src, y_src, x_dst, y_dst, - n_tris * 2, trapezoids); - - free (trapezoids); +PIXMAN_EXPORT void +pixman_add_triangles (pixman_image_t *image, + int32_t x_off, + int32_t y_off, + int n_tris, + const pixman_triangle_t *tris) +{ + pixman_trapezoid_t *traps; + + if ((traps = convert_triangles (n_tris, tris))) + { + pixman_add_trapezoids (image, x_off, y_off, + n_tris * 2, traps); + + free (traps); + } } diff --git a/pixman/pixman.h b/pixman/pixman.h index 7d28e78c..1305bc1d 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -975,7 +975,12 @@ void pixman_composite_triangles (pixman_op_t op, int y_dst, int n_tris, const pixman_triangle_t * tris); - +void pixman_add_triangles (pixman_image_t *image, + int32_t x_off, + int32_t y_off, + int n_tris, + const pixman_triangle_t *tris); + PIXMAN_END_DECLS #endif /* PIXMAN_H__ */ |