2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / cairo / perf / world-map.c
blobfe6d42d543fef070da07c09fab68efe1910ec0c7
1 /*
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
22 * SOFTWARE.
24 * Author: Carl D. Worth <cworth@cworth.org>
27 #include "cairo-perf.h"
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
33 typedef enum {
34 WM_NEW_PATH,
35 WM_MOVE_TO,
36 WM_LINE_TO,
37 WM_HLINE_TO,
38 WM_VLINE_TO,
39 WM_REL_LINE_TO,
40 WM_END
41 } wm_type_t;
43 typedef struct _wm_element {
44 wm_type_t type;
45 double x;
46 double y;
47 } wm_element_t;
49 #include "world-map.h"
51 static cairo_perf_ticks_t
52 do_world_map (cairo_t *cr, int width, int height)
54 const wm_element_t *e;
55 double cx, cy;
57 cairo_perf_timer_start ();
59 cairo_set_source_rgb (cr, .68, .85, .90); /* lightblue */
60 cairo_rectangle (cr, 0, 0, 800, 400);
61 cairo_fill (cr);
63 cairo_set_line_width (cr, 0.2);
65 e = &countries[0];
66 while (1) {
67 switch (e->type) {
68 case WM_NEW_PATH:
69 case WM_END:
70 cairo_set_source_rgb (cr, .75, .75, .75); /* silver */
71 cairo_fill_preserve (cr);
72 cairo_set_source_rgb (cr, .50, .50, .50); /* gray */
73 cairo_stroke (cr);
74 cairo_move_to (cr, e->x, e->y);
75 break;
76 case WM_MOVE_TO:
77 cairo_close_path (cr);
78 cairo_move_to (cr, e->x, e->y);
79 break;
80 case WM_LINE_TO:
81 cairo_line_to (cr, e->x, e->y);
82 break;
83 case WM_HLINE_TO:
84 cairo_get_current_point (cr, &cx, &cy);
85 cairo_line_to (cr, e->x, cy);
86 break;
87 case WM_VLINE_TO:
88 cairo_get_current_point (cr, &cx, &cy);
89 cairo_line_to (cr, cx, e->y);
90 break;
91 case WM_REL_LINE_TO:
92 cairo_rel_line_to (cr, e->x, e->y);
93 break;
95 if (e->type == WM_END)
96 break;
97 e++;
100 cairo_perf_timer_stop ();
102 return cairo_perf_timer_elapsed ();
105 void
106 world_map (cairo_perf_t *perf, cairo_t *cr, int width, int height)
108 cairo_perf_run (perf, "world_map", do_world_map);