ShaderEffect subclasses from Effect, not DependencyObject
[moon.git] / cairo / perf / cairo-perf-win32.c
blobc63ca75683ebc3ad80fbc81c66aea5cf3cf892e6
1 /*
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>
28 #define USE_WINAPI
30 #define WIN32_LEAN_AND_MEAN
31 #include <windows.h>
33 #include "cairo-perf.h"
35 /* timers */
37 typedef struct _cairo_perf_timer
39 LARGE_INTEGER start;
40 LARGE_INTEGER stop;
41 } cairo_perf_timer_t;
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;
47 void
48 cairo_perf_timer_set_synchronize (cairo_perf_timer_synchronize_t synchronize,
49 void *closure)
51 cairo_perf_timer_synchronize = synchronize;
52 cairo_perf_timer_synchronize_closure = closure;
55 void
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);
62 void
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);
69 cairo_perf_ticks_t
70 cairo_perf_timer_elapsed (void) {
71 return (timer.stop.QuadPart - timer.start.QuadPart);
74 cairo_perf_ticks_t
75 cairo_perf_ticks_per_second (void) {
76 LARGE_INTEGER freq;
78 QueryPerformanceFrequency(&freq);
80 return freq.QuadPart;
84 /* yield */
86 void
87 cairo_perf_yield (void) {
88 SleepEx(0, TRUE);