mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
cogl/trace: Add way to add a description to trace
This is useful to pass more complex information, generated at runtime. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
This commit is contained in:
parent
dd40e35ab2
commit
b1ac1327cd
@ -251,8 +251,9 @@ cogl_set_tracing_disabled_on_thread (GMainContext *main_context)
|
||||
g_source_unref (source);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_trace_end (CoglTraceHead *head)
|
||||
static void
|
||||
cogl_trace_end_with_description (CoglTraceHead *head,
|
||||
const char *description)
|
||||
{
|
||||
SysprofTimeStamp end_time;
|
||||
CoglTraceContext *trace_context;
|
||||
@ -270,7 +271,7 @@ cogl_trace_end (CoglTraceHead *head)
|
||||
(uint64_t) end_time - head->begin_time,
|
||||
trace_thread_context->group,
|
||||
head->name,
|
||||
NULL))
|
||||
description))
|
||||
{
|
||||
/* XXX: g_main_context_get_thread_default() might be wrong, it probably
|
||||
* needs to store the GMainContext in CoglTraceThreadContext when creating
|
||||
@ -282,6 +283,20 @@ cogl_trace_end (CoglTraceHead *head)
|
||||
g_mutex_unlock (&cogl_trace_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_trace_end (CoglTraceHead *head)
|
||||
{
|
||||
cogl_trace_end_with_description (head, head->description);
|
||||
g_free (head->description);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_trace_describe (CoglTraceHead *head,
|
||||
const char *description)
|
||||
{
|
||||
head->description = g_strdup (description);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
|
@ -43,6 +43,7 @@ typedef struct _CoglTraceHead
|
||||
{
|
||||
uint64_t begin_time;
|
||||
const char *name;
|
||||
char *description;
|
||||
} CoglTraceHead;
|
||||
|
||||
COGL_EXPORT
|
||||
@ -76,6 +77,10 @@ cogl_trace_begin (CoglTraceHead *head,
|
||||
COGL_EXPORT void
|
||||
cogl_trace_end (CoglTraceHead *head);
|
||||
|
||||
COGL_EXPORT void
|
||||
cogl_trace_describe (CoglTraceHead *head,
|
||||
const char *description);
|
||||
|
||||
static inline void
|
||||
cogl_auto_trace_end_helper (CoglTraceHead **head)
|
||||
{
|
||||
@ -102,6 +107,10 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
|
||||
ScopedCoglTrace##Name = &CoglTrace##Name; \
|
||||
}
|
||||
|
||||
#define COGL_TRACE_DESCRIBE(Name, description)\
|
||||
if (g_private_get (&cogl_trace_thread_data)) \
|
||||
cogl_trace_describe (&CoglTrace##Name, description);
|
||||
|
||||
#else /* COGL_HAS_TRACING */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -109,6 +118,7 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
|
||||
#define COGL_TRACE_BEGIN(Name, name) (void) 0
|
||||
#define COGL_TRACE_END(Name) (void) 0
|
||||
#define COGL_TRACE_BEGIN_SCOPED(Name, name) (void) 0
|
||||
#define COGL_TRACE_DESCRIBE(Name, description) (void) 0
|
||||
|
||||
COGL_EXPORT void
|
||||
cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
||||
|
Loading…
Reference in New Issue
Block a user