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);
|
g_source_unref (source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cogl_trace_end (CoglTraceHead *head)
|
cogl_trace_end_with_description (CoglTraceHead *head,
|
||||||
|
const char *description)
|
||||||
{
|
{
|
||||||
SysprofTimeStamp end_time;
|
SysprofTimeStamp end_time;
|
||||||
CoglTraceContext *trace_context;
|
CoglTraceContext *trace_context;
|
||||||
@ -270,7 +271,7 @@ cogl_trace_end (CoglTraceHead *head)
|
|||||||
(uint64_t) end_time - head->begin_time,
|
(uint64_t) end_time - head->begin_time,
|
||||||
trace_thread_context->group,
|
trace_thread_context->group,
|
||||||
head->name,
|
head->name,
|
||||||
NULL))
|
description))
|
||||||
{
|
{
|
||||||
/* XXX: g_main_context_get_thread_default() might be wrong, it probably
|
/* XXX: g_main_context_get_thread_default() might be wrong, it probably
|
||||||
* needs to store the GMainContext in CoglTraceThreadContext when creating
|
* needs to store the GMainContext in CoglTraceThreadContext when creating
|
||||||
@ -282,6 +283,20 @@ cogl_trace_end (CoglTraceHead *head)
|
|||||||
g_mutex_unlock (&cogl_trace_mutex);
|
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
|
#else
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -43,6 +43,7 @@ typedef struct _CoglTraceHead
|
|||||||
{
|
{
|
||||||
uint64_t begin_time;
|
uint64_t begin_time;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
char *description;
|
||||||
} CoglTraceHead;
|
} CoglTraceHead;
|
||||||
|
|
||||||
COGL_EXPORT
|
COGL_EXPORT
|
||||||
@ -76,6 +77,10 @@ cogl_trace_begin (CoglTraceHead *head,
|
|||||||
COGL_EXPORT void
|
COGL_EXPORT void
|
||||||
cogl_trace_end (CoglTraceHead *head);
|
cogl_trace_end (CoglTraceHead *head);
|
||||||
|
|
||||||
|
COGL_EXPORT void
|
||||||
|
cogl_trace_describe (CoglTraceHead *head,
|
||||||
|
const char *description);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
cogl_auto_trace_end_helper (CoglTraceHead **head)
|
cogl_auto_trace_end_helper (CoglTraceHead **head)
|
||||||
{
|
{
|
||||||
@ -102,6 +107,10 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
|
|||||||
ScopedCoglTrace##Name = &CoglTrace##Name; \
|
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 */
|
#else /* COGL_HAS_TRACING */
|
||||||
|
|
||||||
#include <stdio.h>
|
#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_BEGIN(Name, name) (void) 0
|
||||||
#define COGL_TRACE_END(Name) (void) 0
|
#define COGL_TRACE_END(Name) (void) 0
|
||||||
#define COGL_TRACE_BEGIN_SCOPED(Name, name) (void) 0
|
#define COGL_TRACE_BEGIN_SCOPED(Name, name) (void) 0
|
||||||
|
#define COGL_TRACE_DESCRIBE(Name, description) (void) 0
|
||||||
|
|
||||||
COGL_EXPORT void
|
COGL_EXPORT void
|
||||||
cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
||||||
|
Loading…
Reference in New Issue
Block a user