aboutsummaryrefslogtreecommitdiff
path: root/pixman/test/fetch-test.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
committermarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
commit3562e78743202e43aec8727005182a2558117eca (patch)
tree8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /pixman/test/fetch-test.c
downloadvcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz
vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2
vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip
Checked in the following released items:
xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz
Diffstat (limited to 'pixman/test/fetch-test.c')
-rw-r--r--pixman/test/fetch-test.c163
1 files changed, 163 insertions, 0 deletions
diff --git a/pixman/test/fetch-test.c b/pixman/test/fetch-test.c
new file mode 100644
index 000000000..717f6d4fd
--- /dev/null
+++ b/pixman/test/fetch-test.c
@@ -0,0 +1,163 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "pixman.h"
+
+
+#define SIZE 1024
+
+
+pixman_indexed_t mono_pallete = {
+ .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;
+
+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,
+ .src = { 0x00000055,
+ 0x000000aa },
+ .dst = { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
+ 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff },
+ .indexed = &mono_pallete,
+ },
+#if 0
+ {
+ .format = PIXMAN_g8,
+ .width = 4, .height = 2,
+ .stride = 4,
+ .src = { 0x01234567,
+ 0x89abcdef },
+ .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
+ 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
+ },
+#endif
+ {
+ .format = PIXMAN_yv12,
+ .width = 8, .height = 2,
+ .stride = 8,
+ .src = { 0xff00ff00, 0xff00ff00,
+ 0x00ff00ff, 0x00ff00ff,
+ 0x0080ff80,
+ 0xff800080},
+ .dst = {
+ 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
+ 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
+ 0xffffffff, 0xff000000, 0xffffe113, 0xffb80000,
+ 0xffffffff, 0xff000000, 0xff4affff, 0xff0023ee,
+ },
+ },
+};
+
+const int ntestcases = 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 < ntestcases; ++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;
+}