Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014 Pekka Paalanen <pq@iki.fi> |
Marius Vlad | 2a1b786 | 2019-09-05 13:12:18 +0300 | [diff] [blame] | 3 | * Copyright © 2014, 2019 Collabora, Ltd. |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 4 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 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: |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 12 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 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. |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #ifndef WESTON_TIMELINE_H |
| 28 | #define WESTON_TIMELINE_H |
| 29 | |
Marius Vlad | fb10ed7 | 2019-09-05 14:20:43 +0300 | [diff] [blame] | 30 | #include <wayland-util.h> |
| 31 | #include <stdbool.h> |
| 32 | |
| 33 | #include <libweston/weston-log.h> |
| 34 | #include <wayland-server-core.h> |
| 35 | |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 36 | enum timeline_type { |
| 37 | TLT_END = 0, |
| 38 | TLT_OUTPUT, |
| 39 | TLT_SURFACE, |
| 40 | TLT_VBLANK, |
Alexandros Frantzis | 75d38ef | 2017-09-27 15:09:13 +0300 | [diff] [blame] | 41 | TLT_GPU, |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
Marius Vlad | 23d01c6 | 2019-09-05 17:56:12 +0300 | [diff] [blame^] | 44 | /** 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 Vlad | fb10ed7 | 2019-09-05 14:20:43 +0300 | [diff] [blame] | 51 | struct 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 Vlad | 23d01c6 | 2019-09-05 17:56:12 +0300 | [diff] [blame^] | 59 | * |
| 60 | * @ingroup internal-log |
Marius Vlad | fb10ed7 | 2019-09-05 14:20:43 +0300 | [diff] [blame] | 61 | */ |
| 62 | struct 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 Vlad | 2a1b786 | 2019-09-05 13:12:18 +0300 | [diff] [blame] | 70 | #define TYPEVERIFY(type, arg) ({ \ |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 71 | typeof(arg) tmp___ = (arg); \ |
| 72 | (void)((type)0 == tmp___); \ |
| 73 | tmp___; }) |
| 74 | |
Marius Vlad | 23d01c6 | 2019-09-05 17:56:12 +0300 | [diff] [blame^] | 75 | /** |
| 76 | * Should be used as the last argument when using TL_POINT macro |
| 77 | * |
| 78 | * @ingroup log |
| 79 | */ |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 80 | #define TLP_END TLT_END, NULL |
Marius Vlad | 23d01c6 | 2019-09-05 17:56:12 +0300 | [diff] [blame^] | 81 | |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 82 | #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 Frantzis | 75d38ef | 2017-09-27 15:09:13 +0300 | [diff] [blame] | 85 | #define TLP_GPU(t) TLT_GPU, TYPEVERIFY(const struct timespec *, (t)) |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 86 | |
Marius Vlad | 23d01c6 | 2019-09-05 17:56:12 +0300 | [diff] [blame^] | 87 | /** 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 Vlad | 3203ff6 | 2019-09-05 14:56:12 +0300 | [diff] [blame] | 95 | #define TL_POINT(ec, ...) do { \ |
| 96 | weston_timeline_point(ec->timeline, __VA_ARGS__); \ |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 97 | } while (0) |
| 98 | |
| 99 | void |
Marius Vlad | 3203ff6 | 2019-09-05 14:56:12 +0300 | [diff] [blame] | 100 | weston_timeline_point(struct weston_log_scope *timeline_scope, |
| 101 | const char *name, ...); |
Pekka Paalanen | b502654 | 2014-11-12 15:09:24 +0200 | [diff] [blame] | 102 | |
| 103 | #endif /* WESTON_TIMELINE_H */ |