rendercheck: 4 commits - main.c rendercheck.h t_blend.c tests.c
Eric Anholt
anholt at kemper.freedesktop.org
Tue Jun 20 03:18:42 EEST 2006
main.c | 2
rendercheck.h | 3 +
t_blend.c | 6 ++
tests.c | 141 +++++++++++++++++++++++++++++++++++++++++-----------------
4 files changed, 110 insertions(+), 42 deletions(-)
New commits:
diff-tree f678d50210e81941790f2db72c12563d411006d9 (from 29494c0526c0a1e66e947dec455de1338fad11dd)
Author: Eric Anholt <anholt at FreeBSD.org>
Date: Mon Jun 19 17:17:28 2006 -0700
Disable tests at low bitdepths that rendercheck isn't good enough to support.
diff --git a/tests.c b/tests.c
index a525a2c..ca8c677 100644
--- a/tests.c
+++ b/tests.c
@@ -234,12 +234,14 @@ create_formats_list(Display *dpy)
i);
if (format_list[nformats] != NULL) {
char name[20];
+ int alphabits = bit_count(format_list[nformats]->direct.alphaMask);
+ int redbits = bit_count(format_list[nformats]->direct.redMask);
/* Our testing code isn't all that hot, so don't bother trying at
* the low depths yet.
*/
- if (0 && bit_count(format_list[nformats]->direct.alphaMask) < 5 &&
- bit_count(format_list[nformats]->direct.redMask) < 5)
+ if ((redbits >= 1 && redbits <= 4) ||
+ (alphabits >= 1 && alphabits <= 4))
{
continue;
}
diff-tree 29494c0526c0a1e66e947dec455de1338fad11dd (from 63074a124a755ac6374d644ae7960dbd8cab6251)
Author: Eric Anholt <anholt at FreeBSD.org>
Date: Mon Jun 19 16:49:41 2006 -0700
Note the source format in blend test error output.
diff --git a/t_blend.c b/t_blend.c
index a8208b8..32c40d8 100644
--- a/t_blend.c
+++ b/t_blend.c
@@ -52,10 +52,14 @@ blend_test(Display *dpy, picture_info *w
snprintf(testname, 20, "%s blend", ops[op].name);
if (!eval_diff(testname, &expected, &tested, 0, 0, is_verbose)) {
- printf("src color: %.2f %.2f %.2f %.2f\n"
+ char srcformat[20];
+
+ 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);
diff-tree 63074a124a755ac6374d644ae7960dbd8cab6251 (from 05fa6e38e8e934b74bcc3771781d05cfb3313b26)
Author: Eric Anholt <anholt at FreeBSD.org>
Date: Mon Jun 19 16:49:18 2006 -0700
Tell the ordering of the channel values in error output.
diff --git a/tests.c b/tests.c
index 76d306c..a525a2c 100644
--- a/tests.c
+++ b/tests.c
@@ -171,6 +171,7 @@ eval_diff(char *name, color4d *expected,
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,
diff-tree 05fa6e38e8e934b74bcc3771781d05cfb3313b26 (from 334d2203d35c27e0c0d73226ad8a58360c8b36bb)
Author: Eric Anholt <anholt at FreeBSD.org>
Date: Mon Jun 19 08:30:27 2006 -0700
Add support for checking more formats.
diff --git a/main.c b/main.c
index 05653c5..2ce04b1 100644
--- a/main.c
+++ b/main.c
@@ -40,7 +40,7 @@ int pixmap_move_iter = 1;
int win_width = 40;
int win_height = 40;
-static int
+int
bit_count(int i)
{
int count;
diff --git a/rendercheck.h b/rendercheck.h
index 38d8040..24f2925 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -91,6 +91,9 @@ extern picture_info *argb32white, *argb3
void
describe_format(char *desc, int len, XRenderPictFormat *format);
+int
+bit_count(int i);
+
/* tests.c */
void
color_correct(picture_info *pi, color4d *color);
diff --git a/tests.c b/tests.c
index 53d04e8..76d306c 100644
--- a/tests.c
+++ b/tests.c
@@ -27,8 +27,13 @@
#include "rendercheck.h"
+XRenderPictFormat **format_list;
+int nformats;
+int argb32index;
+
/* Note: changing the order of these colors may disrupt tests that depend on
- * specific colors. Just add to the end if you need.
+ * specific colors. Just add to the end if you need. These are
+ * not premultiplied, but will be in main().
*/
color4d colors[] = {
{1.0, 1.0, 1.0, 1.0},
@@ -193,28 +198,86 @@ argb_fill(Display *dpy, picture_info *p,
XRenderFillRectangle(dpy, PictOpSrc, p->pict, &rendercolor, x, y, w, h);
}
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+/* Create a set of direct format XRenderPictFormats for later use. This lets
+ * us get more formats than just the standard required set, and lets us attach
+ * names to them.
+ */
+void
+create_formats_list(Display *dpy)
+{
+ int i;
+ int nformats_allocated = 5;
+ XRenderPictFormat templ;
+
+ memset(&templ, 0, sizeof(templ));
+ templ.type = PictTypeDirect;
+
+ format_list = malloc(sizeof(XRenderPictFormat *) * nformats_allocated);
+ if (format_list == NULL)
+ errx(1, "malloc error");
+ nformats = 0;
+
+ argb32index = -1;
+ for (i = 0; ; i++) {
+ if (nformats + 1 == nformats_allocated) {
+ nformats_allocated *= 2;
+ format_list = realloc(format_list, sizeof(XRenderPictFormat *) *
+ nformats_allocated);
+ if (format_list == NULL)
+ errx(1, "realloc error");
+ }
+
+ format_list[nformats] = XRenderFindFormat(dpy, PictFormatType, &templ,
+ i);
+ if (format_list[nformats] != NULL) {
+ char name[20];
+
+ /* Our testing code isn't all that hot, so don't bother trying at
+ * the low depths yet.
+ */
+ if (0 && bit_count(format_list[nformats]->direct.alphaMask) < 5 &&
+ bit_count(format_list[nformats]->direct.redMask) < 5)
+ {
+ continue;
+ }
+
+ if (format_list[nformats] == XRenderFindStandardFormat(dpy,
+ PictStandardARGB32))
+ {
+ argb32index = nformats;
+ }
+ describe_format(name, 20, format_list[nformats]);
+ printf("Found server-supported format: %s\n", name);
+
+ nformats++;
+ } else {
+ break;
+ }
+ }
+ if (argb32index == -1) {
+ errx(1, "required ARGB32 format not found");
+ }
+}
+
Bool
do_tests(Display *dpy, picture_info *win)
{
int i, j, src, dst = 0, mask;
- int num_dests, num_formats;
+ int num_dests;
picture_info *dests, *pictures_1x1, *pictures_10x10, picture_3x3, *pictures_solid;
int success_mask = 0, tests_passed = 0, tests_total = 0;
- num_dests = 3;
+ create_formats_list(dpy);
+
+ num_dests = nformats;
dests = (picture_info *)malloc(num_dests * sizeof(dests[0]));
if (dests == NULL)
errx(1, "malloc error");
- dests[0].format = XRenderFindStandardFormat(dpy, PictStandardARGB32);
- dests[1].format = XRenderFindStandardFormat(dpy, PictStandardRGB24);
- dests[2].format = XRenderFindStandardFormat(dpy, PictStandardA8);
- /*
- dests[3].format = XRenderFindStandardFormat(dpy, PictStandardA4);
- dests[4].format = XRenderFindStandardFormat(dpy, PictStandardA1);
- */
-
for (i = 0; i < num_dests; i++) {
+ dests[i].format = format_list[i];
dests[i].d = XCreatePixmap(dpy, RootWindow(dpy, 0),
win_width, win_height, dests[i].format->depth);
dests[i].pict = XRenderCreatePicture(dpy, dests[i].d,
@@ -226,20 +289,17 @@ do_tests(Display *dpy, picture_info *win
describe_format(dests[i].name, 20, dests[i].format);
}
- num_formats = 3;
-
- pictures_1x1 = (picture_info *)malloc(num_colors * num_formats *
+ pictures_1x1 = (picture_info *)malloc(num_colors * nformats *
sizeof(picture_info));
if (pictures_1x1 == NULL)
errx(1, "malloc error");
- for (i = 0; i < num_colors * num_formats; i++) {
+ for (i = 0; i < num_colors * nformats; i++) {
XRenderPictureAttributes pa;
- color4d *c = &colors[i / num_formats];
+ color4d *c = &colors[i / nformats];
/* The standard PictFormat numbers go from 0 to 4 */
- pictures_1x1[i].format = XRenderFindStandardFormat(dpy,
- i % num_formats);
+ pictures_1x1[i].format = format_list[i % nformats];
pictures_1x1[i].d = XCreatePixmap(dpy, RootWindow(dpy, 0), 1,
1, pictures_1x1[i].format->depth);
pa.repeat = TRUE;
@@ -260,23 +320,22 @@ do_tests(Display *dpy, picture_info *win
pictures_1x1[i].color = *c;
color_correct(&pictures_1x1[i], &pictures_1x1[i].color);
}
- argb32white = &pictures_1x1[0 * num_formats];
- argb32red = &pictures_1x1[1 * num_formats];
- argb32green = &pictures_1x1[2 * num_formats];
- argb32blue = &pictures_1x1[3 * num_formats];
+ argb32white = &pictures_1x1[0 * nformats + argb32index];
+ argb32red = &pictures_1x1[1 * nformats + argb32index];
+ argb32green = &pictures_1x1[2 * nformats + argb32index];
+ argb32blue = &pictures_1x1[3 * nformats + argb32index];
- pictures_10x10 = (picture_info *)malloc(num_colors * num_formats *
+ pictures_10x10 = (picture_info *)malloc(num_colors * nformats *
sizeof(picture_info));
if (pictures_10x10 == NULL)
errx(1, "malloc error");
- for (i = 0; i < num_colors * num_formats; i++) {
+ for (i = 0; i < num_colors * nformats; i++) {
XRenderPictureAttributes pa;
- color4d *c = &colors[i / num_formats];
+ color4d *c = &colors[i / nformats];
/* The standard PictFormat numbers go from 0 to 4 */
- pictures_10x10[i].format = XRenderFindStandardFormat(dpy,
- i % num_formats);
+ pictures_10x10[i].format = format_list[i % nformats];
pictures_10x10[i].d = XCreatePixmap(dpy, RootWindow(dpy, 0), 10,
10, pictures_10x10[i].format->depth);
pa.repeat = TRUE;
@@ -335,13 +394,13 @@ do { \
Bool ok, group_ok = TRUE;
printf("Beginning testing of filling of 1x1R pictures\n");
- for (i = 0; i < num_colors * num_formats; i++) {
+ for (i = 0; i < num_colors * nformats; i++) {
ok = fill_test(dpy, win, &pictures_1x1[i]);
RECORD_RESULTS();
}
printf("Beginning testing of filling of 10x10 pictures\n");
- for (i = 0; i < num_colors * num_formats; i++) {
+ for (i = 0; i < num_colors * nformats; i++) {
ok = fill_test(dpy, win, &pictures_10x10[i]);
RECORD_RESULTS();
}
@@ -353,9 +412,8 @@ do { \
Bool ok, group_ok = TRUE;
printf("Beginning dest coords test\n");
- /* 0 and num_formats should result in ARGB8888 red on ARGB8888 white. */
- ok = dstcoords_test(dpy, win, &dests[0], &pictures_1x1[0],
- &pictures_1x1[num_formats]);
+ ok = dstcoords_test(dpy, win, &dests[0], argb32white,
+ argb32red);
RECORD_RESULTS();
if (group_ok)
success_mask |= TEST_DSTCOORDS;
@@ -365,7 +423,7 @@ do { \
Bool ok, group_ok = TRUE;
printf("Beginning src coords test\n");
- ok = srccoords_test(dpy, win, &pictures_1x1[0], FALSE);
+ ok = srccoords_test(dpy, win, argb32white, FALSE);
RECORD_RESULTS();
if (group_ok)
success_mask |= TEST_SRCCOORDS;
@@ -375,7 +433,7 @@ do { \
Bool ok, group_ok = TRUE;
printf("Beginning mask coords test\n");
- ok = srccoords_test(dpy, win, &pictures_1x1[0], TRUE);
+ ok = srccoords_test(dpy, win, argb32white, TRUE);
RECORD_RESULTS();
if (group_ok)
success_mask |= TEST_MASKCOORDS;
@@ -385,7 +443,7 @@ do { \
Bool ok, group_ok = TRUE;
printf("Beginning transformed src coords test\n");
- ok = trans_coords_test(dpy, win, &pictures_1x1[0], FALSE);
+ ok = trans_coords_test(dpy, win, argb32white, FALSE);
RECORD_RESULTS();
if (group_ok)
success_mask |= TEST_TSRCCOORDS;
@@ -395,7 +453,7 @@ do { \
Bool ok, group_ok = TRUE;
printf("Beginning transformed mask coords test\n");
- ok = trans_coords_test(dpy, win, &pictures_1x1[0], TRUE);
+ ok = trans_coords_test(dpy, win, argb32white, TRUE);
RECORD_RESULTS();
if (group_ok)
success_mask |= TEST_TMASKCOORDS;
@@ -415,7 +473,7 @@ do { \
printf("Beginning %s blend test on %s\n", ops[i].name,
pi->name);
- for (src = 0; src < num_colors * num_formats; src++) {
+ for (src = 0; src < num_colors * nformats; src++) {
for (dst = 0; dst < num_colors; dst++) {
ok = blend_test(dpy, win, pi, i,
&pictures_1x1[src],
@@ -607,19 +665,19 @@ do { \
printf("Beginning %s Triangles test on %s\n",
ops[i].name, pi->name);
ok = triangles_test(dpy, win, pi, i,
- &pictures_1x1[num_formats], &pictures_1x1[0]);
+ argb32red, argb32white);
RECORD_RESULTS();
printf("Beginning %s TriStrip test on %s\n",
ops[i].name, pi->name);
ok = tristrip_test(dpy, win, pi, i,
- &pictures_1x1[num_formats], &pictures_1x1[0]);
+ argb32red, argb32white);
RECORD_RESULTS();
printf("Beginning %s TriFan test on %s\n",
ops[i].name, pi->name);
ok = trifan_test(dpy, win, pi, i,
- &pictures_1x1[num_formats], &pictures_1x1[0]);
+ argb32red, argb32white);
RECORD_RESULTS();
}
}
More information about the xorg-commit
mailing list