[Pixman] [PATCH 6/6] Add new public function pixman_add_triangles()
Søren Sandmann Pedersen
sandmann at cs.au.dk
Fri Feb 11 06:54:18 PST 2011
From: Søren Sandmann Pedersen <ssp at redhat.com>
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().
---
pixman/pixman-trap.c | 61 ++++++++++++++++++++++++++++++++++++-------------
pixman/pixman.h | 7 +++++-
2 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c
index adf822c..2957a2b 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 7d28e78..1305bc1 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__ */
--
1.7.3.1
More information about the Pixman
mailing list