diff --git a/clutter/clutter/clutter-master-clock-default.c b/clutter/clutter/clutter-master-clock-default.c index 6ee78fa7a..8d50ab8f3 100644 --- a/clutter/clutter/clutter-master-clock-default.c +++ b/clutter/clutter/clutter-master-clock-default.c @@ -29,10 +29,10 @@ * of #ClutterMasterClock. */ -#include - #include "clutter-build-config.h" +#include + #include "clutter-master-clock.h" #include "clutter-master-clock-default.h" #include "clutter-debug.h" diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index a5d73e63f..07ba9dfae 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -78,7 +78,6 @@ #include "clutter-private.h" #include "cogl/cogl.h" -#include "cogl/cogl-trace.h" struct _ClutterStageQueueRedrawEntry { diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 530ac1306..f345313cf 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -47,8 +47,6 @@ #include "clutter-stage-private.h" #include "clutter-stage-view-private.h" -#include "cogl/cogl-trace.h" - #define MAX_STACK_RECTS 256 typedef struct _ClutterStageViewCoglPrivate diff --git a/cogl/cogl/cogl-defines.h.meson b/cogl/cogl/cogl-defines.h.meson index 6e144b29c..4c9535239 100644 --- a/cogl/cogl/cogl-defines.h.meson +++ b/cogl/cogl/cogl-defines.h.meson @@ -46,3 +46,5 @@ #mesondefine COGL_HAS_X11_SUPPORT #mesondefine COGL_HAS_XLIB #mesondefine COGL_HAS_XLIB_SUPPORT + +#mesondefine COGL_HAS_TRACING diff --git a/cogl/cogl/cogl-trace.c b/cogl/cogl/cogl-trace.c index 983b7d4bb..ffe42edeb 100644 --- a/cogl/cogl/cogl-trace.c +++ b/cogl/cogl/cogl-trace.c @@ -23,6 +23,8 @@ #ifdef HAVE_TRACING #include +#include +#include #include #include #include @@ -30,6 +32,18 @@ #define COGL_TRACE_OUTPUT_FILE "cogl-trace-sp-capture.syscap" #define BUFFER_LENGTH (4096 * 4) +struct _CoglTraceContext +{ + SysprofCaptureWriter *writer; +}; + +typedef struct _CoglTraceThreadContext +{ + int cpu_id; + GPid pid; + char *group; +} CoglTraceThreadContext; + typedef struct { int fd; @@ -228,6 +242,37 @@ cogl_set_tracing_disabled_on_thread (GMainContext *main_context) g_source_unref (source); } +void +cogl_trace_end (CoglTraceHead *head) +{ + SysprofTimeStamp end_time; + CoglTraceContext *trace_context; + CoglTraceThreadContext *trace_thread_context; + + end_time = g_get_monotonic_time () * 1000; + trace_context = cogl_trace_context; + trace_thread_context = g_private_get (&cogl_trace_thread_data); + + g_mutex_lock (&cogl_trace_mutex); + if (!sysprof_capture_writer_add_mark (trace_context->writer, + head->begin_time, + trace_thread_context->cpu_id, + trace_thread_context->pid, + (uint64_t) end_time - head->begin_time, + trace_thread_context->group, + head->name, + NULL)) + { + /* XXX: g_main_context_get_thread_default() might be wrong, it probably + * needs to store the GMainContext in CoglTraceThreadContext when creating + * and use it here. + */ + if (errno == EPIPE) + cogl_set_tracing_disabled_on_thread (g_main_context_get_thread_default ()); + } + g_mutex_unlock (&cogl_trace_mutex); +} + #else #include diff --git a/cogl/cogl/cogl-trace.h b/cogl/cogl/cogl-trace.h index e9c9edafc..0b1e7f0de 100644 --- a/cogl/cogl/cogl-trace.h +++ b/cogl/cogl/cogl-trace.h @@ -19,31 +19,20 @@ #ifndef COGL_TRACE_H #define COGL_TRACE_H -#include "cogl-config.h" - -#ifdef HAVE_TRACING - #include -#include -#include #include #include -typedef struct _CoglTraceContext -{ - SysprofCaptureWriter *writer; -} CoglTraceContext; +#include "cogl/cogl-defines.h" +#include "cogl/cogl-macros.h" -typedef struct _CoglTraceThreadContext -{ - int cpu_id; - GPid pid; - char *group; -} CoglTraceThreadContext; +#ifdef COGL_HAS_TRACING + +typedef struct _CoglTraceContext CoglTraceContext; typedef struct _CoglTraceHead { - SysprofTimeStamp begin_time; + uint64_t begin_time; const char *name; } CoglTraceHead; @@ -69,36 +58,8 @@ cogl_trace_begin (CoglTraceHead *head, head->name = name; } -static inline void -cogl_trace_end (CoglTraceHead *head) -{ - SysprofTimeStamp end_time; - CoglTraceContext *trace_context; - CoglTraceThreadContext *trace_thread_context; - - end_time = g_get_monotonic_time () * 1000; - trace_context = cogl_trace_context; - trace_thread_context = g_private_get (&cogl_trace_thread_data); - - g_mutex_lock (&cogl_trace_mutex); - if (!sysprof_capture_writer_add_mark (trace_context->writer, - head->begin_time, - trace_thread_context->cpu_id, - trace_thread_context->pid, - (uint64_t) end_time - head->begin_time, - trace_thread_context->group, - head->name, - NULL)) - { - /* XXX: g_main_context_get_thread_default() might be wrong, it probably - * needs to store the GMainContext in CoglTraceThreadContext when creating - * and use it here. - */ - if (errno == EPIPE) - cogl_set_tracing_disabled_on_thread (g_main_context_get_thread_default ()); - } - g_mutex_unlock (&cogl_trace_mutex); -} +void +cogl_trace_end (CoglTraceHead *head); static inline void cogl_auto_trace_end_helper (CoglTraceHead **head) @@ -126,7 +87,7 @@ cogl_auto_trace_end_helper (CoglTraceHead **head) ScopedCoglTrace##Name = &CoglTrace##Name; \ } -#else /* HAVE_TRACING */ +#else /* COGL_HAS_TRACING */ #include @@ -142,6 +103,6 @@ void cogl_set_tracing_enabled_on_thread (void *data, const char *filename); void cogl_set_tracing_disabled_on_thread (void *data); -#endif /* HAVE_TRACING */ +#endif /* COGL_HAS_TRACING */ #endif /* COGL_TRACE_H */ diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index a71d09fbf..64ba6d25b 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -121,6 +121,7 @@ #include #include #include +#include /* XXX: This will definitly go away once all the Clutter winsys * code has been migrated down into Cogl! */ #include diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index be93ba2f9..4fedf352f 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -12,6 +12,7 @@ cdata.set('COGL_HAS_X11', have_x11) cdata.set('COGL_HAS_X11_SUPPORT', have_x11) cdata.set('COGL_HAS_XLIB', have_x11) cdata.set('COGL_HAS_XLIB_SUPPORT', have_x11) +cdata.set('COGL_HAS_TRACING', have_profiler) cogl_defines_h = configure_file( input: 'cogl-defines.h.meson', @@ -89,6 +90,7 @@ cogl_headers = [ 'cogl-texture-2d.h', 'cogl-texture-2d-sliced.h', 'cogl-types.h', + 'cogl-trace.h', 'cogl.h', ] @@ -288,7 +290,6 @@ cogl_sources = [ 'cogl-blend-string.h', 'cogl-debug.c', 'cogl-trace.c', - 'cogl-trace.h', 'cogl-sub-texture-private.h', 'cogl-texture-private.h', 'cogl-texture-2d-private.h', diff --git a/src/backends/meta-profiler.c b/src/backends/meta-profiler.c index 0d6270162..43e49aa38 100644 --- a/src/backends/meta-profiler.c +++ b/src/backends/meta-profiler.c @@ -25,7 +25,7 @@ #include #include -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #define META_SYSPROF_PROFILER_DBUS_PATH "/org/gnome/Sysprof3/Profiler" diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index 77f1ed2c8..6c4a474e2 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -59,7 +59,7 @@ #include "backends/native/meta-renderer-native.h" #include "backends/native/meta-seat-native.h" #include "backends/native/meta-stage-native.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "core/meta-border.h" #include "meta/main.h" diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c index e542d6257..f48ce9abd 100644 --- a/src/backends/native/meta-kms.c +++ b/src/backends/native/meta-kms.c @@ -27,7 +27,7 @@ #include "backends/native/meta-kms-impl-simple.h" #include "backends/native/meta-kms-update-private.h" #include "backends/native/meta-udev.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" /** * SECTION:kms diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 1ebc761eb..d1d713040 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -69,9 +69,8 @@ #include "backends/native/meta-output-kms.h" #include "backends/native/meta-renderer-native-gles3.h" #include "backends/native/meta-renderer-native.h" +//#include "cogl/cogl-framebuffer.h" #include "cogl/cogl.h" -#include "cogl/cogl-framebuffer.h" -#include "cogl/cogl-trace.h" #include "core/boxes-private.h" #ifndef EGL_DRM_MASTER_FD_EXT diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index f19f03be9..111965797 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -61,7 +61,7 @@ #include "backends/x11/meta-event-x11.h" #include "backends/x11/meta-stage-x11.h" #include "clutter/clutter-mutter.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "compositor/meta-window-actor-x11.h" #include "compositor/meta-window-actor-wayland.h" #include "compositor/meta-window-actor-private.h" diff --git a/src/core/display.c b/src/core/display.c index 6377ed697..0917f4693 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -54,7 +54,7 @@ #include "clutter/x11/clutter-x11.h" #include "compositor/compositor-private.h" #include "compositor/meta-compositor-x11.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "core/bell.h" #include "core/boxes-private.h" #include "core/display-private.h" diff --git a/src/core/stack.c b/src/core/stack.c index 6518be9b3..f7e0f1b90 100644 --- a/src/core/stack.c +++ b/src/core/stack.c @@ -30,7 +30,7 @@ #include "core/stack.h" #include "backends/meta-logical-monitor.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "core/frame.h" #include "core/main-private.h" #include "core/meta-workspace-manager-private.h" diff --git a/src/core/util.c b/src/core/util.c index accd74654..3854b3737 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -39,7 +39,7 @@ #include /* Just for the definition of the various gravities */ #include "clutter/clutter.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "meta/common.h" #include "meta/main.h" @@ -769,7 +769,7 @@ destroy_later (MetaLater *later) unref_later (later); } -#ifdef HAVE_TRACING +#ifdef COGL_HAS_TRACING static const char * later_type_to_string (MetaLaterType when) { diff --git a/src/core/window.c b/src/core/window.c index 06988dd1b..3356fc790 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -67,7 +67,7 @@ #include "backends/meta-backend-private.h" #include "backends/meta-logical-monitor.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "core/boxes-private.h" #include "core/constraints.h" #include "core/edge-resistance.h" diff --git a/src/core/workspace.c b/src/core/workspace.c index 59a502df1..6125481a1 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -40,7 +40,7 @@ #include "backends/meta-backend-private.h" #include "backends/meta-logical-monitor.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "core/boxes-private.h" #include "core/meta-workspace-manager-private.h" #include "core/workspace-private.h" diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 58beea61c..f7cdb0171 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -30,8 +30,8 @@ #include "backends/meta-cursor-tracker-private.h" #include "clutter/clutter.h" #include "clutter/wayland/clutter-wayland-compositor.h" -#include "cogl/cogl-trace.h" #include "cogl/cogl-wayland-server.h" +#include "cogl/cogl.h" #include "compositor/meta-surface-actor-wayland.h" #include "compositor/meta-surface-actor.h" #include "compositor/meta-window-actor-private.h" diff --git a/src/x11/events.c b/src/x11/events.c index 95cc714d0..f159f1db3 100644 --- a/src/x11/events.c +++ b/src/x11/events.c @@ -32,7 +32,7 @@ #include "backends/meta-cursor-tracker-private.h" #include "backends/x11/meta-backend-x11.h" #include "compositor/meta-compositor-x11.h" -#include "cogl/cogl-trace.h" +#include "cogl/cogl.h" #include "core/bell.h" #include "core/display-private.h" #include "core/meta-workspace-manager-private.h"