1 /*
2  * Copyright © 2014 Pekka Paalanen <pq@iki.fi>
3  * Copyright © 2014 Collabora, Ltd.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial
15  * portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  * SOFTWARE.
25  */
26 
27 #ifndef WESTON_TIMELINE_H
28 #define WESTON_TIMELINE_H
29 
30 extern int weston_timeline_enabled_;
31 
32 struct weston_compositor;
33 
34 void
35 weston_timeline_open(struct weston_compositor *compositor);
36 
37 void
38 weston_timeline_close(void);
39 
40 enum timeline_type {
41 	TLT_END = 0,
42 	TLT_OUTPUT,
43 	TLT_SURFACE,
44 	TLT_VBLANK,
45 };
46 
47 #define TYPEVERIFY(type, arg) ({			\
48 	typeof(arg) tmp___ = (arg);		\
49 	(void)((type)0 == tmp___);		\
50 	tmp___; })
51 
52 #define TLP_END TLT_END, NULL
53 #define TLP_OUTPUT(o) TLT_OUTPUT, TYPEVERIFY(struct weston_output *, (o))
54 #define TLP_SURFACE(s) TLT_SURFACE, TYPEVERIFY(struct weston_surface *, (s))
55 #define TLP_VBLANK(t) TLT_VBLANK, TYPEVERIFY(const struct timespec *, (t))
56 
57 #define TL_POINT(...) do { \
58 	if (weston_timeline_enabled_) \
59 		weston_timeline_point(__VA_ARGS__); \
60 } while (0)
61 
62 void
63 weston_timeline_point(const char *name, ...);
64 
65 #endif /* WESTON_TIMELINE_H */
66