diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-12-01 13:56:07 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-12-01 18:19:35 +0000 |
commit | 903b5030826ab6915d354aa95a4e36c3dd684989 (patch) | |
tree | f042fa5b3bf67bd20c60a38fbc3e419b4a62e82e /t_composite.c | |
parent | 55612909182c253bbfe8278a8867c93c9b09bc01 (diff) |
Split out printing the results from eval_diff()
Separate the evalation of two colors given a format and the printing of
the result. This allows eval_diff() to be used elsewhere and also means
that we do not need to waste cycles generating unused strings for
eval_diff() [this accounts for as much time as composite_op!]. As part
of this process pass in the expected accuracy of the operation to
eval_diff().
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 't_composite.c')
-rw-r--r-- | t_composite.c | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/t_composite.c b/t_composite.c index 315650b..d305d1e 100644 --- a/t_composite.c +++ b/t_composite.c @@ -33,7 +33,7 @@ composite_test(Display *dpy, picture_info *win, picture_info *dst, 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 componentAlpha) { color4d expected, tested, tdst, tmsk; char testname[40]; @@ -44,6 +44,7 @@ composite_test(Display *dpy, picture_info *win, picture_info *dst, color_correct(dst, &tdst); for (m = 0; m < num_mask; m++) { + XRenderDirectFormat mask_acc; XImage *image; if (componentAlpha) { @@ -100,7 +101,16 @@ composite_test(Display *dpy, picture_info *win, picture_info *dst, } else tmsk = mask_color[m]->color; + accuracy(&mask_acc, + &mask_color[m]->format->direct, + &dst_color[d]->format->direct); + accuracy(&mask_acc, &mask_acc, &dst->format->direct); + for (s = 0; s < num_src; s++) { + XRenderDirectFormat acc; + + accuracy(&acc, &mask_acc, &src_color[s]->format->direct); + for (i = 0; i < num_op; i++) { get_pixel_from_image(image, dst, i, s, &tested); @@ -109,38 +119,33 @@ composite_test(Display *dpy, picture_info *win, picture_info *dst, &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); + if (eval_diff(&acc, &expected, &tested) > 3.) { + snprintf(testname, 40, + "%s %scomposite", ops[op[i]].name, + componentAlpha ? "CA " : ""); + print_fail(testname, &expected, &tested, 0, 0, + eval_diff(&acc, &expected, &tested)); + 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); } } } |