blob: 23c06bb220f845e9eb3c513f154037f9ce8379e9 [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 Paalaneneb5a95b2021-02-15 13:34:01 +020036#include "shared/helpers.h"
37
Pekka Paalanenb5026542014-11-12 15:09:24 +020038enum timeline_type {
39 TLT_END = 0,
40 TLT_OUTPUT,
41 TLT_SURFACE,
42 TLT_VBLANK,
Alexandros Frantzis75d38ef2017-09-27 15:09:13 +030043 TLT_GPU,
Pekka Paalanenb5026542014-11-12 15:09:24 +020044};
45
Marius Vlad23d01c62019-09-05 17:56:12 +030046/** Timeline subscription created for each subscription
47 *
48 * Created automatically by weston_log_scope::new_subscription and
49 * destroyed by weston_log_scope::destroy_subscription.
50 *
51 * @ingroup internal-log
52 */
Marius Vladfb10ed72019-09-05 14:20:43 +030053struct weston_timeline_subscription {
54 unsigned int next_id;
55 struct wl_list objects; /**< weston_timeline_subscription_object::subscription_link */
56};
57
58/**
59 * Created when object is first seen for a particular timeline subscription
60 * Destroyed when the subscription got destroyed or object was destroyed
Marius Vlad23d01c62019-09-05 17:56:12 +030061 *
62 * @ingroup internal-log
Marius Vladfb10ed72019-09-05 14:20:43 +030063 */
64struct weston_timeline_subscription_object {
65 void *object; /**< points to the object */
66 unsigned int id;
67 bool force_refresh;
68 struct wl_list subscription_link; /**< weston_timeline_subscription::objects */
69 struct wl_listener destroy_listener;
70};
71
Marius Vlad23d01c62019-09-05 17:56:12 +030072/**
73 * Should be used as the last argument when using TL_POINT macro
74 *
75 * @ingroup log
76 */
Pekka Paalanenb5026542014-11-12 15:09:24 +020077#define TLP_END TLT_END, NULL
Marius Vlad23d01c62019-09-05 17:56:12 +030078
Pekka Paalanenb5026542014-11-12 15:09:24 +020079#define TLP_OUTPUT(o) TLT_OUTPUT, TYPEVERIFY(struct weston_output *, (o))
80#define TLP_SURFACE(s) TLT_SURFACE, TYPEVERIFY(struct weston_surface *, (s))
81#define TLP_VBLANK(t) TLT_VBLANK, TYPEVERIFY(const struct timespec *, (t))
Alexandros Frantzis75d38ef2017-09-27 15:09:13 +030082#define TLP_GPU(t) TLT_GPU, TYPEVERIFY(const struct timespec *, (t))
Pekka Paalanenb5026542014-11-12 15:09:24 +020083
Marius Vlad23d01c62019-09-05 17:56:12 +030084/** This macro is used to add timeline points.
85 *
86 * Use TLP_END when done for the vargs.
87 *
88 * @param ec weston_compositor instance
89 *
90 * @ingroup log
91 */
Marius Vlad3203ff62019-09-05 14:56:12 +030092#define TL_POINT(ec, ...) do { \
93 weston_timeline_point(ec->timeline, __VA_ARGS__); \
Pekka Paalanenb5026542014-11-12 15:09:24 +020094} while (0)
95
96void
Marius Vlad3203ff62019-09-05 14:56:12 +030097weston_timeline_point(struct weston_log_scope *timeline_scope,
98 const char *name, ...);
Pekka Paalanenb5026542014-11-12 15:09:24 +020099
100#endif /* WESTON_TIMELINE_H */