/* * Composite operation with pseudorandom images */ uint32_t test_composite (int testnum, int verbose) { int i; pixman_image_t *src_img = NULL; pixman_image_t *dst_img = NULL; pixman_image_t *mask_img = NULL; int src_width, src_height; int dst_width, dst_height; int src_stride, dst_stride; int src_x, src_y; int dst_x, dst_y; int mask_x, mask_y; int w, h; pixman_op_t op; pixman_format_code_t src_fmt, dst_fmt, mask_fmt; uint32_t *dstbuf, *srcbuf, *maskbuf; uint32_t crc32; int max_width, max_height, max_extra_stride; FLOAT_REGS_CORRUPTION_DETECTOR_START (); max_width = max_height = 24 + testnum / 10000; max_extra_stride = 4 + testnum / 1000000; if (max_width > 256) max_width = 256; if (max_height > 16) max_height = 16; if (max_extra_stride > 8) max_extra_stride = 8; lcg_srand (testnum); op = op_list[lcg_rand_n (sizeof (op_list) / sizeof (op_list[0]))]; if (lcg_rand_n (8)) { /* normal image */ src_img = create_random_image (img_fmt_list, max_width, max_height, max_extra_stride, &src_fmt); } else { /* solid case */ src_img = create_random_image (img_fmt_list, 1, 1, max_extra_stride, &src_fmt); pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL); } dst_img = create_random_image (img_fmt_list, max_width, max_height, max_extra_stride, &dst_fmt); src_width = pixman_image_get_width (src_img); src_height = pixman_image_get_height (src_img); src_stride = pixman_image_get_stride (src_img); dst_width = pixman_image_get_width (dst_img); dst_height = pixman_image_get_height (dst_img); dst_stride = pixman_image_get_stride (dst_img); dstbuf = pixman_image_get_data (dst_img); srcbuf = pixman_image_get_data (src_img); src_x = lcg_rand_n (src_width); src_y = lcg_rand_n (src_height); dst_x = lcg_rand_n (dst_width); dst_y = lcg_rand_n (dst_height); mask_img = NULL; mask_fmt = PIXMAN_null; mask_x = 0; mask_y = 0; maskbuf = NULL; if ((src_fmt == PIXMAN_x8r8g8b8 || src_fmt == PIXMAN_x8b8g8r8) && (lcg_rand_n (4) == 0)) { /* PIXBUF */ mask_fmt = lcg_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8; mask_img = pixman_image_create_bits (mask_fmt, src_width, src_height, srcbuf, src_stride); mask_x = src_x; mask_y = src_y; maskbuf = srcbuf; } else if (lcg_rand_n (2)) { if (lcg_rand_n (2)) { mask_img = create_random_image (mask_fmt_list, max_width, max_height, max_extra_stride, &mask_fmt); } else { /* solid case */ mask_img = create_random_image (mask_fmt_list, 1, 1, max_extra_stride, &mask_fmt); pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL); } if (lcg_rand_n (2)) pixman_image_set_component_alpha (mask_img, 1); mask_x = lcg_rand_n (pixman_image_get_width (mask_img)); mask_y = lcg_rand_n (pixman_image_get_height (mask_img)); } w = lcg_rand_n (dst_width - dst_x + 1); h = lcg_rand_n (dst_height - dst_y + 1); if (verbose) { printf ("op=%d, src_fmt=%08X, dst_fmt=%08X, mask_fmt=%08X\n", op, src_fmt, dst_fmt, mask_fmt); printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n", src_width, src_height, dst_width, dst_height); printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n", src_x, src_y, dst_x, dst_y); printf ("src_stride=%d, dst_stride=%d\n", src_stride, dst_stride); printf ("w=%d, h=%d\n", w, h); } pixman_image_composite (op, src_img, mask_img, dst_img, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); if (verbose) { int j; printf ("---\n"); for (i = 0; i < dst_height; i++) { for (j = 0; j < dst_stride; j++) { if (j == (dst_width * PIXMAN_FORMAT_BPP (dst_fmt) + 7) / 8) printf ("| "); printf ("%02X ", *((uint8_t *)dstbuf + i * dst_stride + j)); } printf ("\n"); } printf ("---\n"); } free_random_image (0, src_img, PIXMAN_null); crc32 = free_random_image (0, dst_img, dst_fmt); if (mask_img) { if (srcbuf == maskbuf) pixman_image_unref(mask_img); else free_random_image (0, mask_img, PIXMAN_null); } FLOAT_REGS_CORRUPTION_DETECTOR_FINISH (); return crc32; }
/* * Composite operation with pseudorandom images */ uint32_t test_composite (int testnum, int verbose) { pixman_image_t *src_img = NULL; pixman_image_t *dst_img = NULL; pixman_image_t *mask_img = NULL; int src_width, src_height; int dst_width, dst_height; int src_stride, dst_stride; int src_x, src_y; int dst_x, dst_y; int mask_x, mask_y; int w, h; pixman_op_t op; pixman_format_code_t src_fmt, dst_fmt, mask_fmt; uint32_t *srcbuf, *maskbuf; uint32_t crc32; int max_width, max_height, max_extra_stride; FLOAT_REGS_CORRUPTION_DETECTOR_START (); max_width = max_height = 24 + testnum / 10000; max_extra_stride = 4 + testnum / 1000000; if (max_width > 256) max_width = 256; if (max_height > 16) max_height = 16; if (max_extra_stride > 8) max_extra_stride = 8; prng_srand (testnum); op = op_list[prng_rand_n (ARRAY_LENGTH (op_list))]; if (prng_rand_n (8)) { /* normal image */ src_img = create_random_image (img_fmt_list, max_width, max_height, max_extra_stride, &src_fmt); } else { /* solid case */ src_img = create_random_image (img_fmt_list, 1, 1, max_extra_stride, &src_fmt); pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL); } dst_img = create_random_image (img_fmt_list, max_width, max_height, max_extra_stride, &dst_fmt); src_width = pixman_image_get_width (src_img); src_height = pixman_image_get_height (src_img); src_stride = pixman_image_get_stride (src_img); dst_width = pixman_image_get_width (dst_img); dst_height = pixman_image_get_height (dst_img); dst_stride = pixman_image_get_stride (dst_img); srcbuf = pixman_image_get_data (src_img); src_x = prng_rand_n (src_width); src_y = prng_rand_n (src_height); dst_x = prng_rand_n (dst_width); dst_y = prng_rand_n (dst_height); mask_img = NULL; mask_fmt = PIXMAN_null; mask_x = 0; mask_y = 0; maskbuf = NULL; if ((src_fmt == PIXMAN_x8r8g8b8 || src_fmt == PIXMAN_x8b8g8r8) && (prng_rand_n (4) == 0)) { /* PIXBUF */ mask_fmt = prng_rand_n (2) ? PIXMAN_a8r8g8b8 : PIXMAN_a8b8g8r8; mask_img = pixman_image_create_bits (mask_fmt, src_width, src_height, srcbuf, src_stride); mask_x = src_x; mask_y = src_y; maskbuf = srcbuf; } else if (prng_rand_n (2)) { if (prng_rand_n (2)) { mask_img = create_random_image (mask_fmt_list, max_width, max_height, max_extra_stride, &mask_fmt); } else { /* solid case */ mask_img = create_random_image (mask_fmt_list, 1, 1, max_extra_stride, &mask_fmt); pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL); } if (prng_rand_n (2)) pixman_image_set_component_alpha (mask_img, 1); mask_x = prng_rand_n (pixman_image_get_width (mask_img)); mask_y = prng_rand_n (pixman_image_get_height (mask_img)); } w = prng_rand_n (dst_width - dst_x + 1); h = prng_rand_n (dst_height - dst_y + 1); if (verbose) { printf ("op=%s\n", operator_name (op)); printf ("src_fmt=%s, dst_fmt=%s, mask_fmt=%s\n", format_name (src_fmt), format_name (dst_fmt), format_name (mask_fmt)); printf ("src_width=%d, src_height=%d, dst_width=%d, dst_height=%d\n", src_width, src_height, dst_width, dst_height); printf ("src_x=%d, src_y=%d, dst_x=%d, dst_y=%d\n", src_x, src_y, dst_x, dst_y); printf ("src_stride=%d, dst_stride=%d\n", src_stride, dst_stride); printf ("w=%d, h=%d\n", w, h); } pixman_image_composite (op, src_img, mask_img, dst_img, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); if (verbose) print_image (dst_img); free_random_image (0, src_img, PIXMAN_null); crc32 = free_random_image (0, dst_img, dst_fmt); if (mask_img) { if (srcbuf == maskbuf) pixman_image_unref(mask_img); else free_random_image (0, mask_img, PIXMAN_null); } FLOAT_REGS_CORRUPTION_DETECTOR_FINISH (); return crc32; }