diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-12-01 11:58:04 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-12-01 18:19:35 +0000 |
commit | 55612909182c253bbfe8278a8867c93c9b09bc01 (patch) | |
tree | 62d6641fd6f554ea4b330142c4ac01372d6eeb6b | |
parent | dc32549256620a42b6e22a9f3a5ff27a785a827e (diff) |
composite: Batch tests
Process an entire num_mask x num_op in a single GetImage pass.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | rendercheck.h | 9 | ||||
-rw-r--r-- | t_composite.c | 182 | ||||
-rw-r--r-- | tests.c | 174 |
3 files changed, 188 insertions, 177 deletions
diff --git a/rendercheck.h b/rendercheck.h index 5b802a2..3e9966d 100644 --- a/rendercheck.h +++ b/rendercheck.h @@ -149,9 +149,12 @@ blend_test(Display *dpy, picture_info *win, picture_info *dst, const picture_info **dst_color, int num_dst); Bool -composite_test(Display *dpy, picture_info *win, picture_info *dst, int op, - picture_info *src_color, picture_info *mask_color, picture_info *dst_color, - Bool componentAlpha, Bool print_errors); +composite_test(Display *dpy, picture_info *win, picture_info *dst, + const int *op, int num_op, + const picture_info **src_color, int num_src, + const picture_info **mask_color, int num_mask, + const picture_info **dst_color, int num_dst, + Bool componentAlpha, Bool print_errors); Bool dstcoords_test(Display *dpy, picture_info *win, int op, picture_info *dst, diff --git a/t_composite.c b/t_composite.c index 25b4dd0..315650b 100644 --- a/t_composite.c +++ b/t_composite.c @@ -24,81 +24,129 @@ #include "rendercheck.h" -#define TEST_WIDTH 10 -#define TEST_HEIGHT 10 - /* Test a composite of a given operation, source, mask, and destination picture. * Fills the window, and samples from the 0,0 pixel corner. */ Bool -composite_test(Display *dpy, picture_info *win, picture_info *dst, int op, - picture_info *src_color, picture_info *mask_color, picture_info *dst_color, - Bool componentAlpha, Bool print_errors) +composite_test(Display *dpy, picture_info *win, picture_info *dst, + const int *op, int num_op, + const picture_info **src_color, int num_src, + const picture_info **mask_color, int num_mask, + const picture_info **dst_color, int num_dst, + Bool componentAlpha, Bool print_errors) { color4d expected, tested, tdst, tmsk; char testname[40]; - XRenderPictureAttributes pa; - Bool success = TRUE; - int i; - - if (componentAlpha) { - pa.component_alpha = TRUE; - XRenderChangePicture(dpy, mask_color->pict, CPComponentAlpha, - &pa); - } - for (i = 0; i < pixmap_move_iter; i++) { - XRenderComposite(dpy, PictOpSrc, dst_color->pict, 0, dst->pict, - 0, 0, 0, 0, 0, 0, TEST_WIDTH, TEST_HEIGHT); - XRenderComposite(dpy, ops[op].op, src_color->pict, - mask_color->pict, dst->pict, 0, 0, 0, 0, 0, 0, - TEST_WIDTH, TEST_HEIGHT); - } - get_pixel(dpy, dst, 0, 0, &tested); - copy_pict_to_win(dpy, dst, win, TEST_WIDTH, TEST_HEIGHT); + int i, s, m, d, iter; - if (componentAlpha) { - pa.component_alpha = FALSE; - XRenderChangePicture(dpy, mask_color->pict, CPComponentAlpha, - &pa); - } + for (d = 0; d < num_dst; d++) { + tdst = dst_color[d]->color; + color_correct(dst, &tdst); + + for (m = 0; m < num_mask; m++) { + XImage *image; + + if (componentAlpha) { + XRenderPictureAttributes pa; + + pa.component_alpha = TRUE; + XRenderChangePicture(dpy, mask_color[m]->pict, + CPComponentAlpha, &pa); + } + + for (iter = 0; iter < pixmap_move_iter; iter++) { + XRenderComposite(dpy, PictOpSrc, + dst_color[d]->pict, 0, dst->pict, + 0, 0, + 0, 0, + 0, 0, + num_op, num_src); + for (s = 0; s < num_src; s++) { + for (i = 0; i < num_op; i++) + XRenderComposite(dpy, ops[op[i]].op, + src_color[s]->pict, + mask_color[m]->pict, + dst->pict, + 0, 0, + 0, 0, + i, s, + 1, 1); + } + } - if (componentAlpha && mask_color->format->direct.redMask == 0) { - /* Ax component-alpha masks expand alpha into all color - * channels. XXX: This should be located somewhere generic. - */ - tmsk.a = mask_color->color.a; - tmsk.r = mask_color->color.a; - tmsk.g = mask_color->color.a; - tmsk.b = mask_color->color.a; - } else - tmsk = mask_color->color; - - tdst = dst_color->color; - color_correct(dst, &tdst); - do_composite(ops[op].op, &src_color->color, &tmsk, &tdst, - &expected, componentAlpha); - color_correct(dst, &expected); - - snprintf(testname, 40, "%s %scomposite", ops[op].name, - componentAlpha ? "CA " : ""); - if (!eval_diff(testname, &expected, &tested, 0, 0, is_verbose && - print_errors)) { - if (print_errors) - printf("src color: %.2f %.2f %.2f %.2f\n" - "msk color: %.2f %.2f %.2f %.2f\n" - "dst color: %.2f %.2f %.2f %.2f\n", - src_color->color.r, src_color->color.g, - src_color->color.b, src_color->color.a, - mask_color->color.r, mask_color->color.g, - mask_color->color.b, mask_color->color.a, - dst_color->color.r, dst_color->color.g, - dst_color->color.b, dst_color->color.a); - printf("src: %s, mask: %s, dst: %s\n", src_color->name, - mask_color->name, dst->name); - success = FALSE; - } else if (is_verbose) { - printf("src: %s, mask: %s, dst: %s\n", src_color->name, - mask_color->name, dst->name); + if (componentAlpha) { + XRenderPictureAttributes pa; + + pa.component_alpha = FALSE; + XRenderChangePicture(dpy, mask_color[m]->pict, + CPComponentAlpha, &pa); + } + + image = XGetImage(dpy, dst->d, + 0, 0, num_op, num_src, + 0xffffffff, ZPixmap); + copy_pict_to_win(dpy, dst, win, win_width, win_height); + + if (componentAlpha && + mask_color[m]->format->direct.redMask == 0) { + /* Ax component-alpha masks expand alpha into + * all color channels. + * XXX: This should be located somewhere generic. + */ + tmsk.a = mask_color[m]->color.a; + tmsk.r = mask_color[m]->color.a; + tmsk.g = mask_color[m]->color.a; + tmsk.b = mask_color[m]->color.a; + } else + tmsk = mask_color[m]->color; + + for (s = 0; s < num_src; s++) { + for (i = 0; i < num_op; i++) { + get_pixel_from_image(image, dst, i, s, &tested); + + do_composite(ops[op[i]].op, + &src_color[s]->color, &tmsk, &tdst, + &expected, componentAlpha); + color_correct(dst, &expected); + + snprintf(testname, 40, + "%s %scomposite", ops[op[i]].name, + componentAlpha ? "CA " : ""); + if (!eval_diff(testname, &expected, &tested, 0, 0, + is_verbose && print_errors)) { + if (print_errors) + printf("src color: %.2f %.2f %.2f %.2f\n" + "msk color: %.2f %.2f %.2f %.2f\n" + "dst color: %.2f %.2f %.2f %.2f\n", + src_color[s]->color.r, + src_color[s]->color.g, + src_color[s]->color.b, + src_color[s]->color.a, + mask_color[m]->color.r, + mask_color[m]->color.g, + mask_color[m]->color.b, + mask_color[m]->color.a, + dst_color[d]->color.r, + dst_color[d]->color.g, + dst_color[d]->color.b, + dst_color[d]->color.a); + printf("src: %s, mask: %s, dst: %s\n", + src_color[s]->name, + mask_color[m]->name, + dst->name); + XDestroyImage(image); + return FALSE; + } else if (is_verbose) { + printf("src: %s, mask: %s, dst: %s\n", + src_color[s]->name, + mask_color[m]->name, + dst->name); + } + } + } + XDestroyImage(image); + } } - return success; + + return TRUE; } @@ -296,11 +296,17 @@ create_formats_list(Display *dpy) Bool do_tests(Display *dpy, picture_info *win) { - int i, j, src, dst = 0, mask; + int i, j, src; int num_dests; picture_info *dests, *pictures_1x1, *pictures_10x10, picture_3x3, *pictures_solid; int success_mask = 0, tests_passed = 0, tests_total = 0; int num_tests; + int *test_ops; + const picture_info **test_src, **test_mask, **test_dst; + int num_test_ops = 0; + int num_test_src = 0; + int num_test_mask = 0; + int num_test_dst = 0; create_formats_list(dpy); @@ -426,6 +432,30 @@ do { \ num_tests = num_colors * nformats; + test_ops = malloc(sizeof(int)*num_ops); + test_src = malloc(sizeof(picture_info*)*(2*num_tests+num_colors)); + test_mask = malloc(sizeof(picture_info*)*2*num_tests); + test_dst = malloc(sizeof(picture_info*)*(num_tests+num_colors)); + + for (i = 0; i < num_ops; i++) { + if (ops[i].disabled) + continue; + + test_ops[num_test_ops++] = i; + } + + for (i = 0; i < num_tests; i++) { + test_src[num_test_src++] = &pictures_1x1[i]; + test_src[num_test_src++] = &pictures_10x10[i]; + test_mask[num_test_mask++] = &pictures_1x1[i]; + test_mask[num_test_mask++] = &pictures_10x10[i]; + test_dst[num_test_dst++] = &pictures_1x1[i]; + } + for (i = 0; i < num_colors; i++) { + test_src[num_test_src++] = &pictures_solid[i]; + test_dst[num_test_dst++] = &pictures_solid[i]; + } + if (enabled_tests & TEST_FILL) { Bool ok, group_ok = TRUE; @@ -509,29 +539,6 @@ do { \ if (enabled_tests & TEST_BLEND) { Bool ok, group_ok = TRUE; - int *blend_ops = malloc(sizeof(int)*num_ops); - const picture_info **blend_src = malloc(sizeof(picture_info*)*(2*num_tests+num_colors)); - const picture_info **blend_dst = malloc(sizeof(picture_info*)*(num_tests+num_colors)); - int num_blend_ops = 0; - int num_blend_src = 0; - int num_blend_dst = 0; - - for (i = 0; i < num_ops; i++) { - if (ops[i].disabled) - continue; - - blend_ops[num_blend_ops++] = i; - } - - for (i = 0; i < num_tests; i++) { - blend_src[num_blend_src++] = &pictures_1x1[i]; - blend_src[num_blend_src++] = &pictures_10x10[i]; - blend_dst[num_blend_dst++] = &pictures_1x1[i]; - } - for (i = 0; i < num_colors; i++) { - blend_src[num_blend_src++] = &pictures_solid[i]; - blend_dst[num_blend_dst++] = &pictures_solid[i]; - } for (j = 0; j <= num_dests; j++) { picture_info *pi; @@ -544,63 +551,35 @@ do { \ printf("Beginning blend test on %s\n", pi->name); ok = blend_test(dpy, win, pi, - blend_ops, num_blend_ops, - blend_src, num_blend_src, - blend_dst, num_blend_dst); + test_ops, num_test_ops, + test_src, num_test_src, + test_dst, num_test_dst); RECORD_RESULTS(); } if (group_ok) success_mask |= TEST_BLEND; - - free(blend_ops); - free(blend_src); - free(blend_dst); } if (enabled_tests & TEST_COMPOSITE) { Bool ok, group_ok = TRUE; - for (i = 0; i < num_ops; i++) { - if (ops[i].disabled) - continue; + for (j = 0; j <= num_dests; j++) { + picture_info *pi; - for (j = 0; j <= num_dests; j++) { - picture_info *pi; + if (j != num_dests) + pi = &dests[j]; + else + pi = win; - if (j != num_dests) - pi = &dests[j]; - else - pi = win; - printf("Beginning %s composite mask test on %s\n", - ops[i].name, pi->name); + printf("Beginning composite mask test on %s\n", pi->name); - for (src = 0; src < num_tests; src++) { - for (mask = 0; mask < num_tests; mask++) { - for (dst = 0; dst < num_tests; dst++) { - ok = composite_test(dpy, win, pi, i, - &pictures_10x10[src], - &pictures_10x10[mask], - &pictures_1x1[dst], FALSE, TRUE); - RECORD_RESULTS(); - ok = composite_test(dpy, win, pi, i, - &pictures_1x1[src], - &pictures_10x10[mask], - &pictures_1x1[dst], FALSE, TRUE); - RECORD_RESULTS(); - ok = composite_test(dpy, win, pi, i, - &pictures_10x10[src], - &pictures_1x1[mask], - &pictures_1x1[dst], FALSE, TRUE); - RECORD_RESULTS(); - ok = composite_test(dpy, win, pi, i, - &pictures_1x1[src], - &pictures_1x1[mask], - &pictures_1x1[dst], FALSE, TRUE); - RECORD_RESULTS(); - } - } - } - } + ok = composite_test(dpy, win, pi, + test_ops, num_test_ops, + test_src, num_test_src, + test_mask, num_test_mask, + test_dst, num_test_dst, + FALSE, TRUE); + RECORD_RESULTS(); } if (group_ok) success_mask |= TEST_COMPOSITE; @@ -609,47 +588,23 @@ do { \ if (enabled_tests & TEST_CACOMPOSITE) { Bool ok, group_ok = TRUE; - for (i = 0; i < num_ops; i++) { - if (ops[i].disabled) - continue; + for (j = 0; j <= num_dests; j++) { + picture_info *pi; - for (j = 0; j <= num_dests; j++) { - picture_info *pi; + if (j != num_dests) + pi = &dests[j]; + else + pi = win; - if (j != num_dests) - pi = &dests[j]; - else - pi = win; - printf("Beginning %s composite CA mask test on %s\n", - ops[i].name, pi->name); + printf("Beginning composite CA mask test on %s\n", pi->name); - for (src = 0; src < num_tests; src++) { - for (mask = 0; mask < num_tests; mask++) { - for (dst = 0; dst < num_tests; dst++) { - ok = composite_test(dpy, win, pi, i, - &pictures_10x10[src], - &pictures_10x10[mask], - &pictures_1x1[dst], TRUE, TRUE); - RECORD_RESULTS(); - ok = composite_test(dpy, win, pi, i, - &pictures_1x1[src], - &pictures_10x10[mask], - &pictures_1x1[dst], TRUE, TRUE); - RECORD_RESULTS(); - ok = composite_test(dpy, win, pi, i, - &pictures_10x10[src], - &pictures_1x1[mask], - &pictures_1x1[dst], TRUE, TRUE); - RECORD_RESULTS(); - ok = composite_test(dpy, win, pi, i, - &pictures_1x1[src], - &pictures_1x1[mask], - &pictures_1x1[dst], TRUE, TRUE); - RECORD_RESULTS(); - } - } - } - } + ok = composite_test(dpy, win, pi, + test_ops, num_test_ops, + test_src, num_test_src, + test_mask, num_test_mask, + test_dst, num_test_dst, + TRUE, TRUE); + RECORD_RESULTS(); } if (group_ok) success_mask |= TEST_CACOMPOSITE; @@ -772,6 +727,11 @@ do { \ success_mask |= TEST_BUG7366; } + free(test_ops); + free(test_src); + free(test_mask); + free(test_dst); + printf("%d tests passed of %d total\n", tests_passed, tests_total); return tests_passed == tests_total; |