rendercheck: rendercheck.h tests.c t_gradient.c
Eric Anholt
anholt at kemper.freedesktop.org
Tue Apr 15 14:01:25 PDT 2008
rendercheck.h | 2 +
t_gradient.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests.c | 4 +++
3 files changed, 78 insertions(+)
New commits:
commit 0c6aaf012b592bae818d5ce75cd41f23bd4d2cd5
Author: Eric Anholt <eric at anholt.net>
Date: Tue Apr 15 14:01:06 2008 -0700
Add a test for rendering to source-only pictures under gradients.
diff --git a/rendercheck.h b/rendercheck.h
index 3ae39ce..b60e482 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -155,6 +155,8 @@ Bool
trans_srccoords_test_2(Display *dpy, picture_info *win, picture_info *white,
Bool test_mask);
+Bool render_to_gradient_test(Display *dpy, picture_info *src);
+
Bool linear_gradient_test(Display *dpy, picture_info *win,
picture_info *dst, int op, picture_info *dst_color);
diff --git a/t_gradient.c b/t_gradient.c
index b0b58fd..71cfebe 100644
--- a/t_gradient.c
+++ b/t_gradient.c
@@ -87,6 +87,78 @@ static const pixel test_pixels [] = {
const int n_linear_gradient_points = sizeof(linear_gradient_points)/(2*sizeof(point));
+static Bool got_bad_drawable;
+
+static int expecting_bad_drawable(Display *dpy, XErrorEvent *event)
+{
+ if (event->error_code == BadDrawable)
+ got_bad_drawable = TRUE;
+
+ return TRUE;
+}
+
+
+/* Tests that rendering to a linear gradient returns an error as expected.
+ */
+Bool
+render_to_gradient_test(Display *dpy, picture_info *src)
+{
+ XLinearGradient g;
+ Picture gradient;
+ XFixed stops[10];
+ XRenderColor colors[10];
+ const stop *stps = &stop_list[0][0];
+ int i, p = 0;
+
+ g.p1.x = XDoubleToFixed(linear_gradient_points[p].x);
+ g.p1.y = XDoubleToFixed(linear_gradient_points[p].y);
+ g.p2.x = XDoubleToFixed(linear_gradient_points[p+1].x);
+ g.p2.y = XDoubleToFixed(linear_gradient_points[p+1].y);
+ for (i = 0; i < 10; ++i) {
+ if (stps[i].x < 0)
+ break;
+ stops[i] = XDoubleToFixed(stps[i].x);
+ colors[i].red = stps[i].color.r*65535;
+ colors[i].green = stps[i].color.g*65535;
+ colors[i].blue = stps[i].color.b*65535;
+ colors[i].alpha = stps[i].color.a*65535;
+ }
+ gradient = XRenderCreateLinearGradient(dpy, &g, stops, colors, i);
+
+ /* Clear out any failing requests before our expected to fail ones. */
+ XSync(dpy, FALSE);
+
+ got_bad_drawable = FALSE;
+ XSetErrorHandler(expecting_bad_drawable);
+
+ /* Try a real compositing path */
+ XRenderComposite(dpy, PictOpOver, src->pict, 0, gradient,
+ 0, 0, 0, 0, 0, 0, win_width, win_height);
+ XSync(dpy, FALSE);
+ if (!got_bad_drawable) {
+ printf("render_to_gradient: Failed to get BadDrawable with "
+ "Over\n");
+ return FALSE;
+ } else {
+ got_bad_drawable = FALSE;
+ }
+
+ /* Try the copy path to catch bad short-circuiting to 2d. */
+ XRenderComposite(dpy, PictOpSrc, src->pict, 0, gradient,
+ 0, 0, 0, 0, 0, 0, win_width, win_height);
+ XSync(dpy, FALSE);
+ if (!got_bad_drawable) {
+ printf("render_to_gradient: Failed to get BadDrawable with "
+ "Src\n");
+ return FALSE;
+ } else {
+ got_bad_drawable = FALSE;
+ }
+ XSetErrorHandler(NULL);
+
+ XRenderFreePicture(dpy, gradient);
+}
+
static void gradientPixel(const stop *stops, double pos, unsigned int spread, color4d *result)
{
const int PRECISION = 1<<16;
diff --git a/tests.c b/tests.c
index 549010c..8e15d86 100644
--- a/tests.c
+++ b/tests.c
@@ -637,6 +637,10 @@ do { \
if (enabled_tests & TEST_GRADIENTS) {
Bool ok, group_ok = TRUE;
+ printf("Beginning render to linear gradient test\n");
+ ok = render_to_gradient_test(dpy, &pictures_1x1[0]);
+ RECORD_RESULTS();
+
for (i = 0; i < num_ops; i++) {
if (ops[i].disabled)
continue;
More information about the xorg-commit
mailing list