2 * Copyright © 2006 Dan Amelang
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * the authors not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. The authors make no representations about the
12 * suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL,
18 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Authors: Dan Amelang <dan@amelang.net>
25 * This test was originally created to test _cairo_fixed_from_double.
26 * cairo_pattern_create_radial was selected as the entry point into
27 * cairo as it makes several calls to _cairo_fixed_from_double and
28 * presents a somewhat realistic use-case (although the RADIALS_COUNT
29 * isn't very realistic).
32 #include "cairo-perf.h"
34 #define RADIALS_COUNT (10000)
44 } radials[RADIALS_COUNT];
47 generate_double_in_range (double min, double max)
51 d = rand () / (double) RAND_MAX;
59 do_pattern_create_radial (cairo_t *cr, int width, int height, int loops)
61 cairo_perf_timer_start ();
62 cairo_perf_set_thread_aware (cr, FALSE);
65 cairo_pattern_t *pattern;
69 cairo_perf_set_thread_aware (cr, TRUE);
71 for (i = 0; i < RADIALS_COUNT; i++) {
73 cairo_pattern_create_radial (radials[i].cx0, radials[i].cy0,
75 radials[i].cx1, radials[i].cy1,
77 cairo_pattern_destroy (pattern);
81 cairo_perf_timer_stop ();
83 return cairo_perf_timer_elapsed ();
87 pattern_create_radial_enabled (cairo_perf_t *perf)
89 return cairo_perf_can_run (perf, "pattern-create-radial", NULL);
93 pattern_create_radial (cairo_perf_t *perf, cairo_t *cr, int width, int height)
98 for (i = 0; i < RADIALS_COUNT; i++)
100 radials[i].cx0 = generate_double_in_range (-50000.0, 50000.0);
101 radials[i].cy0 = generate_double_in_range (-50000.0, 50000.0);
102 radials[i].radius0 = generate_double_in_range (0.0, 1000.0);
103 radials[i].cx1 = generate_double_in_range (-50000.0, 50000.0);
104 radials[i].cy1 = generate_double_in_range (-50000.0, 50000.0);
105 radials[i].radius1 = generate_double_in_range (0.0, 1000.0);
108 cairo_perf_run (perf, "pattern-create-radial",
109 do_pattern_create_radial, NULL);