void dispbox() { if (g_box_count) { setlinemode(1); drawline(g_box_x[0], g_box_y[0], g_box_x[1], g_box_y[1]); drawline(g_box_x[1], g_box_y[1], g_box_x[2], g_box_y[2]); drawline(g_box_x[2], g_box_y[2], g_box_x[3], g_box_y[3]); drawline(g_box_x[3], g_box_y[3], g_box_x[0], g_box_y[0]); setlinemode(0); xsync(); } }
static void run(Display *dpy, int width, int height, unsigned int *attachments, int nattachments, const char *name) { Window win; XSetWindowAttributes attr; int count; DRI2Buffer *buffers; struct timespec start, end; /* Be nasty and install a fullscreen window on top so that we * can guarantee we do not get clipped by children. */ attr.override_redirect = 1; win = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, width, height, 0, DefaultDepth(dpy, DefaultScreen(dpy)), InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)), CWOverrideRedirect, &attr); XMapWindow(dpy, win); xsync(dpy, win); DRI2CreateDrawable(dpy, win); buffers = DRI2GetBuffers(dpy, win, &width, &height, attachments, nattachments, &count); if (count != nattachments) return; xsync(dpy, win); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) DRI2SwapBuffers(dpy, win, 0, 0, 0); xsync(dpy, win); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) swaps in %fs.\n", count, name, width, height, elapsed(&start, &end)); xsync(dpy, win); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) dri2_copy_swap(dpy, win, width, height, nattachments == 2); xsync(dpy, win); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) blits in %fs.\n", count, name, width, height, elapsed(&start, &end)); DRI2SwapInterval(dpy, win, 0); xsync(dpy, win); clock_gettime(CLOCK_MONOTONIC, &start); for (count = 0; count < COUNT; count++) DRI2SwapBuffers(dpy, win, 0, 0, 0); xsync(dpy, win); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %s (%dx%d) vblank=0 swaps in %fs.\n", count, name, width, height, elapsed(&start, &end)); XDestroyWindow(dpy, win); free(buffers); XSync(dpy, 1); }