#include #include #include #include #include #include #include #include #include "tools.h" #include "setup.h" static int width = 640; static int height = 480; #define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val)) static int overlap = 0; static int test (cairo_surface_t *surface) { uint64_t before = 0; uint64_t after = 0; int nwidth = overlap ? 100 : 99; cairo_t *cr; cr = cairo_create (surface); rdtscll (before); 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); rdtscll (after); cairo_destroy (cr); return (int) (after - before); } int main( int argc, char **argv ) { cairo_surface_t *surface; int j; surface = output_create_surface (argv [0], 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"); for (j = 0; j < NUM_RUNS; j++) { int cur = test (surface); fprintf (stderr, "\t%d: %d (%.2f ms)\n", j, cur, get_milliseconds (cur)); } cairo_surface_destroy( surface ); output_cleanup (); return 0; }