5 #include <X11/Xutil.h> /* for XDestroyImage */
13 XRenderPictFormat *format;
16 static void target_init(struct test_display *t, struct draw *tt, int size)
20 tt->a = XCreatePixmap(t->dpy, DefaultRootWindow(t->dpy),
22 tt->b = XCreatePixmap(t->dpy, DefaultRootWindow(t->dpy),
25 val.graphics_exposures = 0;
26 tt->gc = XCreateGC(t->dpy, tt->a, GCGraphicsExposures, &val);
28 tt->format = XRenderFindStandardFormat(t->dpy, PictStandardARGB32);
30 val.foreground = 0xffff0000;
31 XChangeGC(t->dpy, tt->gc, GCForeground, &val);
32 XFillRectangle(t->dpy, tt->a, tt->gc, 0, 0, size, size);
34 val.foreground = 0xff0000ff;
35 XChangeGC(t->dpy, tt->gc, GCForeground, &val);
36 XFillRectangle(t->dpy, tt->b, tt->gc, 0, 0, size, size);
39 static void target_fini(struct test_display *t, struct draw *tt)
41 XFreePixmap(t->dpy, tt->a);
42 XFreePixmap(t->dpy, tt->b);
45 int main(int argc, char **argv)
48 struct draw real, ref;
51 test_init(&test, argc, argv);
53 /* Copy back and forth betwenn two pixmaps, gradually getting larger */
54 for (size = 1; size <= SIZE; size = (size * 3 + 1) / 2) {
55 target_init(&test.real, &real, size);
56 target_init(&test.ref, &ref, size);
58 printf("size=%d\n", size);
59 for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
62 int sx = rand() % (2*size) - size;
63 int sy = rand() % (2*size) - size;
65 int dx = rand() % (2*size) - size;
66 int dy = rand() % (2*size) - size;
68 int order = rand() & 1;
70 XCopyArea(test.real.dpy,
71 order ? real.a : real.b,
72 (!order) ? real.a : real.b,
78 XCopyArea(test.ref.dpy,
79 order ? ref.a : ref.b,
80 (!order) ? ref.a : ref.b,
99 target_fini(&test.real, &real);
100 target_fini(&test.ref, &ref);