25
25
int max_extra_stride,
26
26
pixman_format_code_t *used_fmt)
28
int n = 0, i, width, height, stride;
28
int n = 0, width, height, stride;
29
29
pixman_format_code_t fmt;
31
31
pixman_image_t *img;
33
33
while (allowed_formats[n] != PIXMAN_null)
36
if (n > N_MOST_LIKELY_FORMATS && lcg_rand_n (4) != 0)
36
if (n > N_MOST_LIKELY_FORMATS && prng_rand_n (4) != 0)
37
37
n = N_MOST_LIKELY_FORMATS;
38
fmt = allowed_formats[lcg_rand_n (n)];
38
fmt = allowed_formats[prng_rand_n (n)];
40
width = lcg_rand_n (max_width) + 1;
41
height = lcg_rand_n (max_height) + 1;
40
width = prng_rand_n (max_width) + 1;
41
height = prng_rand_n (max_height) + 1;
42
42
stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 +
43
lcg_rand_n (max_extra_stride + 1);
43
prng_rand_n (max_extra_stride + 1);
44
44
stride = (stride + 3) & ~3;
46
46
/* do the allocation */
47
47
buf = aligned_malloc (64, stride * height);
49
/* initialize image with random data */
50
for (i = 0; i < stride * height; i++)
52
/* generation is biased to having more 0 or 255 bytes as
53
* they are more likely to be special-cased in code
55
*((uint8_t *)buf + i) = lcg_rand_n (4) ? lcg_rand_n (256) :
56
(lcg_rand_n (2) ? 0 : 255);
49
if (prng_rand_n (4) == 0)
51
/* uniform distribution */
52
prng_randmemset (buf, stride * height, 0);
56
/* significantly increased probability for 0x00 and 0xFF */
57
prng_randmemset (buf, stride * height, RANDMEMSET_MORE_00_AND_FF);
59
60
img = pixman_image_create_bits (fmt, width, height, buf, stride);
67
68
pixman_image_set_indexed (img, &(y_palette[PIXMAN_FORMAT_BPP (fmt)]));
70
if (lcg_rand_n (16) == 0)
71
if (prng_rand_n (16) == 0)
71
72
pixman_image_set_filter (img, PIXMAN_FILTER_BILINEAR, NULL, 0);
73
74
image_endian_swap (img);
83
84
pixman_format_code_t fmt)
85
86
uint32_t crc32 = 0;
86
int stride = pixman_image_get_stride (img);
87
87
uint32_t *data = pixman_image_get_data (img);
88
int height = pixman_image_get_height (img);
90
89
if (fmt != PIXMAN_null)
92
/* mask unused 'x' part */
93
if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) &&
94
PIXMAN_FORMAT_DEPTH (fmt) != 0)
97
uint32_t *data = pixman_image_get_data (img);
98
uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1;
100
if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA ||
101
PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_RGBA)
103
mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt));
106
for (i = 0; i * PIXMAN_FORMAT_BPP (fmt) < 32; i++)
107
mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt));
109
for (i = 0; i < stride * height / 4; i++)
113
/* swap endiannes in order to provide identical results on both big
114
* and litte endian systems
116
image_endian_swap (img);
117
crc32 = compute_crc32 (initcrc, data, stride * height);
90
crc32 = compute_crc32_for_image (initcrc, img);
120
92
pixman_image_unref (img);
278
252
if (max_extra_stride > 8)
279
253
max_extra_stride = 8;
283
op = op_list[lcg_rand_n (ARRAY_LENGTH (op_list))];
255
prng_srand (testnum);
257
op = op_list[prng_rand_n (ARRAY_LENGTH (op_list))];
287
261
/* normal image */
288
262
src_img = create_random_image (img_fmt_list, max_width, max_height,
311
285
dstbuf = pixman_image_get_data (dst_img);
312
286
srcbuf = pixman_image_get_data (src_img);
314
src_x = lcg_rand_n (src_width);
315
src_y = lcg_rand_n (src_height);
316
dst_x = lcg_rand_n (dst_width);
317
dst_y = lcg_rand_n (dst_height);
288
src_x = prng_rand_n (src_width);
289
src_y = prng_rand_n (src_height);
290
dst_x = prng_rand_n (dst_width);
291
dst_y = prng_rand_n (dst_height);
320
294
mask_fmt = PIXMAN_null;
325
299
if ((src_fmt == PIXMAN_x8r8g8b8 || src_fmt == PIXMAN_x8b8g8r8) &&
326
(lcg_rand_n (4) == 0))
300
(prng_rand_n (4) == 0))
329
mask_fmt = lcg_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8;
303
mask_fmt = prng_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8;
330
304
mask_img = pixman_image_create_bits (mask_fmt,
337
311
maskbuf = srcbuf;
339
else if (lcg_rand_n (2))
313
else if (prng_rand_n (2))
343
317
mask_img = create_random_image (mask_fmt_list, max_width, max_height,
344
318
max_extra_stride, &mask_fmt);
351
325
pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL);
355
329
pixman_image_set_component_alpha (mask_img, 1);
357
mask_x = lcg_rand_n (pixman_image_get_width (mask_img));
358
mask_y = lcg_rand_n (pixman_image_get_height (mask_img));
331
mask_x = prng_rand_n (pixman_image_get_width (mask_img));
332
mask_y = prng_rand_n (pixman_image_get_height (mask_img));
362
w = lcg_rand_n (dst_width - dst_x + 1);
363
h = lcg_rand_n (dst_height - dst_y + 1);
336
w = prng_rand_n (dst_width - dst_x + 1);
337
h = prng_rand_n (dst_height - dst_y + 1);
367
printf ("op=%d, src_fmt=%08X, dst_fmt=%08X, mask_fmt=%08X\n",
368
op, src_fmt, dst_fmt, mask_fmt);
341
printf ("op=%s\n", operator_name (op));
342
printf ("src_fmt=%s, dst_fmt=%s, mask_fmt=%s\n",
343
format_name (src_fmt), format_name (dst_fmt),
344
format_name (mask_fmt));
369
345
printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n",
370
346
src_width, src_height, dst_width, dst_height);
371
347
printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n",