cogl/trace: Don't enable/disable in idle callback if thread matches
This makes it possible to start profiling immediately on startup, during context/backend/display setup, as well as flush during tear down. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
This commit is contained in:
parent
1efb93e145
commit
5767d2f129
@ -204,13 +204,20 @@ set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
const char *filename)
|
||||
{
|
||||
TraceData *data;
|
||||
GSource *source;
|
||||
|
||||
data = g_new0 (TraceData, 1);
|
||||
data->fd = fd;
|
||||
data->group = group ? strdup (group) : NULL;
|
||||
data->filename = filename ? strdup (filename) : NULL;
|
||||
|
||||
if (main_context == g_main_context_get_thread_default ())
|
||||
{
|
||||
enable_tracing_idle_callback (data);
|
||||
trace_data_free (data);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSource *source;
|
||||
source = g_idle_source_new ();
|
||||
|
||||
g_source_set_callback (source,
|
||||
@ -220,6 +227,7 @@ set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
|
||||
g_source_attach (source, main_context);
|
||||
g_source_unref (source);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -241,6 +249,12 @@ cogl_set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
void
|
||||
cogl_set_tracing_disabled_on_thread (GMainContext *main_context)
|
||||
{
|
||||
if (g_main_context_get_thread_default () == main_context)
|
||||
{
|
||||
disable_tracing_idle_callback (NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
source = g_idle_source_new ();
|
||||
@ -249,6 +263,7 @@ cogl_set_tracing_disabled_on_thread (GMainContext *main_context)
|
||||
|
||||
g_source_attach (source, main_context);
|
||||
g_source_unref (source);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user