From c285306dfaadb388706529623d171cc9fdde1b78 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 1 Dec 2010 21:36:31 +0000 Subject: blend: Handle more sources than available rows in the window Group the sources into pages if we cannot fit them all onto a single window. Reported-by: Aaron Plattner Signed-off-by: Chris Wilson --- t_blend.c | 170 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 92 insertions(+), 78 deletions(-) diff --git a/t_blend.c b/t_blend.c index 525ea09..3a91400 100644 --- a/t_blend.c +++ b/t_blend.c @@ -34,93 +34,107 @@ blend_test(Display *dpy, picture_info *win, picture_info *dst, color4d expected, tested, tdst; char testname[20]; int i, j, k, y, iter; + int page, num_pages; + + /* If the window is smaller than the number of sources to test, + * we need to break the sources up into pages. + * + * We however assume that the window will always be wider than num_ops. + */ + num_pages = num_src / win_height + 1; k = y = 0; while (k < num_dst) { XImage *image; int k0 = k; - - for (iter = 0; iter < pixmap_move_iter; iter++) { - k = k0; - y = 0; - while (k < num_dst && y + num_src < win_height) { - XRenderComposite(dpy, PictOpSrc, - dst_color[k]->pict, 0, dst->pict, - 0, 0, - 0, 0, - 0, y, - num_op, num_src); - for (j = 0; j < num_src; j++) { - for (i = 0; i < num_op; i++) { - XRenderComposite(dpy, ops[op[i]].op, - src_color[j]->pict, 0, dst->pict, - 0, 0, - 0, 0, - i, y, - 1, 1); - } - y++; + int this_src, rem_src; + + rem_src = num_src; + for (page = 0; page < num_pages; page++) { + this_src = rem_src / (num_pages - page); + for (iter = 0; iter < pixmap_move_iter; iter++) { + k = k0; + y = 0; + while (k < num_dst && y + this_src < win_height) { + XRenderComposite(dpy, PictOpSrc, + dst_color[k]->pict, 0, dst->pict, + 0, 0, + 0, 0, + 0, y, + num_op, this_src); + for (j = 0; j < this_src; j++) { + for (i = 0; i < num_op; i++) { + XRenderComposite(dpy, ops[op[i]].op, + src_color[j]->pict, 0, dst->pict, + 0, 0, + 0, 0, + i, y, + 1, 1); + } + y++; + } + k++; + } } - k++; - } - } - image = XGetImage(dpy, dst->d, - 0, 0, num_ops, y, - 0xffffffff, ZPixmap); - copy_pict_to_win(dpy, dst, win, win_width, win_height); - - y = 0; - while (k0 < k) { - XRenderDirectFormat dst_acc; - - accuracy(&dst_acc, - &dst->format->direct, - &dst_color[k0]->format->direct); - - tdst = dst_color[k0]->color; - color_correct(dst, &tdst); - - for (j = 0; j < num_src; j++) { - XRenderDirectFormat acc; - - accuracy(&acc, &src_color[j]->format->direct, &dst_acc); - - for (i = 0; i < num_op; i++) { - get_pixel_from_image(image, dst, i, y, &tested); - - do_composite(ops[op[i]].op, - &src_color[j]->color, - NULL, - &tdst, - &expected, - FALSE); - color_correct(dst, &expected); - - if (eval_diff(&acc, &expected, &tested) > 3.) { - char srcformat[20]; - - snprintf(testname, 20, "%s blend", ops[op[i]].name); - describe_format(srcformat, 20, src_color[j]->format); - print_fail(testname, &expected, &tested, 0, 0, - eval_diff(&acc, &expected, &tested)); - printf("src color: %.2f %.2f %.2f %.2f (%s)\n" - "dst color: %.2f %.2f %.2f %.2f\n", - src_color[j]->color.r, src_color[j]->color.g, - src_color[j]->color.b, src_color[j]->color.a, - srcformat, - dst_color[k0]->color.r, dst_color[k0]->color.g, - dst_color[k0]->color.b, dst_color[k0]->color.a); - printf("src: %s, dst: %s\n", src_color[j]->name, dst->name); - return FALSE; - } + image = XGetImage(dpy, dst->d, + 0, 0, num_ops, y, + 0xffffffff, ZPixmap); + copy_pict_to_win(dpy, dst, win, win_width, win_height); + + y = 0; + while (k0 < k) { + XRenderDirectFormat dst_acc; + + accuracy(&dst_acc, + &dst->format->direct, + &dst_color[k0]->format->direct); + + tdst = dst_color[k0]->color; + color_correct(dst, &tdst); + + for (j = 0; j < this_src; j++) { + XRenderDirectFormat acc; + + accuracy(&acc, &src_color[j]->format->direct, &dst_acc); + + for (i = 0; i < num_op; i++) { + get_pixel_from_image(image, dst, i, y, &tested); + + do_composite(ops[op[i]].op, + &src_color[j]->color, + NULL, + &tdst, + &expected, + FALSE); + color_correct(dst, &expected); + + if (eval_diff(&acc, &expected, &tested) > 3.) { + char srcformat[20]; + + snprintf(testname, 20, "%s blend", ops[op[i]].name); + describe_format(srcformat, 20, src_color[j]->format); + print_fail(testname, &expected, &tested, 0, 0, + eval_diff(&acc, &expected, &tested)); + printf("src color: %.2f %.2f %.2f %.2f (%s)\n" + "dst color: %.2f %.2f %.2f %.2f\n", + src_color[j]->color.r, src_color[j]->color.g, + src_color[j]->color.b, src_color[j]->color.a, + srcformat, + dst_color[k0]->color.r, dst_color[k0]->color.g, + dst_color[k0]->color.b, dst_color[k0]->color.a); + printf("src: %s, dst: %s\n", src_color[j]->name, dst->name); + return FALSE; + } + } + y++; + } + k0++; } - y++; - } - k0++; - } - XDestroyImage(image); + XDestroyImage(image); + rem_src -= this_src; + } } return TRUE; -- cgit v1.2.3