2 * Copyright © 2006 Mozilla Corporation
3 * Copyright © 2006 Red Hat, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * the authors not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. The authors make no representations about the
13 * suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty.
16 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL,
19 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: Vladimir Vukicevic <vladimir@pobox.com>
25 * Carl Worth <cworth@cworth.org>
30 #define WIN32_LEAN_AND_MEAN
33 #include "cairo-perf.h"
37 typedef struct _cairo_perf_timer
43 static cairo_perf_timer_t timer
;
45 static cairo_perf_timer_synchronize_t cairo_perf_timer_synchronize
= NULL
;
46 static void *cairo_perf_timer_synchronize_closure
= NULL
;
48 cairo_perf_timer_set_synchronize (cairo_perf_timer_synchronize_t synchronize
,
51 cairo_perf_timer_synchronize
= synchronize
;
52 cairo_perf_timer_synchronize_closure
= closure
;
56 cairo_perf_timer_start (void) {
57 if (cairo_perf_timer_synchronize
)
58 cairo_perf_timer_synchronize (cairo_perf_timer_synchronize_closure
);
59 QueryPerformanceCounter(&timer
.start
);
63 cairo_perf_timer_stop (void) {
64 if (cairo_perf_timer_synchronize
)
65 cairo_perf_timer_synchronize (cairo_perf_timer_synchronize_closure
);
66 QueryPerformanceCounter(&timer
.stop
);
70 cairo_perf_timer_elapsed (void) {
71 return (timer
.stop
.QuadPart
- timer
.start
.QuadPart
);
75 cairo_perf_ticks_per_second (void) {
78 QueryPerformanceFrequency(&freq
);
87 cairo_perf_yield (void) {