#include #include #include #include int main (int argc, char **argv) { Display *display; Window root; int screen; Pixmap back_pixmap; Pixmap temp_pixmap; Visual *visual; cairo_surface_t *back_surface, *temp_surface; cairo_t *cr; cairo_pattern_t *pattern; struct timeval start, end, elapsed; double total; display = XOpenDisplay (NULL); XSynchronize (display, 1); screen = DefaultScreen (display); root = DefaultRootWindow (display); back_pixmap = XCreatePixmap (display, root, 1400, 1050, DefaultDepth (display, screen)); /* desktop background */ temp_pixmap = XCreatePixmap (display, root, 1400, 1021, DefaultDepth (display, screen)); /* double-buffer */ visual = DefaultVisual (display, screen); back_surface = cairo_xlib_surface_create (display, back_pixmap, visual, 1400, 1050); temp_surface = cairo_xlib_surface_create (display, temp_pixmap, visual, 1400, 1021); cr = cairo_create (temp_surface); pattern = cairo_pattern_create_for_surface (back_surface); cairo_surface_destroy (back_surface); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_rectangle (cr, 0, 0, 1400, 1021); gettimeofday (&start, NULL); cairo_fill (cr); gettimeofday (&end, NULL); if (start.tv_usec > end.tv_usec) { end.tv_usec += 1000000; end.tv_sec--; } elapsed.tv_usec = end.tv_usec - start.tv_usec; elapsed.tv_sec = end.tv_sec - start.tv_sec; total = elapsed.tv_sec + ((double) elapsed.tv_usec / 1e6); printf ("cairo_fill() time: %f sec\n", total); return 0; }