[mutter/gbsneto/profiling-for-real: 161/162] meta/plugin: Add profiling vfuncs




commit fc7b30ab32b0c1f5109624ac9bc807873b05e5f1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Sep 2 16:02:51 2020 -0300

    meta/plugin: Add profiling vfuncs
    
    They depends on COGL_HAS_TRACING, which is already publicly exported
    in cogl/cogl-defines.h.

 src/compositor/meta-plugin-manager.c | 23 +++++++++++++++++++++++
 src/compositor/meta-plugin-manager.h |  7 +++++++
 src/meta/meta-plugin.h               | 22 ++++++++++++++++++++++
 3 files changed, 52 insertions(+)
---
diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c
index 47bf922db6..eee3ace943 100644
--- a/src/compositor/meta-plugin-manager.c
+++ b/src/compositor/meta-plugin-manager.c
@@ -417,3 +417,26 @@ meta_plugin_manager_locate_pointer (MetaPluginManager *plugin_mgr)
   if (klass->locate_pointer)
     klass->locate_pointer (plugin);
 }
+
+#ifdef COGL_HAS_TRACING
+void
+meta_plugin_manager_start_profiler (MetaPluginManager    *plugin_mgr,
+                                    SysprofCaptureWriter *writer)
+{
+  MetaPlugin *plugin = plugin_mgr->plugin;
+  MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
+
+  if (klass->start_profiler)
+    klass->start_profiler (plugin, writer);
+}
+
+void
+meta_plugin_manager_stop_profiler (MetaPluginManager *plugin_mgr)
+{
+  MetaPlugin *plugin = plugin_mgr->plugin;
+  MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
+
+  if (klass->stop_profiler)
+    klass->stop_profiler (plugin);
+}
+#endif
diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h
index d1c007fa19..0fd0d7703a 100644
--- a/src/compositor/meta-plugin-manager.h
+++ b/src/compositor/meta-plugin-manager.h
@@ -102,4 +102,11 @@ MetaInhibitShortcutsDialog *
 
 void meta_plugin_manager_locate_pointer (MetaPluginManager *mgr);
 
+#ifdef COGL_HAS_TRACING
+void meta_plugin_manager_start_profiler (MetaPluginManager    *plugin_mgr,
+                                         SysprofCaptureWriter *writer);
+
+void meta_plugin_manager_stop_profiler (MetaPluginManager *plugin_mgr);
+#endif
+
 #endif
diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h
index 1bc19a5f0e..98396bac39 100644
--- a/src/meta/meta-plugin.h
+++ b/src/meta/meta-plugin.h
@@ -26,12 +26,17 @@
 #include <gmodule.h>
 
 #include "clutter/clutter.h"
+#include "cogl/cogl-defines.h"
 #include "meta/compositor-mutter.h"
 #include "meta/compositor.h"
 #include "meta/meta-close-dialog.h"
 #include "meta/meta-inhibit-shortcuts-dialog.h"
 #include "meta/types.h"
 
+#ifdef COGL_HAS_TRACING
+#include <sysprof-capture.h>
+#endif
+
 #define META_TYPE_PLUGIN (meta_plugin_get_type ())
 
 META_EXPORT
@@ -247,6 +252,23 @@ struct _MetaPluginClass
    * on screen to draw user attention on the pointer location.
    */
   void (*locate_pointer) (MetaPlugin      *plugin);
+
+#ifdef COGL_HAS_TRACING
+  /**
+   * MetaPluginClass::start_profiler:
+   *
+   * Virtual function called when profiling starts.
+   */
+  void (*start_profiler) (MetaPlugin           *plugin,
+                          SysprofCaptureWriter *writer);
+
+  /**
+   * MetaPluginClass::stop_profiler:
+   *
+   * Virtual function called when profiling stops.
+   */
+  void (*stop_profiler)  (MetaPlugin *plugin);
+#endif
 };
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]