[mutter/gbsneto/profiling-for-real: 38/40] cogl/trace: Add helper to retrieve capture writer
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/profiling-for-real: 38/40] cogl/trace: Add helper to retrieve capture writer
- Date: Sun, 20 Sep 2020 22:07:39 +0000 (UTC)
commit 32c8529a8deef10809d95111e9c95fc0190c961d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Sep 2 14:56:39 2020 -0300
cogl/trace: Add helper to retrieve capture writer
This is, as of now, a strict operation. So much so that every
cogl_aquire_capture_writer() call *must* be paired with a
cogl_release_capture_writer() call.
Make the sysprof-capture dependency explicit as well, since now
we expose a Sysprof type on public API when tracing is enabled.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1428
cogl/cogl/cogl-trace.c | 40 ++++++++++++++++++++++++++++++++++++++--
cogl/cogl/cogl-trace.h | 15 +++++++++++++++
cogl/meson.build | 2 +-
3 files changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/cogl/cogl/cogl-trace.c b/cogl/cogl/cogl-trace.c
index ffe42edeb6..b9105a2690 100644
--- a/cogl/cogl/cogl-trace.c
+++ b/cogl/cogl/cogl-trace.c
@@ -22,8 +22,6 @@
#ifdef HAVE_TRACING
-#include <sysprof-capture.h>
-#include <sysprof-capture-writer.h>
#include <sysprof-clock.h>
#include <syscall.h>
#include <sys/types.h>
@@ -242,6 +240,33 @@ cogl_set_tracing_disabled_on_thread (GMainContext *main_context)
g_source_unref (source);
}
+/**
+ * cogl_acquire_capture_writer: (skip)
+ */
+SysprofCaptureWriter *
+cogl_acquire_capture_writer (void)
+{
+ CoglTraceContext *trace_context;
+
+ g_mutex_lock (&cogl_trace_mutex);
+ trace_context = cogl_trace_context;
+ sysprof_capture_writer_flush (trace_context->writer);
+
+ if (!trace_context)
+ return NULL;
+
+ return trace_context->writer;
+}
+
+/**
+ * cogl_release_capture_writer: (skip)
+ */
+void
+cogl_release_capture_writer (void)
+{
+ g_mutex_unlock (&cogl_trace_mutex);
+}
+
void
cogl_trace_end (CoglTraceHead *head)
{
@@ -300,4 +325,15 @@ cogl_set_tracing_disabled_on_thread (void *data)
fprintf (stderr, "Tracing not enabled");
}
+void *
+cogl_acquire_capture_writer (void)
+{
+ return NULL;
+}
+
+void
+cogl_release_capture_writer (void)
+{
+}
+
#endif /* HAVE_TRACING */
diff --git a/cogl/cogl/cogl-trace.h b/cogl/cogl/cogl-trace.h
index 1f0a5ec34b..6a1d0dab1b 100644
--- a/cogl/cogl/cogl-trace.h
+++ b/cogl/cogl/cogl-trace.h
@@ -28,6 +28,9 @@
#ifdef COGL_HAS_TRACING
+#include <sysprof-capture.h>
+#include <sysprof-capture-writer.h>
+
typedef struct _CoglTraceContext CoglTraceContext;
typedef struct _CoglTraceHead
@@ -56,6 +59,12 @@ cogl_set_tracing_enabled_on_thread (GMainContext *main_context,
COGL_EXPORT void
cogl_set_tracing_disabled_on_thread (GMainContext *main_context);
+COGL_EXPORT
+SysprofCaptureWriter * cogl_acquire_capture_writer (void);
+
+COGL_EXPORT
+void cogl_release_capture_writer (void);
+
static inline void
cogl_trace_begin (CoglTraceHead *head,
const char *name)
@@ -112,6 +121,12 @@ cogl_set_tracing_enabled_on_thread (void *data,
COGL_EXPORT void
cogl_set_tracing_disabled_on_thread (void *data);
+COGL_EXPORT
+void * cogl_acquire_capture_writer (void);
+
+COGL_EXPORT
+void cogl_release_capture_writer (void);
+
#endif /* COGL_HAS_TRACING */
#endif /* COGL_TRACE_H */
diff --git a/cogl/meson.build b/cogl/meson.build
index a3c61cfb7d..92fff05e25 100644
--- a/cogl/meson.build
+++ b/cogl/meson.build
@@ -30,7 +30,7 @@ cogl_pkg_private_deps = [
]
if have_profiler
- cogl_pkg_private_deps += [
+ cogl_pkg_deps += [
sysprof_dep,
]
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]