1 /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
2 /* cairo - a vector graphics library with display and print output
4 * Copyright (c) 2011 Intel Corporation
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
28 #include "cairo-perf.h"
32 static void path (cairo_t *cr, int width, int height)
36 cairo_rectangle (cr, 0, 0, width, height);
39 cairo_translate (cr, width/2, height/2);
40 cairo_rotate (cr, M_PI/4);
41 cairo_translate (cr, -width/2, -height/2);
43 for (i = 0; i < width; i += STEP) {
44 cairo_rectangle (cr, i, -2, 1, height+4);
45 cairo_rectangle (cr, -2, i, width+4, 1);
49 static void clip (cairo_t *cr, int width, int height)
53 for (j = 0; j < height; j += 2*STEP) {
54 for (i = 0; i < width; i += 2*STEP)
55 cairo_rectangle (cr, i, j, STEP, STEP);
58 for (i = 0; i < width; i += 2*STEP)
59 cairo_rectangle (cr, i+STEP/2, j, STEP, STEP);
66 draw (cairo_t *cr, int width, int height, int loops)
69 cairo_set_source_rgb (cr, 1, 1, 1);
71 cairo_set_source_rgb (cr, 1, 0, 0);
73 cairo_perf_timer_start ();
74 cairo_perf_set_thread_aware (cr, FALSE);
77 cairo_perf_set_thread_aware (cr, TRUE);
79 clip (cr, width, height);
80 path (cr, width, height);
85 cairo_perf_timer_stop ();
89 return cairo_perf_timer_elapsed ();
93 disjoint_enabled (cairo_perf_t *perf)
95 return cairo_perf_can_run (perf, "disjoint", NULL);
99 disjoint (cairo_perf_t *perf, cairo_t *cr, int width, int height)
101 if (! cairo_perf_can_run (perf, "disjoint", NULL))
104 cairo_perf_run (perf, "disjoint", draw, NULL);