aboutsummaryrefslogtreecommitdiff
path: root/pixman/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-08-29 14:48:31 +0200
committermarha <marha@users.sourceforge.net>2011-08-29 14:48:31 +0200
commit924a6ffc82a7af0ca311af711ea2cf973dc6ff15 (patch)
treef5ee6d0aaf321029a4abb12c3c051c0434dde308 /pixman/test
parent8e57a7fcbf736b8e437baf0bbccb93095d97617f (diff)
parent01df5d59e56a1b060568f8cad2e89f7eea22fc70 (diff)
downloadvcxsrv-924a6ffc82a7af0ca311af711ea2cf973dc6ff15.tar.gz
vcxsrv-924a6ffc82a7af0ca311af711ea2cf973dc6ff15.tar.bz2
vcxsrv-924a6ffc82a7af0ca311af711ea2cf973dc6ff15.zip
Merge remote-tracking branch 'origin/released'
Conflicts: apps/xwininfo/configure.ac apps/xwininfo/xwininfo.c libX11/configure.ac libX11/specs/libX11/AppC.xml libX11/specs/libX11/AppD.xml libX11/specs/libX11/CH03.xml libX11/specs/libX11/CH04.xml libX11/specs/libX11/CH05.xml libX11/specs/libX11/CH06.xml libX11/specs/libX11/CH07.xml libX11/specs/libX11/CH08.xml libX11/specs/libX11/CH09.xml libX11/specs/libX11/CH11.xml libX11/specs/libX11/CH12.xml libX11/specs/libX11/CH13.xml libX11/specs/libX11/CH14.xml libX11/specs/libX11/CH15.xml libX11/specs/libX11/CH16.xml libxcb/configure.ac libxcb/src/c_client.py libxcb/src/xcb_auth.c libxcb/src/xcb_util.c mesalib/common.py mesalib/configs/linux-dri mesalib/docs/GL3.txt mesalib/docs/download.html mesalib/docs/install.html mesalib/include/GL/internal/dri_interface.h mesalib/scons/custom.py mesalib/scons/gallium.py mesalib/src/gallium/auxiliary/util/u_math.h mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c mesalib/src/glsl/ast_function.cpp mesalib/src/glsl/ast_to_hir.cpp mesalib/src/glsl/glcpp/glcpp-parse.y mesalib/src/glsl/glsl_parser_extras.cpp mesalib/src/glsl/glsl_parser_extras.h mesalib/src/glsl/ir.cpp mesalib/src/glsl/ir.h mesalib/src/glsl/ir_clone.cpp mesalib/src/glsl/ir_print_visitor.cpp mesalib/src/glsl/ir_validate.cpp mesalib/src/glsl/linker.cpp mesalib/src/glsl/main.cpp mesalib/src/glsl/opt_tree_grafting.cpp mesalib/src/mapi/glapi/gen/Makefile mesalib/src/mapi/glapi/gen/gl_XML.py mesalib/src/mapi/glapi/gen/gl_table.py mesalib/src/mapi/glapi/glapi_mapi_tmp.h mesalib/src/mapi/glapi/glapi_sparc.S mesalib/src/mapi/glapi/glapi_x86-64.S mesalib/src/mapi/glapi/glapi_x86.S mesalib/src/mapi/glapi/glapitemp.h mesalib/src/mapi/glapi/glprocs.h mesalib/src/mapi/mapi/u_thread.c mesalib/src/mapi/mapi/u_thread.h mesalib/src/mesa/SConscript mesalib/src/mesa/drivers/common/driverfuncs.c mesalib/src/mesa/drivers/windows/gldirect/dglcontext.c mesalib/src/mesa/main/api_arrayelt.c mesalib/src/mesa/main/bufferobj.c mesalib/src/mesa/main/compiler.h mesalib/src/mesa/main/dd.h mesalib/src/mesa/main/dlist.c mesalib/src/mesa/main/enums.c mesalib/src/mesa/main/es_generator.py mesalib/src/mesa/main/fbobject.c mesalib/src/mesa/main/imports.h mesalib/src/mesa/main/mtypes.h mesalib/src/mesa/main/pbo.c mesalib/src/mesa/main/remap_helper.h mesalib/src/mesa/main/shared.c mesalib/src/mesa/main/texgetimage.c mesalib/src/mesa/main/teximage.c mesalib/src/mesa/main/uniforms.c mesalib/src/mesa/program/ir_to_mesa.cpp mesalib/src/mesa/program/prog_optimize.c mesalib/src/mesa/program/register_allocate.c mesalib/src/mesa/program/register_allocate.h mesalib/src/mesa/sources.mak mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c mesalib/src/mesa/state_tracker/st_cb_texture.c mesalib/src/mesa/state_tracker/st_texture.h mesalib/src/mesa/swrast/s_context.c mesalib/src/mesa/tnl/t_draw.c mesalib/src/mesa/vbo/vbo_exec_array.c mesalib/src/mesa/vbo/vbo_save_api.c pixman/pixman/pixman-arm-common.h pixman/pixman/pixman-fast-path.c pixman/pixman/pixman-inlines.h pixman/test/Makefile.am pixman/test/utils.c pixman/test/utils.h xorg-server/configure.ac xorg-server/fb/fbblt.c xorg-server/hw/xquartz/darwin.c xorg-server/xkeyboard-config/symbols/de
Diffstat (limited to 'pixman/test')
-rw-r--r--pixman/test/Makefile.am2
-rw-r--r--pixman/test/Makefile.win325
-rw-r--r--pixman/test/lowlevel-blt-bench.c7
-rw-r--r--pixman/test/region-contains-test.c169
-rw-r--r--pixman/test/scaling-helpers-test.c2
-rw-r--r--pixman/test/utils.c11
-rw-r--r--pixman/test/utils.h16
7 files changed, 199 insertions, 13 deletions
diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am
index d785c2c2e..eca692236 100644
--- a/pixman/test/Makefile.am
+++ b/pixman/test/Makefile.am
@@ -15,6 +15,7 @@ TESTPROGRAMS = \
scaling-crash-test \
scaling-helpers-test \
gradient-crash-test \
+ region-contains-test \
alphamap \
stress-test \
composite-traps-test \
@@ -26,6 +27,7 @@ TESTPROGRAMS = \
pdf_op_test_SOURCES = pdf-op-test.c utils.c utils.h
region_test_SOURCES = region-test.c utils.c utils.h
blitters_test_SOURCES = blitters-test.c utils.c utils.h
+region_contains_test_SOURCES = region-contains-test.c utils.c utils.h
composite_traps_test_SOURCES = composite-traps-test.c utils.c utils.h
scaling_test_SOURCES = scaling-test.c utils.c utils.h
affine_test_SOURCES = affine-test.c utils.c utils.h
diff --git a/pixman/test/Makefile.win32 b/pixman/test/Makefile.win32
index c71afe187..a62b6fc35 100644
--- a/pixman/test/Makefile.win32
+++ b/pixman/test/Makefile.win32
@@ -35,6 +35,7 @@ SOURCES = \
scaling-test.c \
affine-test.c \
composite.c \
+ lowlevel-blt-bench.c \
utils.c
TESTS = \
@@ -56,6 +57,8 @@ TESTS = \
$(CFG_VAR)/affine-test.exe \
$(CFG_VAR)/composite.exe
+BENCHMARKS = \
+ $(CFG_VAR)/lowlevel-blt-bench.exe
OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(SOURCES))
@@ -66,7 +69,7 @@ $(CFG_VAR)/%.obj: %.c
$(CFG_VAR)/%.exe: $(CFG_VAR)/%.obj
$(LINK) /NOLOGO /OUT:$@ $< $(CFG_VAR)/utils.obj $(TEST_LDADD)
-all: $(OBJECTS) $(TESTS)
+all: $(OBJECTS) $(TESTS) $(BENCHMARKS)
@exit 0
clean:
diff --git a/pixman/test/lowlevel-blt-bench.c b/pixman/test/lowlevel-blt-bench.c
index d58587d51..099e434f0 100644
--- a/pixman/test/lowlevel-blt-bench.c
+++ b/pixman/test/lowlevel-blt-bench.c
@@ -22,16 +22,13 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#define PIXMAN_USE_INTERNAL_API
+#include <pixman.h>
-#include "pixman-private.h"
#include "utils.h"
#define SOLID_FLAG 1
diff --git a/pixman/test/region-contains-test.c b/pixman/test/region-contains-test.c
new file mode 100644
index 000000000..d761c4bdf
--- /dev/null
+++ b/pixman/test/region-contains-test.c
@@ -0,0 +1,169 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "utils.h"
+
+static void
+make_random_region (pixman_region32_t *region)
+{
+ int n_boxes;
+
+ pixman_region32_init (region);
+
+ n_boxes = lcg_rand_n (64);
+ while (n_boxes--)
+ {
+ int32_t x1, y1, x2, y2;
+
+ x1 = (int32_t)lcg_rand_u32();
+ y1 = (int32_t)lcg_rand_u32();
+ x2 = (int32_t)lcg_rand_u32();
+ y2 = (int32_t)lcg_rand_u32();
+
+ pixman_region32_union_rect (region, region, x1, y1, x2, y2);
+ }
+}
+
+static void
+print_box (pixman_box32_t *box)
+{
+ printf (" %d %d %d %d\n", box->x1, box->y1, box->x2, box->y2);
+}
+
+static int32_t
+random_coord (pixman_region32_t *region, pixman_bool_t x)
+{
+ pixman_box32_t *b, *bb;
+ int n_boxes;
+ int begin, end;
+
+ if (lcg_rand_n (14))
+ {
+ bb = pixman_region32_rectangles (region, &n_boxes);
+ if (n_boxes == 0)
+ goto use_extent;
+ b = bb + lcg_rand_n (n_boxes);
+ }
+ else
+ {
+ use_extent:
+ b = pixman_region32_extents (region);
+ n_boxes = 1;
+ }
+
+ if (x)
+ {
+ begin = b->x1;
+ end = b->x2;
+ }
+ else
+ {
+ begin = b->y1;
+ end = b->y2;
+ }
+
+ switch (lcg_rand_n (5))
+ {
+ case 0:
+ return begin - lcg_rand_u32();
+ case 1:
+ return end + lcg_rand_u32 ();
+ case 2:
+ return end;
+ case 3:
+ return begin;
+ default:
+ return (begin + end) / 2;
+ }
+ return 0;
+}
+
+static uint32_t
+compute_crc32_u32 (uint32_t crc32, uint32_t v)
+{
+ if (!is_little_endian())
+ {
+ v = ((v & 0xff000000) >> 24) |
+ ((v & 0x00ff0000) >> 8) |
+ ((v & 0x0000ff00) << 8) |
+ ((v & 0x000000ff) << 24);
+ }
+
+ return compute_crc32 (crc32, &v, sizeof (int32_t));
+}
+
+static uint32_t
+crc32_box32 (uint32_t crc32, pixman_box32_t *box)
+{
+ crc32 = compute_crc32_u32 (crc32, box->x1);
+ crc32 = compute_crc32_u32 (crc32, box->y1);
+ crc32 = compute_crc32_u32 (crc32, box->x2);
+ crc32 = compute_crc32_u32 (crc32, box->y2);
+
+ return crc32;
+}
+
+static uint32_t
+test_region_contains_rectangle (int i, int verbose)
+{
+ pixman_box32_t box;
+ pixman_box32_t rbox = { 0, 0, 0, 0 };
+ pixman_region32_t region;
+ uint32_t r, r1, r2, r3, r4, crc32;
+
+ lcg_srand (i);
+
+ make_random_region (&region);
+
+ box.x1 = random_coord (&region, TRUE);
+ box.x2 = box.x1 + lcg_rand_u32 ();
+ box.y1 = random_coord (&region, FALSE);
+ box.y2 = box.y1 + lcg_rand_u32 ();
+
+ if (verbose)
+ {
+ int n_rects;
+ pixman_box32_t *boxes;
+
+ boxes = pixman_region32_rectangles (&region, &n_rects);
+
+ printf ("region:\n");
+ while (n_rects--)
+ print_box (boxes++);
+ printf ("box:\n");
+ print_box (&box);
+ }
+
+ crc32 = 0;
+
+ r1 = pixman_region32_contains_point (&region, box.x1, box.y1, &rbox);
+ crc32 = crc32_box32 (crc32, &rbox);
+ r2 = pixman_region32_contains_point (&region, box.x1, box.y2, &rbox);
+ crc32 = crc32_box32 (crc32, &rbox);
+ r3 = pixman_region32_contains_point (&region, box.x2, box.y1, &rbox);
+ crc32 = crc32_box32 (crc32, &rbox);
+ r4 = pixman_region32_contains_point (&region, box.x2, box.y2, &rbox);
+ crc32 = crc32_box32 (crc32, &rbox);
+
+ r = pixman_region32_contains_rectangle (&region, &box);
+ r = (i << 8) | (r << 4) | (r1 << 3) | (r2 << 2) | (r3 << 1) | (r4 << 0);
+
+ crc32 = compute_crc32_u32 (crc32, r);
+
+ if (verbose)
+ printf ("results: %d %d %d %d %d\n", (r & 0xf0) >> 4, r1, r2, r3, r4);
+
+ pixman_region32_fini (&region);
+
+ return crc32;
+}
+
+int
+main (int argc, const char *argv[])
+{
+ return fuzzer_test_main ("region_contains",
+ 1000000,
+ 0x86311506,
+ test_region_contains_rectangle,
+ argc, argv);
+}
diff --git a/pixman/test/scaling-helpers-test.c b/pixman/test/scaling-helpers-test.c
index c1861389b..a38cac544 100644
--- a/pixman/test/scaling-helpers-test.c
+++ b/pixman/test/scaling-helpers-test.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <assert.h>
#include "utils.h"
-#include "pixman-fast-path.h"
+#include "pixman-inlines.h"
/* A trivial reference implementation for
* 'bilinear_pad_repeat_get_scanline_bounds'
diff --git a/pixman/test/utils.c b/pixman/test/utils.c
index 06c5e5128..da494cf59 100644
--- a/pixman/test/utils.c
+++ b/pixman/test/utils.c
@@ -130,6 +130,14 @@ compute_crc32 (uint32_t in_crc32,
return (crc32 ^ 0xFFFFFFFF);
}
+pixman_bool_t
+is_little_endian (void)
+{
+ volatile uint16_t endian_check_var = 0x1234;
+
+ return (*(volatile uint8_t *)&endian_check_var == 0x34);
+}
+
/* perform endian conversion of pixel data
*/
void
@@ -142,8 +150,7 @@ image_endian_swap (pixman_image_t *img)
int i, j;
/* swap bytes only on big endian systems */
- volatile uint16_t endian_check_var = 0x1234;
- if (*(volatile uint8_t *)&endian_check_var != 0x12)
+ if (is_little_endian())
return;
if (bpp == 8)
diff --git a/pixman/test/utils.h b/pixman/test/utils.h
index 8f0e0c0e5..9b4d984f7 100644
--- a/pixman/test/utils.h
+++ b/pixman/test/utils.h
@@ -44,10 +44,14 @@ lcg_rand_N (int max)
static inline uint32_t
lcg_rand_u32 (void)
{
- uint32_t lo = lcg_rand();
- uint32_t hi = lcg_rand();
-
- return (hi << 16) | lo;
+ /* This uses the 10/11 most significant bits from the 3 lcg results
+ * (and mixes them with the low from the adjacent one).
+ */
+ uint32_t lo = lcg_rand() >> -(32 - 15 - 11 * 2);
+ uint32_t mid = lcg_rand() << (32 - 15 - 11 * 1);
+ uint32_t hi = lcg_rand() << (32 - 15 - 11 * 0);
+
+ return (hi ^ mid ^ lo);
}
/* CRC 32 computation
@@ -57,6 +61,10 @@ compute_crc32 (uint32_t in_crc32,
const void *buf,
size_t buf_len);
+/* Returns TRUE if running on a little endian system */
+pixman_bool_t
+is_little_endian (void);
+
/* perform endian conversion of pixel data
*/
void