diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-12-01 10:38:47 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-12-01 18:19:35 +0000 |
commit | dc32549256620a42b6e22a9f3a5ff27a785a827e (patch) | |
tree | 1f2d125b623ef10c082ff02cf3763d01b70abaf0 | |
parent | a040544669ba71d0eebff3492f21a3b40a1c419c (diff) |
blend: Combine multiple tests into a single XGetImage request
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | ops.c | 8 | ||||
-rw-r--r-- | rendercheck.h | 25 | ||||
-rw-r--r-- | t_blend.c | 117 | ||||
-rw-r--r-- | tests.c | 85 |
5 files changed, 160 insertions, 77 deletions
@@ -41,7 +41,7 @@ char **format_whitelist; int pixmap_move_iter = 1; int win_width = 40; -int win_height = 40; +int win_height = 200; int bit_count(int i) @@ -205,8 +205,12 @@ calc_op(int op, double src, double dst, double srca, double dsta) } void -do_composite(int op, color4d *src, color4d *mask, color4d *dst, color4d *result, - Bool componentAlpha) +do_composite(int op, + const color4d *src, + const color4d *mask, + const color4d *dst, + color4d *result, + Bool componentAlpha) { color4d srcval, srcalpha; diff --git a/rendercheck.h b/rendercheck.h index bb35c5e..5b802a2 100644 --- a/rendercheck.h +++ b/rendercheck.h @@ -106,7 +106,16 @@ void color_correct(picture_info *pi, color4d *color); void -get_pixel(Display *dpy, picture_info *pi, int x, int y, color4d *color); +get_pixel(Display *dpy, + const picture_info *pi, + int x, int y, + color4d *color); + +void +get_pixel_from_image(XImage *image, + const picture_info *pi, + int x, int y, + color4d *color); int eval_diff(char *name, color4d *expected, color4d *test, int x, int y, @@ -125,13 +134,19 @@ copy_pict_to_win(Display *dpy, picture_info *pict, picture_info *win, /* ops.c */ void -do_composite(int op, color4d *src, color4d *mask, color4d *dst, color4d *result, - Bool componentAlpha); +do_composite(int op, + const color4d *src, + const color4d *mask, + const color4d *dst, + color4d *result, + Bool componentAlpha); /* The tests */ Bool -blend_test(Display *dpy, picture_info *win, picture_info *dst, int op, - picture_info *src_color, picture_info *dst_color); +blend_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 **dst_color, int num_dst); Bool composite_test(Display *dpy, picture_info *win, picture_info *dst, int op, @@ -24,51 +24,94 @@ #include "rendercheck.h" -#define TEST_WIDTH 10 -#define TEST_HEIGHT 10 - -/* Test a composite of a given operation, source, and destination picture. - * Fills the window, and samples from the 0,0 pixel corner. - */ +/* Test a composite of a given operation, source, and destination picture. */ Bool -blend_test(Display *dpy, picture_info *win, picture_info *dst, int op, - picture_info *src_color, picture_info *dst_color) +blend_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 **dst_color, int num_dst) { color4d expected, tested, tdst; char testname[20]; - int i; + int i, j, k, y, iter; - 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, 0, - 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); + 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++; + } + k++; + } + } + + image = XGetImage(dpy, dst->d, + 0, 0, num_ops, y, + 0xffffffff, ZPixmap); + copy_pict_to_win(dpy, dst, win, win_width, win_height); - tdst = dst_color->color; - color_correct(dst, &tdst); - do_composite(ops[op].op, &src_color->color, NULL, &tdst, &expected, - FALSE); - color_correct(dst, &expected); + y = 0; + while (k0 < k) { + tdst = dst_color[k0]->color; + color_correct(dst, &tdst); - snprintf(testname, 20, "%s blend", ops[op].name); - if (!eval_diff(testname, &expected, &tested, 0, 0, is_verbose)) { - char srcformat[20]; + for (j = 0; j < num_src; j++) { + for (i = 0; i < num_op; i++) { + get_pixel_from_image(image, dst, i, y, &tested); - describe_format(srcformat, 20, src_color->format); - printf("src color: %.2f %.2f %.2f %.2f (%s)\n" - "dst color: %.2f %.2f %.2f %.2f\n", - src_color->color.r, src_color->color.g, - src_color->color.b, src_color->color.a, - srcformat, - dst_color->color.r, dst_color->color.g, - dst_color->color.b, dst_color->color.a); - printf("src: %s, dst: %s\n", src_color->name, dst->name); - return FALSE; - } else if (is_verbose) { - printf("src: %s, dst: %s\n", src_color->name, dst->name); + do_composite(ops[op[i]].op, + &src_color[j]->color, + NULL, + &tdst, + &expected, + FALSE); + color_correct(dst, &expected); + + snprintf(testname, 20, "%s blend", ops[op[i]].name); + if (!eval_diff(testname, &expected, &tested, 0, 0, is_verbose)) { + char srcformat[20]; + + describe_format(srcformat, 20, src_color[j]->format); + 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; + } else if (is_verbose) { + printf("src: %s, dst: %s\n", src_color[j]->name, dst->name); + } + } + y++; + } + k0++; + } + + XDestroyImage(image); } + return TRUE; } @@ -113,16 +113,16 @@ color_correct(picture_info *pi, color4d *color) } void -get_pixel(Display *dpy, picture_info *pi, int x, int y, color4d *color) +get_pixel_from_image(XImage *image, + const picture_info *pi, + int x, int y, + color4d *color) { - XImage *image; unsigned long val; unsigned long rm, gm, bm, am; XRenderDirectFormat *layout = &pi->format->direct; - image = XGetImage(dpy, pi->d, x, y, 1, 1, 0xffffffff, ZPixmap); - - val = XGetPixel(image, 0, 0); + val = XGetPixel(image, x, y); rm = (unsigned long)layout->redMask << layout->red; gm = (unsigned long)layout->greenMask << layout->green; @@ -141,6 +141,18 @@ get_pixel(Display *dpy, picture_info *pi, int x, int y, color4d *color) color->g = 0.0; color->b = 0.0; } +} + +void +get_pixel(Display *dpy, + const picture_info *pi, + int x, int y, + color4d *color) +{ + XImage *image; + + image = XGetImage(dpy, pi->d, x, y, 1, 1, 0xffffffff, ZPixmap); + get_pixel_from_image(image, pi, 0, 0, color); XDestroyImage(image); } @@ -497,43 +509,52 @@ 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; - for (j = 0; j <= num_dests; j++) { - picture_info *pi; + blend_ops[num_blend_ops++] = i; + } - if (j != num_dests) - pi = &dests[j]; - else - pi = win; - printf("Beginning %s blend test on %s\n", ops[i].name, - pi->name); + 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 (src = 0; src < num_tests; src++) { - for (dst = 0; dst < num_tests; dst++) { - ok = blend_test(dpy, win, pi, i, - &pictures_1x1[src], - &pictures_1x1[dst]); - RECORD_RESULTS(); - ok = blend_test(dpy, win, pi, i, - &pictures_10x10[src], - &pictures_1x1[dst]); - RECORD_RESULTS(); - } - } - for (src = 0; src < num_colors; src++) { - for (dst = 0; dst < num_colors; dst++) { - ok = blend_test(dpy, win, pi, i, &pictures_solid[src], &pictures_1x1[dst]); - RECORD_RESULTS(); - } - } - } + for (j = 0; j <= num_dests; j++) { + picture_info *pi; + + if (j != num_dests) + pi = &dests[j]; + else + pi = win; + + 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); + RECORD_RESULTS(); } if (group_ok) success_mask |= TEST_BLEND; + + free(blend_ops); + free(blend_src); + free(blend_dst); } if (enabled_tests & TEST_COMPOSITE) { |