1 /* 2 * Copyright © 2014 Pekka Paalanen <pq@iki.fi> 3 * Copyright © 2014, 2019 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 #include <wayland-util.h> 31 #include <stdbool.h> 32 33 #include <libweston/weston-log.h> 34 #include <wayland-server-core.h> 35 36 enum timeline_type { 37 TLT_END = 0, 38 TLT_OUTPUT, 39 TLT_SURFACE, 40 TLT_VBLANK, 41 TLT_GPU, 42 }; 43 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 */ 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 59 * 60 * @ingroup internal-log 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 70 #define TYPEVERIFY(type, arg) ({ \ 71 typeof(arg) tmp___ = (arg); \ 72 (void)((type)0 == tmp___); \ 73 tmp___; }) 74 75 /** 76 * Should be used as the last argument when using TL_POINT macro 77 * 78 * @ingroup log 79 */ 80 #define TLP_END TLT_END, NULL 81 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)) 85 #define TLP_GPU(t) TLT_GPU, TYPEVERIFY(const struct timespec *, (t)) 86 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 */ 95 #define TL_POINT(ec, ...) do { \ 96 weston_timeline_point(ec->timeline, __VA_ARGS__); \ 97 } while (0) 98 99 void 100 weston_timeline_point(struct weston_log_scope *timeline_scope, 101 const char *name, ...); 102 103 #endif /* WESTON_TIMELINE_H */ 104