[mutter/gbsneto/charts: 3/4] Allow changing Clutter debug flags at runtime



commit 4987bda1fd92fae3ac830a925c8bc6b38b32c491
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Mar 21 11:49:04 2019 +0000

    Allow changing Clutter debug flags at runtime
    
    This way, we can literally pop up the Looking Glass and
    call:
    
     >>> Meta.add_clutter_debug_flags(Clutter.DebugFlag.FRAME_TIME, 0, 0)
    
    And measure specific actions or events on GNOME Shell.

 clutter/clutter/clutter-debug.h | 41 ---------------------------------
 clutter/clutter/clutter-main.c  | 30 ++++++++++++++++++++++++
 clutter/clutter/clutter-main.h  | 51 +++++++++++++++++++++++++++++++++++++++++
 src/core/util.c                 | 17 ++++++++++++++
 src/meta/util.h                 | 10 ++++++++
 5 files changed, 108 insertions(+), 41 deletions(-)
---
diff --git a/clutter/clutter/clutter-debug.h b/clutter/clutter/clutter-debug.h
index e32a04ba5..76b8505cb 100644
--- a/clutter/clutter/clutter-debug.h
+++ b/clutter/clutter/clutter-debug.h
@@ -6,47 +6,6 @@
 
 G_BEGIN_DECLS
 
-typedef enum
-{
-  CLUTTER_DEBUG_MISC                = 1 << 0,
-  CLUTTER_DEBUG_ACTOR               = 1 << 1,
-  CLUTTER_DEBUG_TEXTURE             = 1 << 2,
-  CLUTTER_DEBUG_EVENT               = 1 << 3,
-  CLUTTER_DEBUG_PAINT               = 1 << 4,
-  CLUTTER_DEBUG_PANGO               = 1 << 5,
-  CLUTTER_DEBUG_BACKEND             = 1 << 6,
-  CLUTTER_DEBUG_SCHEDULER           = 1 << 7,
-  CLUTTER_DEBUG_SCRIPT              = 1 << 8,
-  CLUTTER_DEBUG_SHADER              = 1 << 9,
-  CLUTTER_DEBUG_MULTISTAGE          = 1 << 10,
-  CLUTTER_DEBUG_ANIMATION           = 1 << 11,
-  CLUTTER_DEBUG_LAYOUT              = 1 << 12,
-  CLUTTER_DEBUG_PICK                = 1 << 13,
-  CLUTTER_DEBUG_EVENTLOOP           = 1 << 14,
-  CLUTTER_DEBUG_CLIPPING            = 1 << 15,
-  CLUTTER_DEBUG_OOB_TRANSFORMS      = 1 << 16,
-  CLUTTER_DEBUG_FRAME_TIME          = 1 << 17,
-} ClutterDebugFlag;
-
-typedef enum
-{
-  CLUTTER_DEBUG_NOP_PICKING         = 1 << 0,
-  CLUTTER_DEBUG_DUMP_PICK_BUFFERS   = 1 << 1
-} ClutterPickDebugFlag;
-
-typedef enum
-{
-  CLUTTER_DEBUG_DISABLE_SWAP_EVENTS     = 1 << 0,
-  CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS = 1 << 1,
-  CLUTTER_DEBUG_REDRAWS                 = 1 << 2,
-  CLUTTER_DEBUG_PAINT_VOLUMES           = 1 << 3,
-  CLUTTER_DEBUG_DISABLE_CULLING         = 1 << 4,
-  CLUTTER_DEBUG_DISABLE_OFFSCREEN_REDIRECT = 1 << 5,
-  CLUTTER_DEBUG_CONTINUOUS_REDRAW       = 1 << 6,
-  CLUTTER_DEBUG_PAINT_DEFORM_TILES      = 1 << 7,
-  CLUTTER_DEBUG_PAINT_DAMAGE_REGION     = 1 << 8,
-} ClutterDrawDebugFlag;
-
 #ifdef CLUTTER_ENABLE_DEBUG
 
 #define CLUTTER_HAS_DEBUG(type)         ((clutter_debug_flags & CLUTTER_DEBUG_##type) != FALSE)
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 259b53093..7616eaae0 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -3557,6 +3557,36 @@ clutter_check_windowing_backend (const char *backend_type)
   return FALSE;
 }
 
