weston_10.0_aglcore: Add helper iterator to loop over debug scopes
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0001-libweston-weston-log-Add-an-iterator-for-going-over-.patch
1 From 82b05408e5ed8a8651a99b2dcc61a24c108d48f1 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Fri, 5 May 2023 11:33:40 +0300
4 Subject: [PATCH] libweston/weston-log: Add an iterator for going over scope
5  list
6
7 libweston users, with the weston-debug protocol doesn't have a way
8 to list the debug scopes. This adds an iterator function to browse
9 over the opaque weston_log_scope.
10
11 This also adds two helper functions to get the scope name and its
12 description.
13
14 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
15 ---
16  include/libweston/weston-log.h |  9 +++++++++
17  libweston/weston-log.c         | 36 ++++++++++++++++++++++++++++++++++
18  2 files changed, 45 insertions(+)
19
20 diff --git a/include/libweston/weston-log.h b/include/libweston/weston-log.h
21 index aeb7768bf..846cdb089 100644
22 --- a/include/libweston/weston-log.h
23 +++ b/include/libweston/weston-log.h
24 @@ -131,9 +131,18 @@ struct weston_log_subscription *
25  weston_log_subscription_iterate(struct weston_log_scope *scope,
26                                 struct weston_log_subscription *sub_iter);
27  
28 +struct weston_log_scope *
29 +weston_log_scopes_iterate(struct weston_compositor *compositor,
30 +                         struct weston_log_scope *nscope);
31  void
32  weston_log_flight_recorder_display_buffer(FILE *file);
33  
34 +const char *
35 +weston_log_scope_get_description(struct weston_log_scope *scope);
36 +
37 +const char *
38 +weston_log_scope_get_name(struct weston_log_scope *scope);
39 +
40  #ifdef  __cplusplus
41  }
42  #endif
43 diff --git a/libweston/weston-log.c b/libweston/weston-log.c
44 index 276fde267..957c30c56 100644
45 --- a/libweston/weston-log.c
46 +++ b/libweston/weston-log.c
47 @@ -1009,3 +1009,39 @@ weston_log_subscription_iterate(struct weston_log_scope *scope,
48  
49         return container_of(node, struct weston_log_subscription, source_link);
50  }
51 +
52 +WL_EXPORT struct weston_log_scope *
53 +weston_log_scopes_iterate(struct weston_compositor *compositor,
54 +                         struct weston_log_scope *nscope)
55 +{
56 +       struct weston_log_context *log_ctx = compositor->weston_log_ctx;
57 +       struct wl_list *list;
58 +       struct wl_list *node;
59 +
60 +       assert(log_ctx);
61 +
62 +       list = &log_ctx->scope_list;
63 +
64 +       if (nscope) {
65 +               node = nscope->compositor_link.next;
66 +       } else {
67 +               node = list->next;
68 +       }
69 +
70 +       if (node == list)
71 +               return NULL;
72 +
73 +       return container_of(node, struct weston_log_scope, compositor_link);
74 +}
75 +
76 +WL_EXPORT const char *
77 +weston_log_scope_get_name(struct weston_log_scope *scope)
78 +{
79 +       return scope->name;
80 +}
81 +
82 +WL_EXPORT const char *
83 +weston_log_scope_get_description(struct weston_log_scope *scope)
84 +{
85 +       return scope->desc;
86 +}
87 -- 
88 2.39.2
89