2 * Copyright © 2011 Intel Corporation
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: Chris Wilson <chris@chris-wilson.co.uk>
27 #include "cairo-perf.h"
30 horizontal (cairo_t *cr, int width, int height, int loops)
32 double h = height/2 + .5;
34 cairo_move_to (cr, 0, h);
35 cairo_line_to (cr, width, h);
37 cairo_perf_timer_start ();
38 cairo_perf_set_thread_aware (cr, FALSE);
42 cairo_perf_set_thread_aware (cr, TRUE);
43 cairo_stroke_preserve (cr);
46 cairo_perf_timer_stop ();
50 return cairo_perf_timer_elapsed ();
54 horizontal_hair (cairo_t *cr, int width, int height, int loops)
56 cairo_set_line_width (cr, 1.);
57 return horizontal (cr, width, height, loops);
61 horizontal_wide (cairo_t *cr, int width, int height, int loops)
63 cairo_set_line_width (cr, 5.);
64 return horizontal (cr, width, height, loops);
68 nearly_horizontal (cairo_t *cr, int width, int height, int loops)
72 cairo_move_to (cr, 0, h);
73 cairo_line_to (cr, width, h+1);
75 cairo_perf_timer_start ();
76 cairo_perf_set_thread_aware (cr, FALSE);
80 cairo_perf_set_thread_aware (cr, TRUE);
81 cairo_stroke_preserve (cr);
84 cairo_perf_timer_stop ();
88 return cairo_perf_timer_elapsed ();
92 nearly_horizontal_hair (cairo_t *cr, int width, int height, int loops)
94 cairo_set_line_width (cr, 1.);
95 return nearly_horizontal (cr, width, height, loops);
99 nearly_horizontal_wide (cairo_t *cr, int width, int height, int loops)
101 cairo_set_line_width (cr, 5.);
102 return nearly_horizontal (cr, width, height, loops);
107 vertical (cairo_t *cr, int width, int height, int loops)
109 double w = width/2 + .5;
111 cairo_move_to (cr, w, 0);
112 cairo_line_to (cr, w, height);
114 cairo_perf_timer_start ();
115 cairo_perf_set_thread_aware (cr, FALSE);
119 cairo_perf_set_thread_aware (cr, TRUE);
120 cairo_stroke_preserve (cr);
123 cairo_perf_timer_stop ();
127 return cairo_perf_timer_elapsed ();
131 vertical_hair (cairo_t *cr, int width, int height, int loops)
133 cairo_set_line_width (cr, 1.);
134 return vertical (cr, width, height, loops);
138 vertical_wide (cairo_t *cr, int width, int height, int loops)
140 cairo_set_line_width (cr, 5.);
141 return vertical (cr, width, height, loops);
145 nearly_vertical (cairo_t *cr, int width, int height, int loops)
149 cairo_move_to (cr, w, 0);
150 cairo_line_to (cr, w+1, height);
152 cairo_perf_timer_start ();
153 cairo_perf_set_thread_aware (cr, FALSE);
157 cairo_perf_set_thread_aware (cr, TRUE);
158 cairo_stroke_preserve (cr);
161 cairo_perf_timer_stop ();
165 return cairo_perf_timer_elapsed ();
169 nearly_vertical_hair (cairo_t *cr, int width, int height, int loops)
171 cairo_set_line_width (cr, 1.);
172 return nearly_vertical (cr, width, height, loops);
176 nearly_vertical_wide (cairo_t *cr, int width, int height, int loops)
178 cairo_set_line_width (cr, 5.);
179 return nearly_vertical (cr, width, height, loops);
184 diagonal (cairo_t *cr, int width, int height, int loops)
186 cairo_move_to (cr, 0, 0);
187 cairo_line_to (cr, width, height);
189 cairo_perf_timer_start ();
190 cairo_perf_set_thread_aware (cr, FALSE);
194 cairo_perf_set_thread_aware (cr, TRUE);
195 cairo_stroke_preserve (cr);
198 cairo_perf_timer_stop ();
202 return cairo_perf_timer_elapsed ();
206 diagonal_hair (cairo_t *cr, int width, int height, int loops)
208 cairo_set_line_width (cr, 1.);
209 return diagonal (cr, width, height, loops);
213 diagonal_wide (cairo_t *cr, int width, int height, int loops)
215 cairo_set_line_width (cr, 5.);
216 return diagonal (cr, width, height, loops);
220 a1_line_enabled (cairo_perf_t *perf)
222 return cairo_perf_can_run (perf, "a1-line", NULL);
226 a1_line (cairo_perf_t *perf, cairo_t *cr, int width, int height)
228 cairo_set_source_rgb (cr, 1., 1., 1.);
229 cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
231 cairo_perf_run (perf, "a1-line-hh", horizontal_hair, NULL);
232 cairo_perf_run (perf, "a1-line-hw", horizontal_wide, NULL);
233 cairo_perf_run (perf, "a1-line-nhh", nearly_horizontal_hair, NULL);
234 cairo_perf_run (perf, "a1-line-nhw", nearly_horizontal_wide, NULL);
236 cairo_perf_run (perf, "a1-line-vh", vertical_hair, NULL);
237 cairo_perf_run (perf, "a1-line-vw", vertical_wide, NULL);
238 cairo_perf_run (perf, "a1-line-nvh", nearly_vertical_hair, NULL);
239 cairo_perf_run (perf, "a1-line-nvw", nearly_vertical_wide, NULL);
241 cairo_perf_run (perf, "a1-line-dh", diagonal_hair, NULL);
242 cairo_perf_run (perf, "a1-line-dw", diagonal_wide, NULL);