blob: aaed7431472ee8be38dbbce2fa8d92f334a3bab8 [file] [log] [blame]
Pekka Paalanenb5026542014-11-12 15:09:24 +02001/*
2 * Copyright © 2014 Pekka Paalanen <pq@iki.fi>
Marius Vlad2a1b7862019-09-05 13:12:18 +03003 * Copyright © 2014, 2019 Collabora, Ltd.
Pekka Paalanenb5026542014-11-12 15:09:24 +02004 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -07005 * 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:
Pekka Paalanenb5026542014-11-12 15:09:24 +020012 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -070013 * 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.
Pekka Paalanenb5026542014-11-12 15:09:24 +020025 */
26
27#ifndef WESTON_TIMELINE_H
28#define WESTON_TIMELINE_H
29
Marius Vladfb10ed72019-09-05 14:20:43 +030030#include <wayland-util.h>
31#include <stdbool.h>
32
33#include <libweston/weston-log.h>
34#include <wayland-server-core.h>
35
Pekka Paalanenb5026542014-11-12 15:09:24 +020036enum timeline_type {
37 TLT_END = 0,
38 TLT_OUTPUT,
39 TLT_SURFACE,
40 TLT_VBLANK,
Alexandros Frantzis75d38ef2017-09-27 15:09:13 +030041 TLT_GPU,
Pekka Paalanenb5026542014-11-12 15:09:24 +020042};
43
Marius Vlad23d01c62019-09-05 17:56:12 +030044/** Timeline subscription created for each subscription
45 *
46 * Created automatically by weston_log_scope::new_subscription and
47 * destroyed by weston_log_scope::destroy_subscription.
48 *
49 * @ingroup internal-log
50 */
Marius Vladfb10ed72019-09-05 14:20:43 +030051struct weston_timeline_subscription {
52 unsigned int next_id;
53 struct wl_list objects; /**< weston_timeline_subscription_object::subscription_link */
54};
55
56/**
57 * Created when object is first seen for a particular timeline subscription
58 * Destroyed when the subscription got destroyed or object was destroyed
Marius Vlad23d01c62019-09-05 17:56:12 +030059 *
60 * @ingroup internal-log
Marius Vladfb10ed72019-09-05 14:20:43 +030061 */
62struct weston_timeline_subscription_object {
63 void *object; /**< points to the object */
64 unsigned int id;
65 bool force_refresh;
66 struct wl_list subscription_link; /**< weston_timeline_subscription::objects */
67 struct wl_listener destroy_listener;
68};
69
Marius Vlad2a1b7862019-09-05 13:12:18 +030070#define TYPEVERIFY(type, arg) ({ \
Pekka Paalanenb5026542014-11-12 15:09:24 +020071 typeof(arg) tmp___ = (arg); \
72 (void)((type)0 == tmp___); \
73 tmp___; })
74
Marius Vlad23d01c62019-09-05 17:56:12 +030075/**
76 * Should be used as the last argument when using TL_POINT macro
77 *
78 * @ingroup log
79 */
Pekka Paalanenb5026542014-11-12 15:09:24 +020080#define TLP_END TLT_END, NULL
Marius Vlad23d01c62019-09-05 17:56:12 +030081
Pekka Paalanenb5026542014-11-12 15:09:24 +020082#define TLP_OUTPUT(o) TLT_OUTPUT, TYPEVERIFY(struct weston_output *, (o))
83#define TLP_SURFACE(s) TLT_SURFACE, TYPEVERIFY(struct weston_surface *, (s))
84#define TLP_VBLANK(t) TLT_VBLANK, TYPEVERIFY(const struct timespec *, (t))
Alexandros Frantzis75d38ef2017-09-27 15:09:13 +030085#define TLP_GPU(t) TLT_GPU, TYPEVERIFY(const struct timespec *, (t))
Pekka Paalanenb5026542014-11-12 15:09:24 +020086
Marius Vlad23d01c62019-09-05 17:56:12 +030087/** This macro is used to add timeline points.
88 *
89 * Use TLP_END when done for the vargs.
90 *
91 * @param ec weston_compositor instance
92 *
93 * @ingroup log
94 */
Marius Vlad3203ff62019-09-05 14:56:12 +030095#define TL_POINT(ec, ...) do { \
96 weston_timeline_point(ec->timeline, __VA_ARGS__); \
Pekka Paalanenb5026542014-11-12 15:09:24 +020097} while (0)
98
99void
Marius Vlad3203ff62019-09-05 14:56:12 +0300100weston_timeline_point(struct weston_log_scope *timeline_scope,
101 const char *name, ...);
Pekka Paalanenb5026542014-11-12 15:09:24 +0200102
103#endif /* WESTON_TIMELINE_H */