[sysprof] fps: discover gtk FPS counter and add visualizer row



commit 12f627a7bdec258e88cc84a659344406a1179fa8
Author: Christian Hergert <chergert redhat com>
Date:   Thu May 17 20:31:56 2018 +0100

    fps: discover gtk FPS counter and add visualizer row

 lib/visualizers/sp-visualizer-list.c |   36 +++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/lib/visualizers/sp-visualizer-list.c b/lib/visualizers/sp-visualizer-list.c
index 4ee6d32..b10946e 100644
--- a/lib/visualizers/sp-visualizer-list.c
+++ b/lib/visualizers/sp-visualizer-list.c
@@ -43,7 +43,8 @@ typedef struct
 {
   SpCaptureCursor *cursor;
   GHashTable *mark_groups;
-  gboolean has_cpu;
+  guint fps_counter;
+  guint has_cpu : 1;
 } Discovery;
 
 enum {
@@ -212,11 +213,20 @@ discover_new_rows_frame_cb (const SpCaptureFrame *frame,
         g_hash_table_add (state->mark_groups, g_strdup (mark->group));
     }
 
-  /* TODO: Make this look for CPU define. Currently it is the
-   *       only thing that uses it. So...
-   */
   if (frame->type == SP_CAPTURE_FRAME_CTRDEF)
-    state->has_cpu = TRUE;
+    {
+      const SpCaptureFrameCounterDefine *def = (const SpCaptureFrameCounterDefine *)frame;
+
+      for (guint i = 0; i < def->n_counters; i++)
+        {
+          const SpCaptureCounter *ctr = &def->counters[i];
+
+          if (strstr (ctr->category, "CPU Percent") != NULL)
+            state->has_cpu = TRUE;
+          else if (strstr (ctr->category, "gtk") != NULL && strstr (ctr->name, "fps") != NULL)
+            state->fps_counter = ctr->id;
+        }
+    }
 
   return TRUE;
 }
@@ -264,6 +274,22 @@ handle_capture_results (GObject      *object,
       gtk_container_add (GTK_CONTAINER (self), row);
     }
 
+  if (state->fps_counter)
+    {
+      GdkRGBA rgba;
+      GtkWidget *row = g_object_new (SP_TYPE_LINE_VISUALIZER_ROW,
+                                     "title", _("FPS"),
+                                     "height-request", 50,
+                                     "selectable", FALSE,
+                                     "visible", TRUE,
+                                     "y-lower", 0.0,
+                                     "y-upper", 150.0,
+                                     NULL);
+      gdk_rgba_parse (&rgba, "#204a87");
+      sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (row), state->fps_counter, &rgba);
+      gtk_container_add (GTK_CONTAINER (self), row);
+    }
+
   if (g_hash_table_size (state->mark_groups) < 30)
     {
       GHashTableIter iter;


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