pixman: Branch 'master' - 2 commits
Søren Sandmann Pedersen
sandmann at kemper.freedesktop.org
Fri Apr 24 19:00:42 PDT 2009
test/Makefile.am | 4 +++-
test/scaling-test.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
test/trap-crasher.c | 27 +++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 5 deletions(-)
New commits:
commit dbb72c02fda0d59d0da4ba100c7120ebc244835f
Author: Siarhei Siamashka <siarhei.siamashka at nokia.com>
Date: Mon Apr 20 16:13:44 2009 +0300
Updated scaling test to support rgb565, source clipping, etc.
Now test provides better coverage for various image scaling
cases. Unused byte for x8r8g8b8 format is ignored. Running
the test program without any command line options provides
a PASS/FAIL verdict based on the precalculated crc32 value
for using pixman with all the fastpath functions disabled,
which should simplify testing for correcteness.
diff --git a/test/scaling-test.c b/test/scaling-test.c
index ff24b1d..8810612 100644
--- a/test/scaling-test.c
+++ b/test/scaling-test.c
@@ -151,8 +151,8 @@ uint32_t test_composite(uint32_t initcrc, int testnum, int verbose)
lcg_srand(testnum);
- src_bpp = /*(lcg_rand_n(2) == 0) ? 2 :*/ 4;
- dst_bpp = /*(lcg_rand_n(2) == 0) ? 2 :*/ 4;
+ src_bpp = (lcg_rand_n(2) == 0) ? 2 : 4;
+ dst_bpp = (lcg_rand_n(2) == 0) ? 2 : 4;
op = (lcg_rand_n(2) == 0) ? PIXMAN_OP_SRC : PIXMAN_OP_OVER;
src_width = lcg_rand_n(MAX_SRC_WIDTH) + 1;
@@ -161,6 +161,8 @@ uint32_t test_composite(uint32_t initcrc, int testnum, int verbose)
dst_height = lcg_rand_n(MAX_DST_HEIGHT) + 1;
src_stride = src_width * src_bpp + lcg_rand_n(MAX_STRIDE) * src_bpp;
dst_stride = dst_width * dst_bpp + lcg_rand_n(MAX_STRIDE) * dst_bpp;
+ if (src_stride & 3) src_stride += 2;
+ if (dst_stride & 3) dst_stride += 2;
src_x = -src_width + lcg_rand_n(src_width * 3);
src_y = -src_height + lcg_rand_n(src_height * 3);
@@ -187,8 +189,8 @@ uint32_t test_composite(uint32_t initcrc, int testnum, int verbose)
dst_fmt, dst_width, dst_height, dstbuf, dst_stride);
if (lcg_rand_n(2) == 0) {
- scale_x = 32768 + lcg_rand_n(65536);
- scale_y = 32768 + lcg_rand_n(65536);
+ scale_x = 32768 + lcg_rand_n(65536);
+ scale_y = 32768 + lcg_rand_n(65536);
pixman_transform_init_scale(&transform, scale_x, scale_y);
pixman_image_set_transform(src_img, &transform);
}
@@ -205,6 +207,7 @@ uint32_t test_composite(uint32_t initcrc, int testnum, int verbose)
h = lcg_rand_n(MAX_DST_HEIGHT * 2);
if (verbose) {
+ printf("src_fmt=%08X, dst_fmt=%08X\n", src_fmt, dst_fmt);
printf("op=%d, scale_x=%d, scale_y=%d, repeat=%d\n",
op, scale_x, scale_y, repeat);
printf("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
@@ -214,6 +217,26 @@ uint32_t test_composite(uint32_t initcrc, int testnum, int verbose)
printf("w=%d, h=%d\n", w, h);
}
+ if (lcg_rand_n(2) == 0) {
+ pixman_box16_t clip_boxes[2];
+ int n = lcg_rand_n(2) + 1;
+ for (i = 0; i < n; i++) {
+ clip_boxes[i].x1 = lcg_rand_n(src_width);
+ clip_boxes[i].y1 = lcg_rand_n(src_height);
+ clip_boxes[i].x2 = clip_boxes[i].x1 + lcg_rand_n(src_width - clip_boxes[i].x1);
+ clip_boxes[i].y2 = clip_boxes[i].y1 + lcg_rand_n(src_height - clip_boxes[i].y1);
+ if (verbose) {
+ printf("source clip box: [%d,%d-%d,%d]\n",
+ clip_boxes[i].x1, clip_boxes[i].y1,
+ clip_boxes[i].x2, clip_boxes[i].y2);
+ }
+ }
+ pixman_region_init_rects(&clip, clip_boxes, n);
+ pixman_image_set_clip_region(src_img, &clip);
+ pixman_image_set_source_clipping(src_img, 1);
+ pixman_region_fini(&clip);
+ }
+
pixman_image_composite (op, src_img, NULL, dst_img,
src_x, src_y, 0, 0, dst_x, dst_y, w, h);
@@ -230,6 +253,12 @@ uint32_t test_composite(uint32_t initcrc, int testnum, int verbose)
pixman_image_unref (src_img);
pixman_image_unref (dst_img);
+ if (dst_fmt == PIXMAN_x8r8g8b8) {
+ /* ignore unused part */
+ for (i = 0; i < dst_stride * dst_height / 4; i++)
+ dstbuf[i] &= 0xFFFFFF;
+ }
+
crc32 = Crc32_ComputeBuf(initcrc, dstbuf, dst_stride * dst_height);
free(srcbuf);
free(dstbuf);
@@ -256,6 +285,15 @@ int main(int argc, char *argv[])
crc = test_composite(crc, i, 0);
}
printf("crc32=%08X\n", crc);
+ if (n == 10000) {
+ /* predefined value for running with all the fastpath functions disabled */
+ /* it needs to be updated every time changes are introduced to this program! */
+ if (crc == 0xF2EC6250) {
+ printf("scaling test passed\n");
+ } else {
+ printf("scaling test failed!\n");
+ }
+ }
}
return 0;
}
commit 880afeecc0d8bd610733292fd1cb692bba98dd5b
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date: Fri Apr 24 21:35:46 2009 -0400
Add trap-crasher.c test program
Based off of Pavel Kankovsky's test case in bug 16560.
diff --git a/test/Makefile.am b/test/Makefile.am
index cccb6f8..1beac5b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,11 +4,13 @@ INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman
TESTPROGRAMS = \
region-test \
scaling-test \
- fetch-test
+ fetch-test \
+ trap-crasher
fetch_test_LDADD = $(TEST_LDADD)
region_test_LDADD = $(TEST_LDADD)
scaling_test_LDADD = $(TEST_LDADD)
+trap_crasher_LDADD = $(TEST_LDADD)
# GTK using test programs
diff --git a/test/trap-crasher.c b/test/trap-crasher.c
new file mode 100644
index 0000000..42b82f6
--- /dev/null
+++ b/test/trap-crasher.c
@@ -0,0 +1,27 @@
+#include <stdlib.h>
+#include <pixman.h>
+
+int
+main()
+{
+ pixman_image_t *dst;
+ pixman_trapezoid_t traps[1] = {
+ {
+ .top = 2147483646,
+ .bottom = 2147483647,
+ .left = {
+ .p1 = { .x = 0, .y = 0 },
+ .p2 = { .x = 0, .y = 2147483647 }
+ },
+ .right = {
+ .p1 = { .x = 65536, .y = 0 },
+ .p2 = { .x = 0, .y = 2147483647 }
+ }
+ },
+ };
+
+ dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1);
+
+ pixman_add_trapezoids (dst, 0, 0, sizeof (traps)/sizeof (traps[0]), traps);
+ return (0);
+}
More information about the xorg-commit
mailing list