+/**
+ * clutter_add_debug_flags: (skip)
+ *
+ * Adds the debug flags passed to the list of debug flags.
+ */
+void
+clutter_add_debug_flags (ClutterDebugFlag     debug_flags,
+                         ClutterDrawDebugFlag draw_flags,
+                         ClutterPickDebugFlag pick_flags)
+{
+  clutter_debug_flags |= debug_flags;
+  clutter_paint_debug_flags |= draw_flags;
+  clutter_pick_debug_flags |= pick_flags;
+}
+
+/**
+ * clutter_remove_debug_flags: (skip)
+ *
+ * Removes the debug flags passed from the list of debug flags.
+ */
+void
+clutter_remove_debug_flags (ClutterDebugFlag     debug_flags,
+                            ClutterDrawDebugFlag draw_flags,
+                            ClutterPickDebugFlag pick_flags)
+{
+  clutter_debug_flags &= ~debug_flags;
+  clutter_paint_debug_flags &= ~draw_flags;
+  clutter_pick_debug_flags &= ~pick_flags;
+}
+
 void
 _clutter_set_sync_to_vblank (gboolean sync_to_vblank)
 {
diff --git a/clutter/clutter/clutter-main.h b/clutter/clutter/clutter-main.h
index 6bacc5410..e0f10c892 100644
--- a/clutter/clutter/clutter-main.h
+++ b/clutter/clutter/clutter-main.h
@@ -34,6 +34,48 @@
 
 G_BEGIN_DECLS
 
+
+typedef enum
+{
+  CLUTTER_DEBUG_MISC                = 1 << 0,
+  CLUTTER_DEBUG_ACTOR               = 1 << 1,
+  CLUTTER_DEBUG_TEXTURE             = 1 << 2,
+  CLUTTER_DEBUG_EVENT               = 1 << 3,
+  CLUTTER_DEBUG_PAINT               = 1 << 4,
+  CLUTTER_DEBUG_PANGO               = 1 << 5,
+  CLUTTER_DEBUG_BACKEND             = 1 << 6,
+  CLUTTER_DEBUG_SCHEDULER           = 1 << 7,
+  CLUTTER_DEBUG_SCRIPT              = 1 << 8,
+  CLUTTER_DEBUG_SHADER              = 1 << 9,
+  CLUTTER_DEBUG_MULTISTAGE          = 1 << 10,
+  CLUTTER_DEBUG_ANIMATION           = 1 << 11,
+  CLUTTER_DEBUG_LAYOUT              = 1 << 12,
+  CLUTTER_DEBUG_PICK                = 1 << 13,
+  CLUTTER_DEBUG_EVENTLOOP           = 1 << 14,
+  CLUTTER_DEBUG_CLIPPING            = 1 << 15,
+  CLUTTER_DEBUG_OOB_TRANSFORMS      = 1 << 16,
+  CLUTTER_DEBUG_FRAME_TIME          = 1 << 17,
+} ClutterDebugFlag;
+
+typedef enum
+{
+  CLUTTER_DEBUG_NOP_PICKING         = 1 << 0,
+  CLUTTER_DEBUG_DUMP_PICK_BUFFERS   = 1 << 1
+} ClutterPickDebugFlag;
+
+typedef enum
+{
+  CLUTTER_DEBUG_DISABLE_SWAP_EVENTS     = 1 << 0,
+  CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS = 1 << 1,
+  CLUTTER_DEBUG_REDRAWS                 = 1 << 2,
+  CLUTTER_DEBUG_PAINT_VOLUMES           = 1 << 3,
+  CLUTTER_DEBUG_DISABLE_CULLING         = 1 << 4,
+  CLUTTER_DEBUG_DISABLE_OFFSCREEN_REDIRECT = 1 << 5,
+  CLUTTER_DEBUG_CONTINUOUS_REDRAW       = 1 << 6,
+  CLUTTER_DEBUG_PAINT_DEFORM_TILES      = 1 << 7,
+  CLUTTER_DEBUG_PAINT_DAMAGE_REGION     = 1 << 8,
+} ClutterDrawDebugFlag;
+
 /**
  * CLUTTER_INIT_ERROR:
  *
@@ -174,6 +216,15 @@ guint                   clutter_get_default_frame_rate          (void);
 CLUTTER_EXPORT
 gboolean                clutter_check_windowing_backend         (const char *backend_type);
 
+CLUTTER_EXPORT
+void                    clutter_add_debug_flags                 (ClutterDebugFlag     debug_flags,
+                                                                 ClutterDrawDebugFlag draw_flags,
+                                                                 ClutterPickDebugFlag pick_flags);
+
+CLUTTER_EXPORT
+void                    clutter_remove_debug_flags              (ClutterDebugFlag     debug_flags,
+                                                                 ClutterDrawDebugFlag draw_flags,
+                                                                 ClutterPickDebugFlag pick_flags);
 
 G_END_DECLS
 
diff --git a/src/core/util.c b/src/core/util.c
index 57b73747d..6014fad11 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -1012,5 +1012,22 @@ meta_generate_random_id (GRand *rand,
   return id;
 }
 
+
+void
+meta_add_clutter_debug_flags (ClutterDebugFlag     debug_flags,
+                              ClutterDrawDebugFlag draw_flags,
+                              ClutterPickDebugFlag pick_flags)
+{
+  clutter_add_debug_flags (debug_flags, draw_flags, pick_flags);
+}
+
+void
+meta_remove_clutter_debug_flags (ClutterDebugFlag     debug_flags,
+                                 ClutterDrawDebugFlag draw_flags,
+                                 ClutterPickDebugFlag pick_flags)
+{
+  clutter_remove_debug_flags (debug_flags, draw_flags, pick_flags);
+}
+
 /* eof util.c */
 
diff --git a/src/meta/util.h b/src/meta/util.h
index 497cea99b..51b18aa8b 100644
--- a/src/meta/util.h
+++ b/src/meta/util.h
@@ -226,4 +226,14 @@ typedef enum
 META_EXPORT
 MetaLocaleDirection meta_get_locale_direction (void);
 
+META_EXPORT
+void meta_add_clutter_debug_flags (ClutterDebugFlag     debug_flags,
+                                   ClutterDrawDebugFlag draw_flags,
+                                   ClutterPickDebugFlag pick_flags);
+
+META_EXPORT
+void meta_remove_clutter_debug_flags (ClutterDebugFlag     debug_flags,
+                                      ClutterDrawDebugFlag draw_flags,
+                                      ClutterPickDebugFlag pick_flags);
+
 #endif /* META_UTIL_H */


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