[PATCH 3/3] Add a test program, tri-test
Søren Sandmann Pedersen
ssp at redhat.com
Wed Jan 12 05:49:13 PST 2011
This program tests whether the new triangle support works.
---
test/Makefile.am | 6 +++++-
test/tri-test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletions(-)
create mode 100644 test/tri-test.c
diff --git a/test/Makefile.am b/test/Makefile.am
index 19c4f80..e18f914 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -74,7 +74,8 @@ TESTPROGRAMS_GTK = \
alpha-test \
screen-test \
convolution-test \
- trap-test
+ trap-test \
+ tri-test
INCLUDES += $(GTK_CFLAGS)
@@ -96,6 +97,9 @@ clip_in_SOURCES = clip-in.c $(GTK_UTILS)
trap_test_LDADD = $(GTK_LDADD)
trap_test_SOURCES = trap-test.c $(GTK_UTILS)
+tri_test_LDADD = $(GTK_LDADD)
+tri_test_SOURCES = tri-test.c $(GTK_UTILS)
+
screen_test_LDADD = $(GTK_LDADD)
screen_test_SOURCES = screen-test.c $(GTK_UTILS)
diff --git a/test/tri-test.c b/test/tri-test.c
new file mode 100644
index 0000000..dd3fd17
--- /dev/null
+++ b/test/tri-test.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "utils.h"
+#include "gtk-utils.h"
+
+int
+main (int argc, char **argv)
+{
+#define WIDTH 200
+#define HEIGHT 200
+
+#define POINT(x,y) \
+ { pixman_double_to_fixed ((x)), pixman_double_to_fixed ((y)) }
+
+ pixman_image_t *src_img, *dest_img;
+ pixman_triangle_t tris[4] =
+ {
+ { POINT (100, 100), POINT (10, 50), POINT (110, 10) },
+ { POINT (100, 100), POINT (150, 10), POINT (200, 50) },
+ { POINT (100, 100), POINT (10, 170), POINT (90, 175) },
+ { POINT (100, 100), POINT (170, 150), POINT (120, 190) },
+ };
+ pixman_color_t color = { 0x4444, 0x4444, 0xffff, 0xffff };
+ uint32_t *bits = malloc (WIDTH * HEIGHT * 4);
+ int i;
+
+ for (i = 0; i < WIDTH * HEIGHT; ++i)
+ bits[i] = (i / HEIGHT) * 0x01010000;
+
+ src_img = pixman_image_create_solid_fill (&color);
+ dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, bits, WIDTH * 4);
+
+ pixman_composite_triangles (PIXMAN_OP_ATOP_REVERSE,
+ src_img,
+ dest_img,
+ PIXMAN_a8,
+ 200, 200,
+ 35, 5,
+ ARRAY_LENGTH (tris), tris);
+ show_image (dest_img);
+
+ pixman_image_unref (src_img);
+ pixman_image_unref (dest_img);
+ free (bits);
+
+ return 0;
+}
--
1.7.3.1
More information about the xorg-devel
mailing list