aboutsummaryrefslogtreecommitdiff
path: root/pixman/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-03-02 10:53:27 +0000
committermarha <marha@users.sourceforge.net>2011-03-02 10:53:27 +0000
commit43fb99508848b8e9f4ced9a7e7a6c3692047fbf1 (patch)
tree8cba41c6dda06adfd2a2f88eff6e54ab6d4204cf /pixman/test
parent717b1a4e21b372e1343e33ae9348fbe5c6f8d7ed (diff)
parent56950d7bed70ee82186f44f9333537cdbb33c448 (diff)
downloadvcxsrv-43fb99508848b8e9f4ced9a7e7a6c3692047fbf1.tar.gz
vcxsrv-43fb99508848b8e9f4ced9a7e7a6c3692047fbf1.tar.bz2
vcxsrv-43fb99508848b8e9f4ced9a7e7a6c3692047fbf1.zip
svn merge ^/branches/released .
Diffstat (limited to 'pixman/test')
-rw-r--r--pixman/test/Makefile.am2
-rw-r--r--pixman/test/Makefile.win3273
-rw-r--r--pixman/test/composite.c30
-rw-r--r--pixman/test/fetch-test.c397
-rw-r--r--pixman/test/scaling-helpers-test.c93
-rw-r--r--pixman/test/stress-test.c2
-rw-r--r--pixman/test/trap-crasher.c54
7 files changed, 407 insertions, 244 deletions
diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am
index f05b99918..d785c2c2e 100644
--- a/pixman/test/Makefile.am
+++ b/pixman/test/Makefile.am
@@ -13,6 +13,7 @@ TESTPROGRAMS = \
trap-crasher \
alpha-loop \
scaling-crash-test \
+ scaling-helpers-test \
gradient-crash-test \
alphamap \
stress-test \
@@ -33,6 +34,7 @@ alpha_loop_SOURCES = alpha-loop.c utils.c utils.h
composite_SOURCES = composite.c utils.c utils.h
gradient_crash_test_SOURCES = gradient-crash-test.c utils.c utils.h
stress_test_SOURCES = stress-test.c utils.c utils.h
+scaling_helpers_test_SOURCES = scaling-helpers-test.c utils.c utils.h
# Benchmarks
diff --git a/pixman/test/Makefile.win32 b/pixman/test/Makefile.win32
new file mode 100644
index 000000000..c71afe187
--- /dev/null
+++ b/pixman/test/Makefile.win32
@@ -0,0 +1,73 @@
+CC = cl
+LINK = link
+
+CFG_VAR = $(CFG)
+ifeq ($(CFG_VAR),)
+CFG_VAR=release
+endif
+
+CFLAGS = -MD -nologo -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_BIND_TO_CURRENT_VCLIBS_VERSION -D_MT -I../pixman -I. -I../
+TEST_LDADD = ../pixman/$(CFG_VAR)/pixman-1.lib
+INCLUDES = -I../pixman -I$(top_builddir)/pixman
+
+# optimization flags
+ifeq ($(CFG_VAR),debug)
+CFLAGS += -Od -Zi
+else
+CFLAGS += -O2
+endif
+
+SOURCES = \
+ a1-trap-test.c \
+ pdf-op-test.c \
+ region-test.c \
+ region-translate-test.c \
+ fetch-test.c \
+ oob-test.c \
+ trap-crasher.c \
+ alpha-loop.c \
+ scaling-crash-test.c \
+ gradient-crash-test.c \
+ alphamap.c \
+ stress-test.c \
+ composite-traps-test.c \
+ blitters-test.c \
+ scaling-test.c \
+ affine-test.c \
+ composite.c \
+ utils.c
+
+TESTS = \
+ $(CFG_VAR)/a1-trap-test.exe \
+ $(CFG_VAR)/pdf-op-test.exe \
+ $(CFG_VAR)/region-test.exe \
+ $(CFG_VAR)/region-translate-test.exe \
+ $(CFG_VAR)/fetch-test.exe \
+ $(CFG_VAR)/oob-test.exe \
+ $(CFG_VAR)/trap-crasher.exe \
+ $(CFG_VAR)/alpha-loop.exe \
+ $(CFG_VAR)/scaling-crash-test.exe \
+ $(CFG_VAR)/gradient-crash-test.exe \
+ $(CFG_VAR)/alphamap.exe \
+ $(CFG_VAR)/stress-test.exe \
+ $(CFG_VAR)/composite-traps-test.exe \
+ $(CFG_VAR)/blitters-test.exe \
+ $(CFG_VAR)/scaling-test.exe \
+ $(CFG_VAR)/affine-test.exe \
+ $(CFG_VAR)/composite.exe
+
+
+OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(SOURCES))
+
+$(CFG_VAR)/%.obj: %.c
+ @mkdir -p $(CFG_VAR)
+ @$(CC) -c $(CFLAGS) -Fo"$@" $<
+
+$(CFG_VAR)/%.exe: $(CFG_VAR)/%.obj
+ $(LINK) /NOLOGO /OUT:$@ $< $(CFG_VAR)/utils.obj $(TEST_LDADD)
+
+all: $(OBJECTS) $(TESTS)
+ @exit 0
+
+clean:
+ @rm -f $(CFG_VAR)/*.obj $(CFG_VAR)/*.pdb || exit 0
diff --git a/pixman/test/composite.c b/pixman/test/composite.c
index 8b8a8f540..50a3c0644 100644
--- a/pixman/test/composite.c
+++ b/pixman/test/composite.c
@@ -426,6 +426,7 @@ calc_op (pixman_op_t op, double src, double dst, double srca, double dsta)
case PIXMAN_OP_HSL_LUMINOSITY:
default:
abort();
+ return 0; /* silence MSVC */
}
#undef mult_chan
}
@@ -617,18 +618,18 @@ eval_diff (color_t *expected, color_t *test, pixman_format_code_t format)
}
static char *
-describe_image (image_t *info, char *buf, int buflen)
+describe_image (image_t *info, char *buf)
{
if (info->size)
{
- snprintf (buf, buflen, "%s %dx%d%s",
- info->format->name,
- info->size, info->size,
- info->repeat ? "R" :"");
+ sprintf (buf, "%s %dx%d%s",
+ info->format->name,
+ info->size, info->size,
+ info->repeat ? "R" :"");
}
else
{
- snprintf (buf, buflen, "solid");
+ sprintf (buf, "solid");
}
return buf;
@@ -710,10 +711,9 @@ composite_test (image_t *dst,
{
char buf[40];
- snprintf (buf, sizeof (buf),
- "%s %scomposite",
- op->name,
- component_alpha ? "CA " : "");
+ sprintf (buf, "%s %scomposite",
+ op->name,
+ component_alpha ? "CA " : "");
printf ("%s test error of %.4f --\n"
" R G B A\n"
@@ -735,9 +735,9 @@ composite_test (image_t *dst,
mask->color->b, mask->color->a,
dst->color->r, dst->color->g,
dst->color->b, dst->color->a);
- printf ("src: %s, ", describe_image (src, buf, sizeof (buf)));
- printf ("mask: %s, ", describe_image (mask, buf, sizeof (buf)));
- printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf)));
+ printf ("src: %s, ", describe_image (src, buf));
+ printf ("mask: %s, ", describe_image (mask, buf));
+ printf ("dst: %s\n\n", describe_image (dst, buf));
}
else
{
@@ -747,8 +747,8 @@ composite_test (image_t *dst,
src->color->b, src->color->a,
dst->color->r, dst->color->g,
dst->color->b, dst->color->a);
- printf ("src: %s, ", describe_image (src, buf, sizeof (buf)));
- printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf)));
+ printf ("src: %s, ", describe_image (src, buf));
+ printf ("dst: %s\n\n", describe_image (dst, buf));
}
success = FALSE;
diff --git a/pixman/test/fetch-test.c b/pixman/test/fetch-test.c
index 2ca16ddbf..4554f9f9b 100644
--- a/pixman/test/fetch-test.c
+++ b/pixman/test/fetch-test.c
@@ -1,201 +1,196 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "pixman.h"
-#include <config.h>
-
-#define SIZE 1024
-
-static pixman_indexed_t mono_palette =
-{
- .rgba = { 0x00000000, 0x00ffffff },
-};
-
-
-typedef struct {
- pixman_format_code_t format;
- int width, height;
- int stride;
- uint32_t src[SIZE];
- uint32_t dst[SIZE];
- pixman_indexed_t *indexed;
-} testcase_t;
-
-static testcase_t testcases[] =
-{
- {
- .format = PIXMAN_a8r8g8b8,
- .width = 2, .height = 2,
- .stride = 8,
- .src = { 0x00112233, 0x44556677,
- 0x8899aabb, 0xccddeeff },
- .dst = { 0x00112233, 0x44556677,
- 0x8899aabb, 0xccddeeff },
- .indexed = NULL,
- },
- {
- .format = PIXMAN_g1,
- .width = 8, .height = 2,
- .stride = 4,
-#ifdef WORDS_BIGENDIAN
- .src =
- {
- 0xaa000000,
- 0x55000000
- },
-#else
- .src =
- {
- 0x00000055,
- 0x000000aa
- },
-#endif
- .dst =
- {
- 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
- 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff
- },
- .indexed = &mono_palette,
- },
-#if 0
- {
- .format = PIXMAN_g8,
- .width = 4, .height = 2,
- .stride = 4,
- .src = { 0x01234567,
- 0x89abcdef },
- .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
- 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
- },
-#endif
- /* FIXME: make this work on big endian */
- {
- .format = PIXMAN_yv12,
- .width = 8, .height = 2,
- .stride = 8,
-#ifdef WORDS_BIGENDIAN
- .src =
- {
- 0x00ff00ff, 0x00ff00ff,
- 0xff00ff00, 0xff00ff00,
- 0x80ff8000,
- 0x800080ff
- },
-#else
- .src =
- {
- 0xff00ff00, 0xff00ff00,
- 0x00ff00ff, 0x00ff00ff,
- 0x0080ff80,
- 0xff800080
- },
-#endif
- .dst =
- {
- 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
- 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
- 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000,
- 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee,
- },
- },
-};
-
-int n_test_cases = sizeof(testcases)/sizeof(testcases[0]);
-
-
-static uint32_t
-reader (const void *src, int size)
-{
- switch (size)
- {
- case 1:
- return *(uint8_t *)src;
- case 2:
- return *(uint16_t *)src;
- case 4:
- return *(uint32_t *)src;
- default:
- assert(0);
- }
-}
-
-
-static void
-writer (void *src, uint32_t value, int size)
-{
- switch (size)
- {
- case 1:
- *(uint8_t *)src = value;
- break;
- case 2:
- *(uint16_t *)src = value;
- break;
- case 4:
- *(uint32_t *)src = value;
- break;
- default:
- assert(0);
- }
-}
-
-
-int
-main (int argc, char **argv)
-{
- uint32_t dst[SIZE];
- pixman_image_t *src_img;
- pixman_image_t *dst_img;
- int i, j, x, y;
- int ret = 0;
-
- for (i = 0; i < n_test_cases; ++i)
- {
- for (j = 0; j < 2; ++j)
- {
- src_img = pixman_image_create_bits (testcases[i].format,
- testcases[i].width,
- testcases[i].height,
- testcases[i].src,
- testcases[i].stride);
- pixman_image_set_indexed(src_img, testcases[i].indexed);
-
- dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
- testcases[i].width,
- testcases[i].height,
- dst,
- testcases[i].width*4);
-
- if (j)
- {
- pixman_image_set_accessors (src_img, reader, writer);
- pixman_image_set_accessors (dst_img, reader, writer);
- }
-
- pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
- 0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height);
-
- pixman_image_unref (src_img);
- pixman_image_unref (dst_img);
-
- for (y = 0; y < testcases[i].height; ++y)
- {
- for (x = 0; x < testcases[i].width; ++x)
- {
- int offset = y * testcases[i].width + x;
-
- if (dst[offset] != testcases[i].dst[offset])
- {
- printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n",
- i + 1, 'a' + j,
- x, y,
- testcases[i].dst[offset], dst[offset]);
- ret = 1;
- }
- }
- }
- }
- }
-
- return ret;
-}
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "pixman.h"
+#include <config.h>
+
+#define SIZE 1024
+
+static pixman_indexed_t mono_palette =
+{
+ 0, { 0x00000000, 0x00ffffff },
+};
+
+
+typedef struct {
+ pixman_format_code_t format;
+ int width, height;
+ int stride;
+ uint32_t src[SIZE];
+ uint32_t dst[SIZE];
+ pixman_indexed_t *indexed;
+} testcase_t;
+
+static testcase_t testcases[] =
+{
+ {
+ PIXMAN_a8r8g8b8,
+ 2, 2,
+ 8,
+ { 0x00112233, 0x44556677,
+ 0x8899aabb, 0xccddeeff },
+ { 0x00112233, 0x44556677,
+ 0x8899aabb, 0xccddeeff },
+ NULL,
+ },
+ {
+ PIXMAN_g1,
+ 8, 2,
+ 4,
+#ifdef WORDS_BIGENDIAN
+ {
+ 0xaa000000,
+ 0x55000000
+ },
+#else
+ {
+ 0x00000055,
+ 0x000000aa
+ },
+#endif
+ {
+ 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
+ 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff
+ },
+ &mono_palette,
+ },
+#if 0
+ {
+ PIXMAN_g8,
+ 4, 2,
+ 4,
+ { 0x01234567,
+ 0x89abcdef },
+ { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
+ 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
+ },
+#endif
+ /* FIXME: make this work on big endian */
+ {
+ PIXMAN_yv12,
+ 8, 2,
+ 8,
+#ifdef WORDS_BIGENDIAN
+ {
+ 0x00ff00ff, 0x00ff00ff,
+ 0xff00ff00, 0xff00ff00,
+ 0x80ff8000,
+ 0x800080ff
+ },
+#else
+ {
+ 0xff00ff00, 0xff00ff00,
+ 0x00ff00ff, 0x00ff00ff,
+ 0x0080ff80,
+ 0xff800080
+ },
+#endif
+ {
+ 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
+ 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
+ 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000,
+ 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee,
+ },
+ },
+};
+
+int n_test_cases = sizeof(testcases)/sizeof(testcases[0]);
+
+
+static uint32_t
+reader (const void *src, int size)
+{
+ switch (size)
+ {
+ case 1:
+ return *(uint8_t *)src;
+ case 2:
+ return *(uint16_t *)src;
+ case 4:
+ return *(uint32_t *)src;
+ default:
+ assert(0);
+ return 0; /* silence MSVC */
+ }
+}
+
+
+static void
+writer (void *src, uint32_t value, int size)
+{
+ switch (size)
+ {
+ case 1:
+ *(uint8_t *)src = value;
+ break;
+ case 2:
+ *(uint16_t *)src = value;
+ break;
+ case 4:
+ *(uint32_t *)src = value;
+ break;
+ default:
+ assert(0);
+ }
+}
+
+
+int
+main (int argc, char **argv)
+{
+ uint32_t dst[SIZE];
+ pixman_image_t *src_img;
+ pixman_image_t *dst_img;
+ int i, j, x, y;
+ int ret = 0;
+
+ for (i = 0; i < n_test_cases; ++i)
+ {
+ for (j = 0; j < 2; ++j)
+ {
+ src_img = pixman_image_create_bits (testcases[i].format,
+ testcases[i].width,
+ testcases[i].height,
+ testcases[i].src,
+ testcases[i].stride);
+ pixman_image_set_indexed(src_img, testcases[i].indexed);
+
+ dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
+ testcases[i].width,
+ testcases[i].height,
+ dst,
+ testcases[i].width*4);
+
+ if (j)
+ {
+ pixman_image_set_accessors (src_img, reader, writer);
+ pixman_image_set_accessors (dst_img, reader, writer);
+ }
+
+ pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
+ 0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height);
+
+ pixman_image_unref (src_img);
+ pixman_image_unref (dst_img);
+
+ for (y = 0; y < testcases[i].height; ++y)
+ {
+ for (x = 0; x < testcases[i].width; ++x)
+ {
+ int offset = y * testcases[i].width + x;
+
+ if (dst[offset] != testcases[i].dst[offset])
+ {
+ printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n",
+ i + 1, 'a' + j,
+ x, y,
+ testcases[i].dst[offset], dst[offset]);
+ ret = 1;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+}
diff --git a/pixman/test/scaling-helpers-test.c b/pixman/test/scaling-helpers-test.c
new file mode 100644
index 000000000..c1861389b
--- /dev/null
+++ b/pixman/test/scaling-helpers-test.c
@@ -0,0 +1,93 @@
+#include <config.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include "utils.h"
+#include "pixman-fast-path.h"
+
+/* A trivial reference implementation for
+ * 'bilinear_pad_repeat_get_scanline_bounds'
+ */
+static void
+bilinear_pad_repeat_get_scanline_bounds_ref (int32_t source_image_width,
+ pixman_fixed_t vx_,
+ pixman_fixed_t unit_x,
+ int32_t * left_pad,
+ int32_t * left_tz,
+ int32_t * width,
+ int32_t * right_tz,
+ int32_t * right_pad)
+{
+ int w = *width;
+ *left_pad = 0;
+ *left_tz = 0;
+ *width = 0;
+ *right_tz = 0;
+ *right_pad = 0;
+ int64_t vx = vx_;
+ while (--w >= 0)
+ {
+ if (vx < 0)
+ {
+ if (vx + pixman_fixed_1 < 0)
+ *left_pad += 1;
+ else
+ *left_tz += 1;
+ }
+ else if (vx + pixman_fixed_1 >= pixman_int_to_fixed (source_image_width))
+ {
+ if (vx >= pixman_int_to_fixed (source_image_width))
+ *right_pad += 1;
+ else
+ *right_tz += 1;
+ }
+ else
+ {
+ *width += 1;
+ }
+ vx += unit_x;
+ }
+}
+
+int
+main (void)
+{
+ int i;
+ for (i = 0; i < 10000; i++)
+ {
+ int32_t left_pad1, left_tz1, width1, right_tz1, right_pad1;
+ int32_t left_pad2, left_tz2, width2, right_tz2, right_pad2;
+ pixman_fixed_t vx = lcg_rand_N(10000 << 16) - (3000 << 16);
+ int32_t width = lcg_rand_N(10000);
+ int32_t source_image_width = lcg_rand_N(10000) + 1;
+ pixman_fixed_t unit_x = lcg_rand_N(10 << 16) + 1;
+ width1 = width2 = width;
+
+ bilinear_pad_repeat_get_scanline_bounds_ref (source_image_width,
+ vx,
+ unit_x,
+ &left_pad1,
+ &left_tz1,
+ &width1,
+ &right_tz1,
+ &right_pad1);
+
+ bilinear_pad_repeat_get_scanline_bounds (source_image_width,
+ vx,
+ unit_x,
+ &left_pad2,
+ &left_tz2,
+ &width2,
+ &right_tz2,
+ &right_pad2);
+
+ assert (left_pad1 == left_pad2);
+ assert (left_tz1 == left_tz2);
+ assert (width1 == width2);
+ assert (right_tz1 == right_tz2);
+ assert (right_pad1 == right_pad2);
+ }
+
+ return 0;
+}
diff --git a/pixman/test/stress-test.c b/pixman/test/stress-test.c
index 0a89a52e9..a51737ea0 100644
--- a/pixman/test/stress-test.c
+++ b/pixman/test/stress-test.c
@@ -128,7 +128,7 @@ real_reader (const void *src, int size)
return *(uint32_t *)src;
default:
assert (0);
- break;
+ return 0; /* silence MSVC */
}
}
diff --git a/pixman/test/trap-crasher.c b/pixman/test/trap-crasher.c
index 42b82f674..96f3b0bab 100644
--- a/pixman/test/trap-crasher.c
+++ b/pixman/test/trap-crasher.c
@@ -1,27 +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);
-}
+#include <stdlib.h>
+#include <pixman.h>
+
+int
+main()
+{
+ pixman_image_t *dst;
+ pixman_trapezoid_t traps[1] = {
+ {
+ 2147483646,
+ 2147483647,
+ {
+ { 0, 0 },
+ { 0, 2147483647 }
+ },
+ {
+ { 65536, 0 },
+ { 0, 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);
+}