Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright © 2014 Pekka Paalanen <pq@iki.fi> |
| 3 | * Copyright © 2014 Collabora, Ltd. |
| 4 | * |
| 5 | * Permission to use, copy, modify, distribute, and sell this software and |
| 6 | * its documentation for any purpose is hereby granted without fee, provided |
| 7 | * that the above copyright notice appear in all copies and that both that |
| 8 | * copyright notice and this permission notice appear in supporting |
| 9 | * documentation, and that the name of the copyright holders not be used in |
| 10 | * advertising or publicity pertaining to distribution of the software |
| 11 | * without specific, written prior permission. The copyright holders make |
| 12 | * no representations about the suitability of this software for any |
| 13 | * purpose. It is provided "as is" without express or implied warranty. |
| 14 | * |
| 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #ifndef WESTON_TIMELINE_H |
| 25 | #define WESTON_TIMELINE_H |
| 26 | |
| 27 | extern int weston_timeline_enabled_; |
| 28 | |
| 29 | struct weston_compositor; |
| 30 | |
| 31 | void |
| 32 | weston_timeline_open(struct weston_compositor *compositor); |
| 33 | |
| 34 | void |
| 35 | weston_timeline_close(void); |
| 36 | |
| 37 | enum timeline_type { |
| 38 | TLT_END = 0, |
| 39 | TLT_OUTPUT, |
| 40 | TLT_SURFACE, |
| 41 | TLT_VBLANK, |
| 42 | }; |
| 43 | |
| 44 | #define TYPEVERIFY(type, arg) ({ \ |
| 45 | typeof(arg) tmp___ = (arg); \ |
| 46 | (void)((type)0 == tmp___); \ |
| 47 | tmp___; }) |
| 48 | |
| 49 | #define TLP_END TLT_END, NULL |
| 50 | #define TLP_OUTPUT(o) TLT_OUTPUT, TYPEVERIFY(struct weston_output *, (o)) |
| 51 | #define TLP_SURFACE(s) TLT_SURFACE, TYPEVERIFY(struct weston_surface *, (s)) |
| 52 | #define TLP_VBLANK(t) TLT_VBLANK, TYPEVERIFY(const struct timespec *, (t)) |
| 53 | |
| 54 | #define TL_POINT(...) do { \ |
| 55 | if (weston_timeline_enabled_) \ |
| 56 | weston_timeline_point(__VA_ARGS__); \ |
| 57 | } while (0) |
| 58 | |
| 59 | void |
| 60 | weston_timeline_point(const char *name, ...); |
| 61 | |
| 62 | #endif /* WESTON_TIMELINE_H */ |