#include #include #include #include int main (int argc, char **argv) { Display *display; Window root; int screen; int screen_width, screen_height; int temp_width, temp_height; 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); screen_width = DisplayWidth (display, screen); screen_height = DisplayHeight (display, screen); temp_width = screen_width; temp_height = screen_height - 29; /* think of this as the height of the GNOME Panel */ back_pixmap = XCreatePixmap (display, root, screen_width, screen_height, DefaultDepth (display, screen)); /* desktop background */ temp_pixmap = XCreatePixmap (display, root, temp_width, temp_height, DefaultDepth (display, screen)); /* double-buffer */ visual = DefaultVisual (display, screen); back_surface = cairo_xlib_surface_create (display, back_pixmap, visual, screen_width, screen_height); temp_surface = cairo_xlib_surface_create (display, temp_pixmap, visual, temp_width, temp_height); 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, temp_width, temp_height); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); 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; }