blitters-test.c revision 952204ab
1a450e446Smrg/* 2a450e446Smrg * Test program, which stresses the use of different color formats and 3a450e446Smrg * compositing operations. 4a450e446Smrg * 5a450e446Smrg * Just run it without any command line arguments, and it will report either 6a450e446Smrg * "blitters test passed" - everything is ok 7a450e446Smrg * "blitters test failed!" - there is some problem 8a450e446Smrg * 9a450e446Smrg * In the case of failure, finding the problem involves the following steps: 10a450e446Smrg * 1. Get the reference 'blitters-test' binary. It makes sense to disable all 11a450e446Smrg * the cpu specific optimizations in pixman and also configure it with 12a450e446Smrg * '--disable-shared' option. Those who are paranoid can also tweak the 13a450e446Smrg * sources to disable all fastpath functions. The resulting binary 14a450e446Smrg * can be renamed to something like 'blitters-test.ref'. 15a450e446Smrg * 2. Compile the buggy binary (also with the '--disable-shared' option). 16a450e446Smrg * 3. Run 'ruby blitters-test-bisect.rb ./blitters-test.ref ./blitters-test' 17a450e446Smrg * 4. Look at the information about failed case (destination buffer content 18a450e446Smrg * will be shown) and try to figure out what is wrong. Loading 19a450e446Smrg * test program in gdb, specifying failed test number in the command 20a450e446Smrg * line with '-' character prepended and setting breakpoint on 21a450e446Smrg * 'pixman_image_composite' function can provide detailed information 22a450e446Smrg * about function arguments 23a450e446Smrg */ 24a450e446Smrg#include <assert.h> 25a450e446Smrg#include <stdlib.h> 26a450e446Smrg#include <stdio.h> 27a450e446Smrg#include <config.h> 28952204abSmrg#include "utils.h" 29a450e446Smrg 30952204abSmrgstatic pixman_indexed_t palette; 31a450e446Smrg 32a450e446Smrgstatic void * 33a450e446Smrgaligned_malloc (size_t align, size_t size) 34a450e446Smrg{ 35a450e446Smrg void *result; 36a450e446Smrg 37a450e446Smrg#ifdef HAVE_POSIX_MEMALIGN 38952204abSmrg if (posix_memalign (&result, align, size) != 0) 39952204abSmrg result = NULL; 40a450e446Smrg#else 41a450e446Smrg result = malloc (size); 42a450e446Smrg#endif 43a450e446Smrg 44a450e446Smrg return result; 45a450e446Smrg} 46a450e446Smrg 47a450e446Smrg/* Create random image for testing purposes */ 48a450e446Smrgstatic pixman_image_t * 49a450e446Smrgcreate_random_image (pixman_format_code_t *allowed_formats, 50a450e446Smrg int max_width, 51a450e446Smrg int max_height, 52a450e446Smrg int max_extra_stride, 53a450e446Smrg pixman_format_code_t *used_fmt) 54a450e446Smrg{ 55a450e446Smrg int n = 0, i, width, height, stride; 56a450e446Smrg pixman_format_code_t fmt; 57a450e446Smrg uint32_t *buf; 58a450e446Smrg pixman_image_t *img; 59a450e446Smrg 60a450e446Smrg while (allowed_formats[n] != -1) 61a450e446Smrg n++; 62a450e446Smrg fmt = allowed_formats[lcg_rand_n (n)]; 63952204abSmrg 64a450e446Smrg width = lcg_rand_n (max_width) + 1; 65a450e446Smrg height = lcg_rand_n (max_height) + 1; 66a450e446Smrg stride = (width * PIXMAN_FORMAT_BPP (fmt) + 7) / 8 + 67a450e446Smrg lcg_rand_n (max_extra_stride + 1); 68a450e446Smrg stride = (stride + 3) & ~3; 69a450e446Smrg 70a450e446Smrg /* do the allocation */ 71a450e446Smrg buf = aligned_malloc (64, stride * height); 72a450e446Smrg 73a450e446Smrg /* initialize image with random data */ 74a450e446Smrg for (i = 0; i < stride * height; i++) 75a450e446Smrg { 76a450e446Smrg /* generation is biased to having more 0 or 255 bytes as 77a450e446Smrg * they are more likely to be special-cased in code 78a450e446Smrg */ 79a450e446Smrg *((uint8_t *)buf + i) = lcg_rand_n (4) ? lcg_rand_n (256) : 80a450e446Smrg (lcg_rand_n (2) ? 0 : 255); 81a450e446Smrg } 82a450e446Smrg 83a450e446Smrg img = pixman_image_create_bits (fmt, width, height, buf, stride); 84a450e446Smrg 85952204abSmrg if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR || 86952204abSmrg PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY) 87952204abSmrg { 88952204abSmrg pixman_image_set_indexed (img, &palette); 89952204abSmrg } 90952204abSmrg 91a450e446Smrg image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt)); 92a450e446Smrg 93a450e446Smrg if (used_fmt) *used_fmt = fmt; 94a450e446Smrg return img; 95a450e446Smrg} 96a450e446Smrg 97a450e446Smrg/* Free random image, and optionally update crc32 based on its data */ 98a450e446Smrgstatic uint32_t 99a450e446Smrgfree_random_image (uint32_t initcrc, 100a450e446Smrg pixman_image_t *img, 101a450e446Smrg pixman_format_code_t fmt) 102a450e446Smrg{ 103a450e446Smrg uint32_t crc32 = 0; 104a450e446Smrg int stride = pixman_image_get_stride (img); 105a450e446Smrg uint32_t *data = pixman_image_get_data (img); 106952204abSmrg int height = pixman_image_get_height (img); 107a450e446Smrg 108a450e446Smrg if (fmt != -1) 109a450e446Smrg { 110a450e446Smrg /* mask unused 'x' part */ 111a450e446Smrg if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) && 112a450e446Smrg PIXMAN_FORMAT_DEPTH (fmt) != 0) 113a450e446Smrg { 114a450e446Smrg int i; 115a450e446Smrg uint32_t *data = pixman_image_get_data (img); 116a450e446Smrg uint32_t mask = (1 << PIXMAN_FORMAT_DEPTH (fmt)) - 1; 117a450e446Smrg 118a450e446Smrg if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_BGRA) 119a450e446Smrg mask <<= (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt)); 120a450e446Smrg 121a450e446Smrg for (i = 0; i < 32; i++) 122a450e446Smrg mask |= mask << (i * PIXMAN_FORMAT_BPP (fmt)); 123a450e446Smrg 124a450e446Smrg for (i = 0; i < stride * height / 4; i++) 125a450e446Smrg data[i] &= mask; 126a450e446Smrg } 127a450e446Smrg 128a450e446Smrg /* swap endiannes in order to provide identical results on both big 129a450e446Smrg * and litte endian systems 130a450e446Smrg */ 131a450e446Smrg image_endian_swap (img, PIXMAN_FORMAT_BPP (fmt)); 132a450e446Smrg crc32 = compute_crc32 (initcrc, data, stride * height); 133a450e446Smrg } 134a450e446Smrg 135a450e446Smrg pixman_image_unref (img); 136a450e446Smrg free (data); 137a450e446Smrg 138a450e446Smrg return crc32; 139a450e446Smrg} 140a450e446Smrg 141a450e446Smrgstatic pixman_op_t op_list[] = { 142a450e446Smrg PIXMAN_OP_SRC, 143a450e446Smrg PIXMAN_OP_OVER, 144a450e446Smrg PIXMAN_OP_ADD, 145a450e446Smrg PIXMAN_OP_CLEAR, 146a450e446Smrg PIXMAN_OP_SRC, 147a450e446Smrg PIXMAN_OP_DST, 148a450e446Smrg PIXMAN_OP_OVER, 149a450e446Smrg PIXMAN_OP_OVER_REVERSE, 150a450e446Smrg PIXMAN_OP_IN, 151a450e446Smrg PIXMAN_OP_IN_REVERSE, 152a450e446Smrg PIXMAN_OP_OUT, 153a450e446Smrg PIXMAN_OP_OUT_REVERSE, 154a450e446Smrg PIXMAN_OP_ATOP, 155a450e446Smrg PIXMAN_OP_ATOP_REVERSE, 156a450e446Smrg PIXMAN_OP_XOR, 157a450e446Smrg PIXMAN_OP_ADD, 158a450e446Smrg PIXMAN_OP_SATURATE, 159a450e446Smrg PIXMAN_OP_DISJOINT_CLEAR, 160a450e446Smrg PIXMAN_OP_DISJOINT_SRC, 161a450e446Smrg PIXMAN_OP_DISJOINT_DST, 162a450e446Smrg PIXMAN_OP_DISJOINT_OVER, 163a450e446Smrg PIXMAN_OP_DISJOINT_OVER_REVERSE, 164a450e446Smrg PIXMAN_OP_DISJOINT_IN, 165a450e446Smrg PIXMAN_OP_DISJOINT_IN_REVERSE, 166a450e446Smrg PIXMAN_OP_DISJOINT_OUT, 167a450e446Smrg PIXMAN_OP_DISJOINT_OUT_REVERSE, 168a450e446Smrg PIXMAN_OP_DISJOINT_ATOP, 169a450e446Smrg PIXMAN_OP_DISJOINT_ATOP_REVERSE, 170a450e446Smrg PIXMAN_OP_DISJOINT_XOR, 171a450e446Smrg PIXMAN_OP_CONJOINT_CLEAR, 172a450e446Smrg PIXMAN_OP_CONJOINT_SRC, 173a450e446Smrg PIXMAN_OP_CONJOINT_DST, 174a450e446Smrg PIXMAN_OP_CONJOINT_OVER, 175a450e446Smrg PIXMAN_OP_CONJOINT_OVER_REVERSE, 176a450e446Smrg PIXMAN_OP_CONJOINT_IN, 177a450e446Smrg PIXMAN_OP_CONJOINT_IN_REVERSE, 178a450e446Smrg PIXMAN_OP_CONJOINT_OUT, 179a450e446Smrg PIXMAN_OP_CONJOINT_OUT_REVERSE, 180a450e446Smrg PIXMAN_OP_CONJOINT_ATOP, 181a450e446Smrg PIXMAN_OP_CONJOINT_ATOP_REVERSE, 182a450e446Smrg PIXMAN_OP_CONJOINT_XOR, 183a450e446Smrg PIXMAN_OP_MULTIPLY, 184a450e446Smrg PIXMAN_OP_SCREEN, 185a450e446Smrg PIXMAN_OP_OVERLAY, 186a450e446Smrg PIXMAN_OP_DARKEN, 187a450e446Smrg PIXMAN_OP_LIGHTEN, 188a450e446Smrg PIXMAN_OP_COLOR_DODGE, 189a450e446Smrg PIXMAN_OP_COLOR_BURN, 190a450e446Smrg PIXMAN_OP_HARD_LIGHT, 191a450e446Smrg PIXMAN_OP_DIFFERENCE, 192a450e446Smrg PIXMAN_OP_EXCLUSION, 193a450e446Smrg#if 0 /* these use floating point math and are not always bitexact on different platforms */ 194a450e446Smrg PIXMAN_OP_SOFT_LIGHT, 195a450e446Smrg PIXMAN_OP_HSL_HUE, 196a450e446Smrg PIXMAN_OP_HSL_SATURATION, 197a450e446Smrg PIXMAN_OP_HSL_COLOR, 198a450e446Smrg PIXMAN_OP_HSL_LUMINOSITY, 199a450e446Smrg#endif 200a450e446Smrg}; 201a450e446Smrg 202a450e446Smrgstatic pixman_format_code_t img_fmt_list[] = { 203a450e446Smrg PIXMAN_a8r8g8b8, 204a450e446Smrg PIXMAN_x8r8g8b8, 205a450e446Smrg PIXMAN_r5g6b5, 206a450e446Smrg PIXMAN_r3g3b2, 207a450e446Smrg PIXMAN_a8, 208a450e446Smrg PIXMAN_a8b8g8r8, 209a450e446Smrg PIXMAN_x8b8g8r8, 210a450e446Smrg PIXMAN_b8g8r8a8, 211a450e446Smrg PIXMAN_b8g8r8x8, 212a450e446Smrg PIXMAN_r8g8b8, 213a450e446Smrg PIXMAN_b8g8r8, 214a450e446Smrg PIXMAN_r5g6b5, 215a450e446Smrg PIXMAN_b5g6r5, 216a450e446Smrg PIXMAN_x2r10g10b10, 217a450e446Smrg PIXMAN_a2r10g10b10, 218a450e446Smrg PIXMAN_x2b10g10r10, 219a450e446Smrg PIXMAN_a2b10g10r10, 220a450e446Smrg PIXMAN_a1r5g5b5, 221a450e446Smrg PIXMAN_x1r5g5b5, 222a450e446Smrg PIXMAN_a1b5g5r5, 223a450e446Smrg PIXMAN_x1b5g5r5, 224a450e446Smrg PIXMAN_a4r4g4b4, 225a450e446Smrg PIXMAN_x4r4g4b4, 226a450e446Smrg PIXMAN_a4b4g4r4, 227a450e446Smrg PIXMAN_x4b4g4r4, 228a450e446Smrg PIXMAN_a8, 229a450e446Smrg PIXMAN_r3g3b2, 230a450e446Smrg PIXMAN_b2g3r3, 231a450e446Smrg PIXMAN_a2r2g2b2, 232a450e446Smrg PIXMAN_a2b2g2r2, 233a450e446Smrg PIXMAN_c8, 234a450e446Smrg PIXMAN_g8, 235a450e446Smrg PIXMAN_x4c4, 236a450e446Smrg PIXMAN_x4g4, 237a450e446Smrg PIXMAN_c4, 238a450e446Smrg PIXMAN_g4, 239a450e446Smrg PIXMAN_g1, 240a450e446Smrg PIXMAN_x4a4, 241a450e446Smrg PIXMAN_a4, 242a450e446Smrg PIXMAN_r1g2b1, 243a450e446Smrg PIXMAN_b1g2r1, 244a450e446Smrg PIXMAN_a1r1g1b1, 245a450e446Smrg PIXMAN_a1b1g1r1, 246a450e446Smrg PIXMAN_a1, 247a450e446Smrg -1 248a450e446Smrg}; 249a450e446Smrg 250a450e446Smrgstatic pixman_format_code_t mask_fmt_list[] = { 251a450e446Smrg PIXMAN_a8r8g8b8, 252a450e446Smrg PIXMAN_a8, 253a450e446Smrg PIXMAN_a4, 254a450e446Smrg PIXMAN_a1, 255a450e446Smrg -1 256a450e446Smrg}; 257a450e446Smrg 258a450e446Smrg 259a450e446Smrg/* 260a450e446Smrg * Composite operation with pseudorandom images 261a450e446Smrg */ 262a450e446Smrguint32_t 263a450e446Smrgtest_composite (uint32_t initcrc, int testnum, int verbose) 264a450e446Smrg{ 265a450e446Smrg int i; 266a450e446Smrg pixman_image_t *src_img = NULL; 267a450e446Smrg pixman_image_t *dst_img = NULL; 268a450e446Smrg pixman_image_t *mask_img = NULL; 269a450e446Smrg int src_width, src_height; 270a450e446Smrg int dst_width, dst_height; 271a450e446Smrg int src_stride, dst_stride; 272a450e446Smrg int src_x, src_y; 273a450e446Smrg int dst_x, dst_y; 274952204abSmrg int mask_x, mask_y; 275a450e446Smrg int w, h; 276a450e446Smrg int op; 277a450e446Smrg pixman_format_code_t src_fmt, dst_fmt, mask_fmt; 278952204abSmrg uint32_t *dstbuf, *srcbuf, *maskbuf; 279a450e446Smrg uint32_t crc32; 280a450e446Smrg int max_width, max_height, max_extra_stride; 281a450e446Smrg 282a450e446Smrg max_width = max_height = 24 + testnum / 10000; 283a450e446Smrg max_extra_stride = 4 + testnum / 1000000; 284a450e446Smrg 285a450e446Smrg if (max_width > 256) 286a450e446Smrg max_width = 256; 287a450e446Smrg 288a450e446Smrg if (max_height > 16) 289a450e446Smrg max_height = 16; 290a450e446Smrg 291a450e446Smrg if (max_extra_stride > 8) 292a450e446Smrg max_extra_stride = 8; 293a450e446Smrg 294a450e446Smrg lcg_srand (testnum); 295a450e446Smrg 296a450e446Smrg op = op_list[lcg_rand_n (sizeof (op_list) / sizeof (op_list[0]))]; 297a450e446Smrg 298a450e446Smrg if (lcg_rand_n (8)) 299a450e446Smrg { 300a450e446Smrg /* normal image */ 301a450e446Smrg src_img = create_random_image (img_fmt_list, max_width, max_height, 302a450e446Smrg max_extra_stride, &src_fmt); 303a450e446Smrg } 304a450e446Smrg else 305a450e446Smrg { 306a450e446Smrg /* solid case */ 307a450e446Smrg src_img = create_random_image (img_fmt_list, 1, 1, 308a450e446Smrg max_extra_stride, &src_fmt); 309a450e446Smrg 310a450e446Smrg pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL); 311a450e446Smrg } 312a450e446Smrg 313a450e446Smrg dst_img = create_random_image (img_fmt_list, max_width, max_height, 314a450e446Smrg max_extra_stride, &dst_fmt); 315a450e446Smrg 316952204abSmrg src_width = pixman_image_get_width (src_img); 317952204abSmrg src_height = pixman_image_get_height (src_img); 318952204abSmrg src_stride = pixman_image_get_stride (src_img); 319952204abSmrg 320952204abSmrg dst_width = pixman_image_get_width (dst_img); 321952204abSmrg dst_height = pixman_image_get_height (dst_img); 322952204abSmrg dst_stride = pixman_image_get_stride (dst_img); 323952204abSmrg 324952204abSmrg dstbuf = pixman_image_get_data (dst_img); 325952204abSmrg srcbuf = pixman_image_get_data (src_img); 326952204abSmrg 327952204abSmrg src_x = lcg_rand_n (src_width); 328952204abSmrg src_y = lcg_rand_n (src_height); 329952204abSmrg dst_x = lcg_rand_n (dst_width); 330952204abSmrg dst_y = lcg_rand_n (dst_height); 331952204abSmrg 332a450e446Smrg mask_img = NULL; 333a450e446Smrg mask_fmt = -1; 334952204abSmrg mask_x = 0; 335952204abSmrg mask_y = 0; 336952204abSmrg maskbuf = NULL; 337a450e446Smrg 338952204abSmrg if ((src_fmt == PIXMAN_x8r8g8b8 || src_fmt == PIXMAN_x8b8g8r8) && 339952204abSmrg (lcg_rand_n (4) == 0)) 340952204abSmrg { 341952204abSmrg /* PIXBUF */ 342952204abSmrg mask_fmt = lcg_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8; 343952204abSmrg mask_img = pixman_image_create_bits (mask_fmt, 344952204abSmrg src_width, 345952204abSmrg src_height, 346952204abSmrg srcbuf, 347952204abSmrg src_stride); 348952204abSmrg mask_x = src_x; 349952204abSmrg mask_y = src_y; 350952204abSmrg maskbuf = srcbuf; 351952204abSmrg } 352952204abSmrg else if (lcg_rand_n (2)) 353a450e446Smrg { 354a450e446Smrg if (lcg_rand_n (2)) 355a450e446Smrg { 356a450e446Smrg mask_img = create_random_image (mask_fmt_list, max_width, max_height, 357a450e446Smrg max_extra_stride, &mask_fmt); 358a450e446Smrg } 359a450e446Smrg else 360a450e446Smrg { 361a450e446Smrg /* solid case */ 362a450e446Smrg mask_img = create_random_image (mask_fmt_list, 1, 1, 363a450e446Smrg max_extra_stride, &mask_fmt); 364a450e446Smrg pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL); 365a450e446Smrg } 366a450e446Smrg 367a450e446Smrg if (lcg_rand_n (2)) 368a450e446Smrg pixman_image_set_component_alpha (mask_img, 1); 369a450e446Smrg 370952204abSmrg mask_x = lcg_rand_n (pixman_image_get_width (mask_img)); 371952204abSmrg mask_y = lcg_rand_n (pixman_image_get_height (mask_img)); 372952204abSmrg } 373a450e446Smrg 374a450e446Smrg 375a450e446Smrg w = lcg_rand_n (dst_width - dst_x + 1); 376a450e446Smrg h = lcg_rand_n (dst_height - dst_y + 1); 377a450e446Smrg 378a450e446Smrg if (verbose) 379a450e446Smrg { 380a450e446Smrg printf ("op=%d, src_fmt=%08X, dst_fmt=%08X, mask_fmt=%08X\n", 381a450e446Smrg op, src_fmt, dst_fmt, mask_fmt); 382a450e446Smrg printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n", 383a450e446Smrg src_width, src_height, dst_width, dst_height); 384a450e446Smrg printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n", 385a450e446Smrg src_x, src_y, dst_x, dst_y); 386a450e446Smrg printf ("src_stride=%d, dst_stride=%d\n", 387a450e446Smrg src_stride, dst_stride); 388a450e446Smrg printf ("w=%d, h=%d\n", w, h); 389a450e446Smrg } 390a450e446Smrg 391a450e446Smrg pixman_image_composite (op, src_img, mask_img, dst_img, 392952204abSmrg src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); 393a450e446Smrg 394a450e446Smrg if (verbose) 395a450e446Smrg { 396a450e446Smrg int j; 397a450e446Smrg 398a450e446Smrg printf ("---\n"); 399a450e446Smrg for (i = 0; i < dst_height; i++) 400a450e446Smrg { 401a450e446Smrg for (j = 0; j < dst_stride; j++) 402a450e446Smrg { 403a450e446Smrg if (j == (dst_width * PIXMAN_FORMAT_BPP (dst_fmt) + 7) / 8) 404a450e446Smrg printf ("| "); 405a450e446Smrg 406a450e446Smrg printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j)); 407a450e446Smrg } 408a450e446Smrg printf ("\n"); 409a450e446Smrg } 410a450e446Smrg printf ("---\n"); 411a450e446Smrg } 412a450e446Smrg 413a450e446Smrg free_random_image (initcrc, src_img, -1); 414a450e446Smrg crc32 = free_random_image (initcrc, dst_img, dst_fmt); 415a450e446Smrg 416a450e446Smrg if (mask_img) 417952204abSmrg { 418952204abSmrg if (srcbuf == maskbuf) 419952204abSmrg pixman_image_unref(mask_img); 420952204abSmrg else 421952204abSmrg free_random_image (initcrc, mask_img, -1); 422952204abSmrg } 423952204abSmrg 424a450e446Smrg 425a450e446Smrg return crc32; 426a450e446Smrg} 427a450e446Smrg 428952204abSmrgstatic void 429952204abSmrginitialize_palette (void) 430952204abSmrg{ 431952204abSmrg int i; 432952204abSmrg 433952204abSmrg for (i = 0; i < PIXMAN_MAX_INDEXED; ++i) 434952204abSmrg palette.rgba[i] = lcg_rand (); 435952204abSmrg 436952204abSmrg for (i = 0; i < 32768; ++i) 437952204abSmrg palette.ent[i] = lcg_rand() & 0xff; 438952204abSmrg} 439952204abSmrg 440a450e446Smrgint 441a450e446Smrgmain (int argc, char *argv[]) 442a450e446Smrg{ 443a450e446Smrg int i, n1 = 1, n2 = 0; 444a450e446Smrg uint32_t crc = 0; 445a450e446Smrg int verbose = getenv ("VERBOSE") != NULL; 446a450e446Smrg 447952204abSmrg initialize_palette(); 448952204abSmrg 449a450e446Smrg if (argc >= 3) 450a450e446Smrg { 451a450e446Smrg n1 = atoi (argv[1]); 452a450e446Smrg n2 = atoi (argv[2]); 453a450e446Smrg } 454a450e446Smrg else if (argc >= 2) 455a450e446Smrg { 456a450e446Smrg n2 = atoi (argv[1]); 457a450e446Smrg } 458a450e446Smrg else 459a450e446Smrg { 460a450e446Smrg n1 = 1; 461a450e446Smrg n2 = 2000000; 462a450e446Smrg } 463a450e446Smrg 464a450e446Smrg if (n2 < 0) 465a450e446Smrg { 466a450e446Smrg crc = test_composite (0, abs (n2), 1); 467a450e446Smrg printf ("crc32=%08X\n", crc); 468a450e446Smrg } 469a450e446Smrg else 470a450e446Smrg { 471a450e446Smrg for (i = n1; i <= n2; i++) 472a450e446Smrg { 473a450e446Smrg crc = test_composite (crc, i, 0); 474a450e446Smrg 475a450e446Smrg if (verbose) 476a450e446Smrg printf ("%d: %08X\n", i, crc); 477a450e446Smrg } 478a450e446Smrg printf ("crc32=%08X\n", crc); 479a450e446Smrg 480a450e446Smrg if (n2 == 2000000) 481a450e446Smrg { 482a450e446Smrg /* Predefined value for running with all the fastpath functions 483a450e446Smrg disabled. It needs to be updated every time when changes are 484a450e446Smrg introduced to this program or behavior of pixman changes! */ 485952204abSmrg if (crc == 0x8F9F7DC1) 486a450e446Smrg { 487a450e446Smrg printf ("blitters test passed\n"); 488a450e446Smrg } 489a450e446Smrg else 490a450e446Smrg { 491a450e446Smrg printf ("blitters test failed!\n"); 492a450e446Smrg return 1; 493a450e446Smrg } 494a450e446Smrg } 495a450e446Smrg } 496a450e446Smrg return 0; 497a450e446Smrg} 498