rendercheck: 10 commits - doc/TODO main.c ops.c rendercheck.h t_blend.c t_composite.c t_dstcoords.c tests.c t_fill.c t_gradient.c t_repeat.c t_srccoords.c t_triangles.c t_tsrccoords2.c t_tsrccoords.c
Chris Wilson
ickle at kemper.freedesktop.org
Wed Dec 1 10:27:36 PST 2010
doc/TODO | 3
main.c | 2
ops.c | 8 +
rendercheck.h | 57 ++++++++--
t_blend.c | 133 +++++++++++++++++--------
t_composite.c | 187 ++++++++++++++++++++++-------------
t_dstcoords.c | 16 ++-
t_fill.c | 13 +-
t_gradient.c | 7 -
t_repeat.c | 69 +++++++++----
t_srccoords.c | 14 +-
t_triangles.c | 46 ++++++--
t_tsrccoords.c | 51 +++++----
t_tsrccoords2.c | 19 ++-
tests.c | 293 ++++++++++++++++++++++++++++----------------------------
15 files changed, 569 insertions(+), 349 deletions(-)
New commits:
commit a038220d4aeb3111d34b45d852b97be85a56459d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 17:52:01 2010 +0000
TODO: Multiple roundtrips for image processing due to get_pixel fixed
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/doc/TODO b/doc/TODO
index de1787c..34f2e44 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -3,4 +3,3 @@
- Check coordinates for more different transformations
- Check source/mask pixels falling outside the drawable.
- Check trapezoids!
-- get_pixel equivalent that doesn't involve round-trips per call.
commit bf0067692cf961fea6ebbda601f83c1c1960aff4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 17:50:07 2010 +0000
dstcoords: Sample result using a single GetImage
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/t_dstcoords.c b/t_dstcoords.c
index ed91ecc..8944dec 100644
--- a/t_dstcoords.c
+++ b/t_dstcoords.c
@@ -38,6 +38,7 @@ dstcoords_test(Display *dpy, picture_info *win, int op, picture_info *dst,
picture_info *bg, picture_info *fg)
{
color4d expected, tested;
+ XImage *image;
int x, y, i;
Bool failed = FALSE;
@@ -50,9 +51,13 @@ dstcoords_test(Display *dpy, picture_info *win, int op, picture_info *dst,
copy_pict_to_win(dpy, dst, win, TEST_WIDTH, TEST_HEIGHT);
+ image = XGetImage(dpy, dst->d,
+ 0, 0, 5, 5,
+ ~0U, ZPixmap);
+
for (x = 0; x < 5; x++) {
for (y = 0; y < 5; y++) {
- get_pixel(dpy, dst, x, y, &tested);
+ get_pixel_from_image(image, dst, x, y, &tested);
if ((x >= 1 && x <= 3) && (y >= 1 && y <= 3))
expected = fg->color;
else
@@ -68,5 +73,7 @@ dstcoords_test(Display *dpy, picture_info *win, int op, picture_info *dst,
}
}
+ XDestroyImage(image);
+
return !failed;
}
commit e70fb7146dc18adcd38dd58adfb861a2a432ce64
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 17:46:39 2010 +0000
tsrcoords2: Sample result using a single GetImage
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/t_tsrccoords2.c b/t_tsrccoords2.c
index 89e92b1..4449dca 100644
--- a/t_tsrccoords2.c
+++ b/t_tsrccoords2.c
@@ -81,6 +81,7 @@ trans_srccoords_test_2(Display *dpy, picture_info *win, picture_info *white,
int tested_colors[5][5];
picture_info *src;
XTransform t;
+ XImage *image;
src = create_target_picture(dpy);
if (src == NULL) {
@@ -120,10 +121,14 @@ trans_srccoords_test_2(Display *dpy, picture_info *win, picture_info *white,
&pa);
}
+ image = XGetImage(dpy, win->d,
+ 0, 0, 5, 5,
+ 0xffffffff, ZPixmap);
+
for (i = 0; i < 25; i++) {
int x = i % 5, y = i / 5, srcx, srcy;
- get_pixel(dpy, win, x, y, &tested);
+ get_pixel_from_image(image, win, x, y, &tested);
/* Map from our destination coordinates to where they are
* in the source picture. Rotate right.
@@ -166,6 +171,7 @@ trans_srccoords_test_2(Display *dpy, picture_info *win, picture_info *white,
}
}
+ XDestroyImage(image);
destroy_target_picture(dpy, src);
return !failed;
commit 168830dca2e75e67d448039f3f42a0bad6719147
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 17:44:41 2010 +0000
tsrcoords: Sample result with just a single GetImage
... and whilst we are here make processing the 2D arrays cache friendly.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/t_tsrccoords.c b/t_tsrccoords.c
index 63cee4b..124fdc9 100644
--- a/t_tsrccoords.c
+++ b/t_tsrccoords.c
@@ -25,6 +25,9 @@
#include "rendercheck.h"
+#define TEST_WIDTH 40
+#define TEST_HEIGHT 40
+
static int dot_colors[5][5] = {
{7, 7, 7, 7, 7},
{7, 7, 7, 7, 7},
@@ -48,7 +51,7 @@ static picture_info *create_dot_picture(Display *dpy)
for (i = 0; i < 25; i++) {
int x = i % 5;
int y = i / 5;
- color4d *c = &colors[dot_colors[x][y]];
+ color4d *c = &colors[dot_colors[y][x]];
argb_fill(dpy, p, x, y, 1, 1, c->a, c->r, c->g, c->b);
}
@@ -79,11 +82,12 @@ trans_coords_test(Display *dpy, picture_info *win, picture_info *white,
Bool test_mask)
{
color4d tested;
- int x, y;
Bool failed = FALSE;
- int tested_colors[40][40], expected_colors[40][40];
+ int tested_colors[TEST_HEIGHT][TEST_WIDTH], expected_colors[TEST_HEIGHT][TEST_WIDTH];
XTransform t;
picture_info *src;
+ XImage *image;
+ int x, y;
src = create_dot_picture(dpy);
if (src == NULL) {
@@ -98,31 +102,35 @@ trans_coords_test(Display *dpy, picture_info *win, picture_info *white,
if (!test_mask)
XRenderComposite(dpy, PictOpSrc, src->pict, 0,
- win->pict, 0, 0, 0, 0, 0, 0, 40, 40);
+ win->pict, 0, 0, 0, 0, 0, 0, TEST_WIDTH, TEST_HEIGHT);
else {
XRenderComposite(dpy, PictOpSrc, white->pict, src->pict,
- win->pict, 0, 0, 0, 0, 0, 0, 40, 40);
+ win->pict, 0, 0, 0, 0, 0, 0, TEST_WIDTH, TEST_HEIGHT);
}
- for (x = 0; x < 40; x++) {
- for (y = 0; y < 40; y++) {
+ image = XGetImage(dpy, win->d,
+ 0, 0, TEST_WIDTH, TEST_HEIGHT,
+ 0xffffffff, ZPixmap);
+
+ for (y = 0; y < TEST_HEIGHT; y++) {
+ for (x = 0; x < TEST_WIDTH; x++) {
int src_sample_x, src_sample_y;
src_sample_x = x / 8;
src_sample_y = y / 8;
- expected_colors[x][y] = dot_colors[src_sample_x][src_sample_y];
+ expected_colors[y][x] = dot_colors[src_sample_y][src_sample_x];
- get_pixel(dpy, win, x, y, &tested);
+ get_pixel_from_image(image, win, x, y, &tested);
if (tested.r == 1.0 && tested.g == 1.0 && tested.b == 1.0) {
- tested_colors[x][y] = 0;
+ tested_colors[y][x] = 0;
} else if (tested.r == 0.0 && tested.g == 0.0 &&
tested.b == 0.0) {
- tested_colors[x][y] = 7;
+ tested_colors[y][x] = 7;
} else {
- tested_colors[x][y] = 9;
+ tested_colors[y][x] = 9;
}
- if (tested_colors[x][y] != expected_colors[x][y])
+ if (tested_colors[y][x] != expected_colors[y][x])
failed = TRUE;
}
}
@@ -131,21 +139,22 @@ trans_coords_test(Display *dpy, picture_info *win, picture_info *white,
printf("%s transform coordinates test failed.\n",
test_mask ? "mask" : "src");
printf("expected vs tested:\n");
- for (y = 0; y < 40; y++) {
- for (x = 0; x < 40; x++)
- printf("%d", expected_colors[x][y]);
+ for (y = 0; y < TEST_HEIGHT; y++) {
+ for (x = 0; x < TEST_WIDTH; x++)
+ printf("%d", expected_colors[y][x]);
printf(" ");
- for (x = 0; x < 40; x++)
- printf("%d", tested_colors[x][y]);
+ for (x = 0; x < TEST_WIDTH; x++)
+ printf("%d", tested_colors[y][x]);
printf("\n");
}
printf(" vs tested (same)\n");
- for (y = 0; y < 40; y++) {
- for (x = 0; x < 40; x++)
- printf("%d", tested_colors[x][y]);
+ for (y = 0; y < TEST_HEIGHT; y++) {
+ for (x = 0; x < TEST_WIDTH; x++)
+ printf("%d", tested_colors[y][x]);
printf("\n");
}
}
+ XDestroyImage(image);
init_transform(&t);
commit 6fe8d675216524a68894a28a1c335f0ad29239db
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 17:35:41 2010 +0000
triangles: Use a single GetImage call to sample the result
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/t_triangles.c b/t_triangles.c
index 645f507..207b7b0 100644
--- a/t_triangles.c
+++ b/t_triangles.c
@@ -44,6 +44,7 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
color4d tdst, tsrc;
int x, y;
Bool success = TRUE;
+ XImage *image;
triangles[0].p1.x = XDoubleToFixed(2);
triangles[0].p1.y = XDoubleToFixed(2);
@@ -76,6 +77,10 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tsrc, FALSE);
color_correct(dst, &tsrc);
+ image = XGetImage(dpy, dst->d,
+ 0, 0, 5, 5,
+ 0xffffffff, ZPixmap);
+
for (x = 0; x < 5; x++) {
for (y = 0; y < 5; y++) {
color4d expected, tested;
@@ -86,7 +91,7 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
expected = tdst;
}
- get_pixel(dpy, dst, x, y, &tested);
+ get_pixel_from_image(image, dst, x, y, &tested);
if (eval_diff(&dst->format->direct, &expected, &tested) > 2.) {
print_fail("triangles", &expected, &tested, x, y,
@@ -103,6 +108,7 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
dst_color->color.r, dst_color->color.g,
dst_color->color.b, dst_color->color.a);
}
+ XDestroyImage(image);
return success;
}
@@ -115,6 +121,7 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
color4d tdst, tsrc;
int x, y;
Bool success = TRUE;
+ XImage *image;
points[0].x = XDoubleToFixed(2);
points[0].y = XDoubleToFixed(2);
@@ -142,6 +149,10 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tsrc, FALSE);
color_correct(dst, &tsrc);
+ image = XGetImage(dpy, dst->d,
+ 0, 0, 5, 5,
+ 0xffffffff, ZPixmap);
+
for (x = 0; x < 5; x++) {
for (y = 0; y < 5; y++) {
color4d expected, tested;
@@ -152,7 +163,7 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
expected = tdst;
}
- get_pixel(dpy, dst, x, y, &tested);
+ get_pixel_from_image(image, dst, x, y, &tested);
if (eval_diff(&dst->format->direct, &expected, &tested) > 2.) {
print_fail("triangles", &expected, &tested, x,y,
@@ -169,6 +180,7 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
dst_color->color.r, dst_color->color.g,
dst_color->color.b, dst_color->color.a);
}
+ XDestroyImage(image);
return success;
}
@@ -181,6 +193,7 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
color4d tdst, tsrc;
int x, y;
Bool success = TRUE;
+ XImage *image;
points[0].x = XDoubleToFixed(2);
points[0].y = XDoubleToFixed(2);
@@ -208,6 +221,10 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tsrc, FALSE);
color_correct(dst, &tsrc);
+ image = XGetImage(dpy, dst->d,
+ 0, 0, 5, 5,
+ 0xffffffff, ZPixmap);
+
for (x = 0; x < 5; x++) {
for (y = 0; y < 5; y++) {
color4d expected, tested;
@@ -218,7 +235,7 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
expected = tdst;
}
- get_pixel(dpy, dst, x, y, &tested);
+ get_pixel_from_image(image, dst, x, y, &tested);
if (eval_diff(&dst->format->direct, &expected, &tested) > 2.) {
print_fail("triangles", &expected, &tested, x, y,
@@ -235,6 +252,7 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
dst_color->color.r, dst_color->color.g,
dst_color->color.b, dst_color->color.a);
}
+ XDestroyImage(image);
return success;
}
commit ad4da4e62ace7f5bfa0cfb2b82240b9498ce1005
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 14:52:13 2010 +0000
repeat: Only call GetImage once for each test.
Sample the entire result with a single call to GetImage in order to
batch up the transfers when checking the result.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/t_repeat.c b/t_repeat.c
index bd5cd38..4e26136 100644
--- a/t_repeat.c
+++ b/t_repeat.c
@@ -50,7 +50,6 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
picture_info *dst_color, picture_info *c1, picture_info *c2, Bool test_mask)
{
int wi, hi;
- Bool failed = FALSE;
for (wi = 0; wi < sizeof(sizes) / sizeof(int); wi++) {
int w = sizes[wi];
@@ -64,6 +63,8 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
color4d tdst, c1expected, c2expected;
XRenderPictureAttributes pa;
XRenderDirectFormat acc;
+ XImage *image;
+ Bool failed = FALSE;
pa.component_alpha = test_mask;
pa.repeat = TRUE;
@@ -129,8 +130,12 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
color_correct(dst, &c1expected);
color_correct(dst, &c2expected);
- for (x = 0; x < TEST_WIDTH; x++) {
- for (y = 0; y < TEST_HEIGHT; y++) {
+ image = XGetImage(dpy, dst->d,
+ 0, 0, TEST_WIDTH, TEST_HEIGHT,
+ ~0U, ZPixmap);
+
+ for (y = 0; y < TEST_HEIGHT; y++) {
+ for (x = 0; x < TEST_WIDTH; x++) {
int samplex = x % w;
int sampley = y % h;
color4d *expected, tested;
@@ -140,7 +145,7 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
} else {
expected = &c1expected;
}
- get_pixel(dpy, dst, x, y, &tested);
+ get_pixel_from_image(image, dst, x, y, &tested);
if (eval_diff(&acc, expected, &tested) > 3.) {
snprintf(name, 40, "%dx%d %s %s-repeat", w, h,
@@ -148,13 +153,20 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
print_fail(name, expected, &tested, x, y,
eval_diff(&acc, expected, &tested));
- failed = TRUE;
+
+ failed = TRUE;
+ goto out;
}
}
}
+out:
+ XDestroyImage(image);
XRenderFreePicture(dpy, src.pict);
XFreePixmap(dpy, src.d);
+
+ if (failed)
+ return FALSE;
}
}
- return !failed;
+ return TRUE;
}
commit 903b5030826ab6915d354aa95a4e36c3dd684989
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 13:56:07 2010 +0000
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 at chris-wilson.co.uk>
diff --git a/doc/TODO b/doc/TODO
index ee20732..de1787c 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,8 +1,6 @@
- Check bilinear filtering
- Check repeating transformed sources
- Check coordinates for more different transformations
-- Get a useful number being produced for error values, and correct eval_diff's
- limit.
- Check source/mask pixels falling outside the drawable.
- Check trapezoids!
- get_pixel equivalent that doesn't involve round-trips per call.
diff --git a/rendercheck.h b/rendercheck.h
index 3e9966d..34d06c5 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -117,9 +117,26 @@ get_pixel_from_image(XImage *image,
int x, int y,
color4d *color);
-int
-eval_diff(char *name, color4d *expected, color4d *test, int x, int y,
- Bool verbose);
+void
+accuracy(XRenderDirectFormat *result,
+ const XRenderDirectFormat *a,
+ const XRenderDirectFormat *b);
+
+double
+eval_diff(const XRenderDirectFormat *accuracy,
+ const color4d *expected,
+ const color4d *test);
+
+void print_fail(const char *name,
+ const color4d *expected,
+ const color4d *test,
+ int x, int y,
+ double d);
+
+void print_pass(const char *name,
+ const color4d *expected,
+ int x, int y,
+ double d);
void
argb_fill(Display *dpy, picture_info *p, int x, int y, int w, int h, float a,
@@ -154,7 +171,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);
Bool
dstcoords_test(Display *dpy, picture_info *win, int op, picture_info *dst,
diff --git a/t_blend.c b/t_blend.c
index 7847d07..525ea09 100644
--- a/t_blend.c
+++ b/t_blend.c
@@ -72,10 +72,20 @@ blend_test(Display *dpy, picture_info *win, picture_info *dst,
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);
@@ -87,11 +97,13 @@ blend_test(Display *dpy, picture_info *win, picture_info *dst,
FALSE);
color_correct(dst, &expected);
- snprintf(testname, 20, "%s blend", ops[op[i]].name);
- if (!eval_diff(testname, &expected, &tested, 0, 0, is_verbose)) {
+ 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,
@@ -101,8 +113,6 @@ blend_test(Display *dpy, picture_info *win, picture_info *dst,
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++;
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);
}
}
}
diff --git a/t_dstcoords.c b/t_dstcoords.c
index f6adab7..ed91ecc 100644
--- a/t_dstcoords.c
+++ b/t_dstcoords.c
@@ -59,9 +59,12 @@ dstcoords_test(Display *dpy, picture_info *win, int op, picture_info *dst,
expected = bg->color;
color_correct(dst, &expected);
- if (!eval_diff("dst coords", &expected, &tested, x, y,
- is_verbose))
+ if (eval_diff(&dst->format->direct, &expected, &tested) > 2.0) {
+ print_fail("dst coords",
+ &expected, &tested, x, y,
+ eval_diff(&dst->format->direct, &expected, &tested));
failed = TRUE;
+ }
}
}
diff --git a/t_fill.c b/t_fill.c
index f367cb8..4dd80a6 100644
--- a/t_fill.c
+++ b/t_fill.c
@@ -35,10 +35,15 @@ fill_test(Display *dpy, picture_info *win, picture_info *src)
char name[20];
get_pixel(dpy, src, 0, 0, &tested);
-
copy_pict_to_win(dpy, src, win, win_width, win_height);
- strcpy(name, "fill ");
- describe_format(name, 20 - strlen(name), src->format);
- return eval_diff(name, &src->color, &tested, 0, 0, is_verbose);
+ if (eval_diff(&src->format->direct, &src->color, &tested) > 2.) {
+ strcpy(name, "fill ");
+ describe_format(name, 20 - strlen(name), src->format);
+ print_fail(name, &src->color, &tested, 0, 0,
+ eval_diff(&src->format->direct, &src->color, &tested));
+ return FALSE;
+ }
+
+ return TRUE;
}
diff --git a/t_gradient.c b/t_gradient.c
index 379c163..4f84403 100644
--- a/t_gradient.c
+++ b/t_gradient.c
@@ -305,8 +305,11 @@ Bool linear_gradient_test(Display *dpy, picture_info *win,
&expected, False);
color_correct(dst, &expected);
- snprintf(testname, 40, "%s linear gradient", ops[op].name);
- if (!eval_diff(testname, &expected, &tested, 0, 0, is_verbose)) {
+ if (eval_diff(&dst->format->direct, &expected, &tested) > 3.) {
+ snprintf(testname, 40,
+ "%s linear gradient", ops[op].name);
+ print_fail(testname, &expected, &tested, 0, 0,
+ eval_diff(&dst->format->direct, &expected, &tested));
printf("gradient: %d stops: %d repeat: %d pos: %d/%d\n"
"src color: %.2f %.2f %.2f %.2f\n"
"dst color: %.2f %.2f %.2f %.2f\n",
diff --git a/t_repeat.c b/t_repeat.c
index 92b95ea..bd5cd38 100644
--- a/t_repeat.c
+++ b/t_repeat.c
@@ -63,6 +63,7 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
char name[40];
color4d tdst, c1expected, c2expected;
XRenderPictureAttributes pa;
+ XRenderDirectFormat acc;
pa.component_alpha = test_mask;
pa.repeat = TRUE;
@@ -108,6 +109,12 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
tdst = dst_color->color;
color_correct(dst, &tdst);
+ accuracy(&acc,
+ &dst->format->direct,
+ &dst_color->format->direct);
+ accuracy(&acc, &acc, &c1->format->direct);
+ accuracy(&acc, &acc, &c2->format->direct);
+
if (!test_mask) {
do_composite(ops[op].op, &c1->color, NULL, &tdst,
&c1expected, FALSE);
@@ -122,8 +129,6 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
color_correct(dst, &c1expected);
color_correct(dst, &c2expected);
- snprintf(name, 40, "%dx%d %s %s-repeat", w, h,
- ops[op].name, test_mask ? "mask" : "src");
for (x = 0; x < TEST_WIDTH; x++) {
for (y = 0; y < TEST_HEIGHT; y++) {
int samplex = x % w;
@@ -137,9 +142,14 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
}
get_pixel(dpy, dst, x, y, &tested);
- if (!eval_diff(name, expected, &tested, x, y,
- is_verbose))
+ if (eval_diff(&acc, expected, &tested) > 3.) {
+ snprintf(name, 40, "%dx%d %s %s-repeat", w, h,
+ ops[op].name, test_mask ? "mask" : "src");
+
+ print_fail(name, expected, &tested, x, y,
+ eval_diff(&acc, expected, &tested));
failed = TRUE;
+ }
}
}
XRenderFreePicture(dpy, src.pict);
diff --git a/t_srccoords.c b/t_srccoords.c
index c29a960..6aff6d5 100644
--- a/t_srccoords.c
+++ b/t_srccoords.c
@@ -90,7 +90,6 @@ srccoords_test(Display *dpy, picture_info *win, picture_info *white,
}
for (i = 0; i < 25; i++) {
- char name[20];
int x = i % 5, y = i / 5;
if (!test_mask)
@@ -123,13 +122,12 @@ srccoords_test(Display *dpy, picture_info *win, picture_info *white,
} else
tested_colors[x][y] = 9;
- if (test_mask)
- snprintf(name, 20, "mask coords");
- else
- snprintf(name, 20, "src coords");
- if (!eval_diff(name, &expected, &tested, x, y,
- is_verbose))
- failed = TRUE;
+ if (eval_diff(&win->format->direct, &expected, &tested) > 2.) {
+ print_fail(test_mask ? "mask coords" : "src coords",
+ &expected, &tested, x, y,
+ eval_diff(&win->format->direct, &expected, &tested));
+ failed = TRUE;
+ }
}
if (failed) {
int j;
diff --git a/t_triangles.c b/t_triangles.c
index 230c2ff..645f507 100644
--- a/t_triangles.c
+++ b/t_triangles.c
@@ -88,10 +88,10 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
get_pixel(dpy, dst, x, y, &tested);
- if (!eval_diff("triangles", &expected, &tested, x, y,
- is_verbose))
- {
- success = FALSE;
+ if (eval_diff(&dst->format->direct, &expected, &tested) > 2.) {
+ print_fail("triangles", &expected, &tested, x, y,
+ eval_diff(&dst->format->direct, &expected, &tested));
+ success = FALSE;
}
}
}
@@ -154,9 +154,9 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
get_pixel(dpy, dst, x, y, &tested);
- if (!eval_diff("triangles", &expected, &tested, x, y,
- is_verbose))
- {
+ if (eval_diff(&dst->format->direct, &expected, &tested) > 2.) {
+ print_fail("triangles", &expected, &tested, x,y,
+ eval_diff(&dst->format->direct, &expected, &tested));
success = FALSE;
}
}
@@ -220,10 +220,10 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
get_pixel(dpy, dst, x, y, &tested);
- if (!eval_diff("triangles", &expected, &tested, x, y,
- is_verbose))
- {
- success = FALSE;
+ if (eval_diff(&dst->format->direct, &expected, &tested) > 2.) {
+ print_fail("triangles", &expected, &tested, x, y,
+ eval_diff(&dst->format->direct, &expected, &tested));
+ success = FALSE;
}
}
}
diff --git a/t_tsrccoords2.c b/t_tsrccoords2.c
index 1bb3974..89e92b1 100644
--- a/t_tsrccoords2.c
+++ b/t_tsrccoords2.c
@@ -121,7 +121,6 @@ trans_srccoords_test_2(Display *dpy, picture_info *win, picture_info *white,
}
for (i = 0; i < 25; i++) {
- char name[20];
int x = i % 5, y = i / 5, srcx, srcy;
get_pixel(dpy, win, x, y, &tested);
@@ -142,12 +141,12 @@ trans_srccoords_test_2(Display *dpy, picture_info *win, picture_info *white,
} else
tested_colors[y][x] = 9;
- if (test_mask)
- snprintf(name, 20, "mask coords");
- else
- snprintf(name, 20, "src coords");
- if (!eval_diff(name, &expected, &tested, x, y, is_verbose))
+ if (eval_diff(&win->format->direct, &expected, &tested) > 2.) {
+ print_fail(test_mask ? "mask coords" : "src coords",
+ &expected, &tested, x, y,
+ eval_diff(&win->format->direct, &expected, &tested));
failed = TRUE;
+ }
}
if (failed) {
int x, y;
diff --git a/tests.c b/tests.c
index 66a1115..f722bc6 100644
--- a/tests.c
+++ b/tests.c
@@ -156,43 +156,63 @@ get_pixel(Display *dpy,
XDestroyImage(image);
}
-int
-eval_diff(char *name, color4d *expected, color4d *test, int x, int y,
- Bool verbose)
+void
+accuracy(XRenderDirectFormat *result,
+ const XRenderDirectFormat *a,
+ const XRenderDirectFormat *b)
{
- double rscale, gscale, bscale, ascale;
- double rdiff, gdiff, bdiff, adiff, diff;
+ result->redMask = min(a->redMask, b->redMask);
+ result->greenMask = min(a->greenMask, b->greenMask);
+ result->blueMask = min(a->blueMask, b->blueMask);
+ result->alphaMask = min(a->alphaMask, b->alphaMask);
+}
- /* XXX: Need to be provided mask shifts so we can produce useful error
- * values.
- */
- rscale = 1.0 * (1 << 5);
- gscale = 1.0 * (1 << 6);
- bscale = 1.0 * (1 << 5);
- ascale = 1.0 * 32;
- rdiff = fabs(test->r - expected->r) * rscale;
- bdiff = fabs(test->g - expected->g) * gscale;
- gdiff = fabs(test->b - expected->b) * bscale;
- adiff = fabs(test->a - expected->a) * ascale;
- /*rdiff = log2(1.0 + rdiff);
+double
+eval_diff(const XRenderDirectFormat *format,
+ const color4d *expected,
+ const color4d *test)
+{
+ double rdiff, gdiff, bdiff, adiff;
+
+ rdiff = fabs(test->r - expected->r) * format->redMask;
+ bdiff = fabs(test->g - expected->g) * format->greenMask;
+ gdiff = fabs(test->b - expected->b) * format->blueMask;
+ adiff = fabs(test->a - expected->a) * format->alphaMask;
+
+#if 0
+ rdiff = log2(1.0 + rdiff);
gdiff = log2(1.0 + gdiff);
bdiff = log2(1.0 + bdiff);
- adiff = log2(1.0 + adiff);*/
- diff = max(max(max(rdiff, gdiff), bdiff), adiff);
- if (diff > 3.0) {
- printf("%s test error of %.4f at (%d, %d) --\n"
- " R G B A\n"
- "got: %.2f %.2f %.2f %.2f\n"
- "expected: %.2f %.2f %.2f %.2f\n", name, diff, x, y,
- test->r, test->g, test->b, test->a,
- expected->r, expected->g, expected->b, expected->a);
- return FALSE;
- } else if (verbose) {
- printf("%s test succeeded at (%d, %d) with %.4f: "
- "%.2f %.2f %.2f %.2f\n", name, x, y, diff,
- expected->r, expected->g, expected->b, expected->a);
- }
- return TRUE;
+ adiff = log2(1.0 + adiff);
+#endif
+
+ return max(max(max(rdiff, gdiff), bdiff), adiff);
+}
+
+void print_fail(const char *name,
+ const color4d *expected,
+ const color4d *test,
+ int x, int y,
+ double d)
+{
+ printf("%s test error of %.4f at (%d, %d) --\n"
+ " R G B A\n"
+ "got: %.3f %.3f %.3f %.3f\n"
+ "expected: %.3f %.3f %.3f %.3f\n",
+ name, d, x, y,
+ test->r, test->g, test->b, test->a,
+ expected->r, expected->g, expected->b, expected->a);
+}
+
+void print_pass(const char *name,
+ const color4d *expected,
+ int x, int y,
+ double d)
+{
+ printf("%s test succeeded at (%d, %d) with %.4f: "
+ "%.2f %.2f %.2f %.2f\n",
+ name, x, y, d,
+ expected->r, expected->g, expected->b, expected->a);
}
void
@@ -578,7 +598,7 @@ do { \
test_src, num_test_src,
test_mask, num_test_mask,
test_dst, num_test_dst,
- FALSE, TRUE);
+ FALSE);
RECORD_RESULTS();
}
if (group_ok)
@@ -603,7 +623,7 @@ do { \
test_src, num_test_src,
test_mask, num_test_mask,
test_dst, num_test_dst,
- TRUE, TRUE);
+ TRUE);
RECORD_RESULTS();
}
if (group_ok)
commit 55612909182c253bbfe8278a8867c93c9b09bc01
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 11:58:04 2010 +0000
composite: Batch tests
Process an entire num_mask x num_op in a single GetImage pass.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
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;
}
diff --git a/tests.c b/tests.c
index 0465e6d..66a1115 100644
--- a/tests.c
+++ b/tests.c
@@ -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;
commit dc32549256620a42b6e22a9f3a5ff27a785a827e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 10:38:47 2010 +0000
blend: Combine multiple tests into a single XGetImage request
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/main.c b/main.c
index 99d8441..9a97d72 100644
--- a/main.c
+++ b/main.c
@@ -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)
diff --git a/ops.c b/ops.c
index ebcc770..0e03550 100644
--- a/ops.c
+++ b/ops.c
@@ -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,
diff --git a/t_blend.c b/t_blend.c
index 94cce20..7847d07 100644
--- a/t_blend.c
+++ b/t_blend.c
@@ -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;
}
diff --git a/tests.c b/tests.c
index 47a10dc..0465e6d 100644
--- a/tests.c
+++ b/tests.c
@@ -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) {
commit a040544669ba71d0eebff3492f21a3b40a1c419c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Dec 1 15:07:25 2010 +0000
repeat: Specify test width/height rather than relying on win_width/height
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/t_repeat.c b/t_repeat.c
index fc9ceb7..92b95ea 100644
--- a/t_repeat.c
+++ b/t_repeat.c
@@ -30,7 +30,10 @@
#include "rendercheck.h"
-/* We choose some sizes larger than win_width/height because AAs like to turn
+#define TEST_WIDTH 40
+#define TEST_HEIGHT 40
+
+/* We choose some sizes larger than width/height because AAs like to turn
* off repeating when it's unnecessary and we want to make sure that those paths
* are sane.
*/
@@ -72,28 +75,32 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
/* Fill to the first color */
XRenderComposite(dpy, PictOpSrc, c1->pict, None, src.pict,
- 0, 0, 0, 0, 0, 0, w, h);
+ 0, 0, 0, 0, 0, 0, w, h);
/* And set the upper-left to the second color */
XRenderComposite(dpy, PictOpSrc, c2->pict, None, src.pict,
- 0, 0, 0, 0, 0, 0, c2w, c2h);
+ 0, 0, 0, 0, 0, 0, c2w, c2h);
for (i = 0; i < pixmap_move_iter; i++) {
/* Fill to dst_color */
- XRenderComposite(dpy, PictOpSrc, dst_color->pict, None,
- dst->pict, 0, 0, 0, 0, 0, 0, win_width, win_height);
- /* Composite the repeat picture in. */
+ XRenderComposite(dpy, PictOpSrc,
+ dst_color->pict, None, dst->pict,
+ 0, 0, 0, 0, 0, 0,
+ TEST_WIDTH, TEST_HEIGHT);
+ /* Composite the repeat picture in. */
if (!test_mask) {
XRenderComposite(dpy, ops[op].op,
- src.pict, None, dst->pict, 0, 0, 0, 0, 0, 0,
- win_width, win_height);
+ src.pict, None, dst->pict,
+ 0, 0, 0, 0, 0, 0,
+ TEST_WIDTH, TEST_HEIGHT);
} else {
/* Using PictOpSrc, color 0 (white), and
* component alpha, the mask color should be
* written to the destination.
*/
XRenderComposite(dpy, ops[op].op,
- argb32white->pict, src.pict, dst->pict,
- 0, 0, 0, 0, 0, 0, win_width, win_height);
+ argb32white->pict, src.pict, dst->pict,
+ 0, 0, 0, 0, 0, 0,
+ TEST_WIDTH, TEST_HEIGHT);
}
}
@@ -117,8 +124,8 @@ repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
snprintf(name, 40, "%dx%d %s %s-repeat", w, h,
ops[op].name, test_mask ? "mask" : "src");
- for (x = 0; x < win_width; x++) {
- for (y = 0; y < win_height; y++) {
+ for (x = 0; x < TEST_WIDTH; x++) {
+ for (y = 0; y < TEST_HEIGHT; y++) {
int samplex = x % w;
int sampley = y % h;
color4d *expected, tested;
More information about the xorg-commit
mailing list