#include #include #include #include #include #define ARRAY_SIZE(A) (sizeof (A) / sizeof (A[0])) static void die (const char *fmt, ...) { va_list ap; va_start (ap, fmt); vfprintf (stderr, fmt, ap); va_end (ap); exit (1); } int main (int argc, char **argv) { Display *dpy; Pixmap pixmap; XPoint *points; XRectangle clip[2]; unsigned int n, max; GC gc; XGCValues values; unsigned int flags = 0; dpy = XOpenDisplay (NULL); if (dpy == NULL) die ("unable to open display"); pixmap = XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)), 128, 128, DefaultDepth (dpy, DefaultScreen (dpy))); values.function = GXand; flags |= GCFunction; values.foreground = 0xdeadbeef; flags |= GCForeground; values.line_width = 0; flags |= GCLineWidth; values.line_style = LineSolid; flags |= GCLineStyle; values.fill_style = FillSolid; flags |= GCFillStyle; gc = XCreateGC (dpy, pixmap, flags, &values); clip[0].x = 0; clip[0].y = 0; clip[0].width = 128; clip[0].height = 64; clip[1].x = 0; clip[1].y = 64; clip[1].width = 128; clip[1].height = 64; XSetClipRectangles (dpy, gc, 0, 0, clip, ARRAY_SIZE (clip), YXBanded); XSync (dpy, True); max = (XMaxRequestSize (dpy) * 4 - sz_xPolyLineReq) / sizeof (XPoint); points = malloc (sizeof (XPoint) * max); if (points == NULL) die ("unable to allocate points\n"); for (n = 0; n < max; n ++) { points[n].x = rand() & 127; points[n].y = rand() & 127; } for (n = 1024; n < max; n *= 2) { printf ("testing nPoints=%d\n", n); fflush (stdout); XDrawLines (dpy, pixmap, gc, points, n, CoordModeOrigin); XSync (dpy, True); } printf ("testing nPoints=%d\n", max); fflush (stdout); XDrawLines (dpy, pixmap, gc, points, max, CoordModeOrigin); XSync (dpy, True); free (points); XCloseDisplay (dpy); return 0; }