diff options
Diffstat (limited to 'pixman/test/stress-test.c')
-rw-r--r-- | pixman/test/stress-test.c | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/pixman/test/stress-test.c b/pixman/test/stress-test.c index 7fc067e82..9280802bd 100644 --- a/pixman/test/stress-test.c +++ b/pixman/test/stress-test.c @@ -83,7 +83,7 @@ get_size (void) default: case 2: - return lcg_rand_n (200); + return lcg_rand_n (100); case 4: return lcg_rand_n (2000) + 1000; @@ -181,9 +181,27 @@ log_rand (void) { uint32_t mask; - mask = (1 << lcg_rand_n (31)) - 1; + mask = (1 << lcg_rand_n (10)) - 1; - return (lcg_rand () & mask) - (mask >> 1); + return (lcg_rand_u32 () & mask) - (mask >> 1); +} + +static int32_t +rand_x (pixman_image_t *image) +{ + if (image->type == BITS) + return lcg_rand_n (image->bits.width); + else + return log_rand (); +} + +static int32_t +rand_y (pixman_image_t *image) +{ + if (image->type == BITS) + return lcg_rand_n (image->bits.height); + else + return log_rand (); } static pixman_image_t * @@ -225,7 +243,7 @@ create_random_bits_image (void) width = get_size (); height = get_size (); - if ((uint64_t)width * height > 200000) + while ((uint64_t)width * height > 200000) { if (lcg_rand_n(2) == 0) height = 200000 / width; @@ -304,8 +322,8 @@ create_random_bits_image (void) filter = filters[lcg_rand_n (ARRAY_LENGTH (filters))]; if (filter == PIXMAN_FILTER_CONVOLUTION) { - int width = lcg_rand_n (17); - int height = lcg_rand_n (19); + int width = lcg_rand_n (3); + int height = lcg_rand_n (4); n_coefficients = width * height + 2; coefficients = malloc (n_coefficients * sizeof (pixman_fixed_t)); @@ -365,7 +383,7 @@ set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map) pixman_image_set_repeat (image, repeat); /* Alpha map */ - if (allow_alpha_map && lcg_rand_n (3) == 0) + if (allow_alpha_map && lcg_rand_n (4) == 0) { pixman_image_t *alpha_map; int16_t x, y; @@ -376,8 +394,8 @@ set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map) { set_general_properties (alpha_map, FALSE); - x = lcg_rand_N (100000) - 65536; - y = lcg_rand_N (100000) - 65536; + x = rand_x (image) - image->bits.width / 2; + y = rand_y (image) - image->bits.height / 2; pixman_image_set_alpha_map (image, alpha_map, x, y); @@ -389,14 +407,14 @@ set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map) pixman_image_set_component_alpha (image, lcg_rand_n (3) == 0); /* Clip region */ - if (lcg_rand_n (8) != 0) + if (lcg_rand_n (8) < 2) { pixman_region32_t region; int i, n_rects; pixman_region32_init (®ion); - switch (lcg_rand_n (10)) + switch (lcg_rand_n (12)) { case 0: n_rects = 0; @@ -433,6 +451,27 @@ set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map) ®ion, ®ion, x, y, width, height); } + if (image->type == BITS && lcg_rand_n (8) != 0) + { + uint32_t width, height; + int x, y; + int i; + + /* Also add a couple of clip rectangles inside the image + * so that compositing will actually take place. + */ + for (i = 0; i < 5; ++i) + { + x = lcg_rand_n (2 * image->bits.width) - image->bits.width; + y = lcg_rand_n (2 * image->bits.height) - image->bits.height; + width = lcg_rand_n (image->bits.width) - x + 10; + height = lcg_rand_n (image->bits.height) - y + 10; + + pixman_region32_union_rect ( + ®ion, ®ion, x, y, width, height); + } + } + pixman_image_set_clip_region32 (image, ®ion); pixman_region32_fini (®ion); @@ -762,11 +801,11 @@ run_test (uint32_t seed, pixman_bool_t verbose, uint32_t mod) pixman_image_composite32 (op, source, mask, dest, - log_rand(), log_rand(), - log_rand(), log_rand(), - log_rand(), log_rand(), - absolute (log_rand()), - absolute (log_rand())); + rand_x (source), rand_y (source), + rand_x (mask), rand_y (mask), + 0, 0, + dest->bits.width, + dest->bits.height); } if (source) pixman_image_unref (source); |