2 * Copyright © 2006 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Author: Carl D. Worth <cworth@cworth.org>
27 #include "cairo-perf.h"
43 typedef struct _wm_element {
49 #include "world-map.h"
57 do_world_map (cairo_t *cr, int width, int height, int loops, int mode)
59 const wm_element_t *e;
62 cairo_set_line_width (cr, 0.2);
64 cairo_perf_timer_start ();
65 cairo_perf_set_thread_aware (cr, FALSE);
69 cairo_perf_set_thread_aware (cr, TRUE);
70 cairo_set_source_rgb (cr, .68, .85, .90); /* lightblue */
71 cairo_rectangle (cr, 0, 0, 800, 400);
80 cairo_set_source_rgb (cr, .75, .75, .75); /* silver */
81 cairo_fill_preserve (cr);
84 cairo_set_source_rgb (cr, .50, .50, .50); /* gray */
88 cairo_move_to (cr, e->x, e->y);
91 cairo_close_path (cr);
92 cairo_move_to (cr, e->x, e->y);
95 cairo_line_to (cr, e->x, e->y);
98 cairo_get_current_point (cr, &cx, &cy);
99 cairo_line_to (cr, e->x, cy);
102 cairo_get_current_point (cr, &cx, &cy);
103 cairo_line_to (cr, cx, e->y);
106 cairo_rel_line_to (cr, e->x, e->y);
109 if (e->type == WM_END)
117 cairo_perf_timer_stop ();
119 return cairo_perf_timer_elapsed ();
123 do_world_map_stroke (cairo_t *cr, int width, int height, int loops)
125 return do_world_map (cr, width, height, loops, STROKE);
129 do_world_map_fill (cairo_t *cr, int width, int height, int loops)
131 return do_world_map (cr, width, height, loops, FILL);
135 do_world_map_both (cairo_t *cr, int width, int height, int loops)
137 return do_world_map (cr, width, height, loops, FILL | STROKE);
141 world_map_enabled (cairo_perf_t *perf)
143 return cairo_perf_can_run (perf, "world-map", NULL);
147 world_map (cairo_perf_t *perf, cairo_t *cr, int width, int height)
149 cairo_perf_run (perf, "world-map-stroke", do_world_map_stroke, NULL);
150 cairo_perf_run (perf, "world-map-fill", do_world_map_fill, NULL);
151 cairo_perf_run (perf, "world-map", do_world_map_both, NULL);