weston-debug: Make it easier to separate weston_debug_stream

This way we can split easier weston_debug_stream into a separate file.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Marius Vlad 5 years ago
parent 7814f301d1
commit 8f329e25f7
  1. 53
      libweston/weston-debug.c
  2. 10
      libweston/weston-log-internal.h

@ -240,19 +240,52 @@ weston_log_subscription_remove(struct weston_log_subscription *sub)
sub->source = NULL; sub->source = NULL;
} }
/** Look-up the scope from the scope list stored in the log context, by
static struct weston_log_scope * * matching against the \c name.
get_scope(struct weston_log_context *log_ctx, const char *name) *
* @param log_ctx
* @param name the scope name, see weston_compositor_add_log_scope()
* @returns NULL if none found, or a pointer to a weston_log_scope
*
* @internal
*/
struct weston_log_scope *
weston_log_get_scope(struct weston_log_context *log_ctx, const char *name)
{ {
struct weston_log_scope *scope; struct weston_log_scope *scope;
wl_list_for_each(scope, &log_ctx->scope_list, compositor_link) wl_list_for_each(scope, &log_ctx->scope_list, compositor_link)
if (strcmp(name, scope->name) == 0) if (strcmp(name, scope->name) == 0)
return scope; return scope;
return NULL; return NULL;
} }
/** Wrapper to invoke the weston_log_scope_cb. Allows to call the begin_cb of
* a log scope.
*
* @internal
*/
void
weston_log_run_begin_cb(struct weston_log_scope *scope)
{
if (scope->begin_cb)
scope->begin_cb(scope, scope->user_data);
}
/** Advertise the log scope name and the log scope description
*
* This is only used by the weston-debug protocol!
*
* @internal
*/
void
weston_debug_protocol_advertise_scopes(struct weston_log_context *log_ctx,
struct wl_resource *res)
{
struct weston_log_scope *scope;
wl_list_for_each(scope, &log_ctx->scope_list, compositor_link)
weston_debug_v1_send_available(res, scope->name, scope->desc);
}
static void static void
stream_close_unlink(struct weston_debug_stream *stream) stream_close_unlink(struct weston_debug_stream *stream)
{ {
@ -379,7 +412,7 @@ stream_create(struct weston_log_context *log_ctx, const char *name,
sub = weston_log_subscription_create(&stream->base, name); sub = weston_log_subscription_create(&stream->base, name);
scope = get_scope(log_ctx, name); scope = weston_log_get_scope(log_ctx, name);
if (scope) { if (scope) {
weston_log_subscription_add(scope, sub); weston_log_subscription_add(scope, sub);
if (scope->begin_cb) if (scope->begin_cb)
@ -475,7 +508,6 @@ bind_weston_debug(struct wl_client *client,
void *data, uint32_t version, uint32_t id) void *data, uint32_t version, uint32_t id)
{ {
struct weston_log_context *log_ctx = data; struct weston_log_context *log_ctx = data;
struct weston_log_scope *scope;
struct wl_resource *resource; struct wl_resource *resource;
resource = wl_resource_create(client, resource = wl_resource_create(client,
@ -488,10 +520,7 @@ bind_weston_debug(struct wl_client *client,
wl_resource_set_implementation(resource, &weston_debug_impl, wl_resource_set_implementation(resource, &weston_debug_impl,
log_ctx, NULL); log_ctx, NULL);
wl_list_for_each(scope, &log_ctx->scope_list, compositor_link) { weston_debug_protocol_advertise_scopes(log_ctx, resource);
weston_debug_v1_send_available(resource, scope->name,
scope->desc);
}
} }
/** /**
@ -664,7 +693,7 @@ weston_compositor_add_log_scope(struct weston_log_context *log_ctx,
return NULL; return NULL;
} }
if (get_scope(log_ctx, name)){ if (weston_log_get_scope(log_ctx, name)){
weston_log("Error: debug scope named '%s' is already registered.\n", weston_log("Error: debug scope named '%s' is already registered.\n",
name); name);
return NULL; return NULL;

@ -77,4 +77,14 @@ weston_log_subscription_add(struct weston_log_scope *scope,
void void
weston_log_subscription_remove(struct weston_log_subscription *sub); weston_log_subscription_remove(struct weston_log_subscription *sub);
struct weston_log_scope *
weston_log_get_scope(struct weston_log_context *log_ctx, const char *name);
void
weston_log_run_begin_cb(struct weston_log_scope *scope);
void
weston_debug_protocol_advertise_scopes(struct weston_log_context *log_ctx,
struct wl_resource *res);
#endif /* WESTON_LOG_INTERNAL_H */ #endif /* WESTON_LOG_INTERNAL_H */

Loading…
Cancel
Save