#include #include #include #include #include #define NUM_RUNS 100 static int width = 640; static int height = 480; static int overlap = 0; static void test (cairo_surface_t *surface) { int nwidth = overlap ? 100 : 99; cairo_t *cr; cr = cairo_create (surface); cairo_identity_matrix (cr); cairo_rectangle (cr, 0, 0, 200, height); cairo_rectangle (cr, 300, 0, width-300, height); cairo_rectangle (cr, 200, 0, nwidth, 200); cairo_rectangle (cr, 200, 300, nwidth, height-300); cairo_clip (cr); cairo_new_path (cr); cairo_translate (cr, 0, 0); cairo_rectangle (cr, 0, 0, width, height); cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); cairo_fill (cr); cairo_destroy (cr); } int main( int argc, char **argv ) { cairo_surface_t *surface; int j; struct timeval before; struct timeval after; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); if (argc == 2 && !strcmp (argv[1], "1")) overlap = 1; fprintf (stderr, "Testing multiple clip rectangles...\n"); test (surface); cairo_surface_write_to_png (surface, "multiple-clip-surfaces-out.png"); gettimeofday (&before, NULL); for (j = 0; j < NUM_RUNS; j++) { test (surface); } gettimeofday (&after, NULL); fprintf (stderr, "%g msec\n", (after.tv_sec - before.tv_sec) * 1000. + (after.tv_usec - before.tv_usec) / 1000.); cairo_surface_destroy( surface ); return 0; }