[Bf-blender-cvs] [7b8adb7d89a] profiler-editor: redraw profiler when profiling

Jacques Lucke noreply at git.blender.org
Thu Apr 29 11:30:48 CEST 2021


Commit: 7b8adb7d89aafec52d6887f247d41adcd678e604
Author: Jacques Lucke
Date:   Tue Apr 27 16:46:13 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rB7b8adb7d89aafec52d6887f247d41adcd678e604

redraw profiler when profiling

===================================================================

M	source/blender/blenlib/BLI_profile.h
M	source/blender/editors/space_profiler/profiler_draw.cc
M	source/blender/editors/space_profiler/space_profiler.cc
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/blenlib/BLI_profile.h b/source/blender/blenlib/BLI_profile.h
index 0631098aad0..5826c5c84da 100644
--- a/source/blender/blenlib/BLI_profile.h
+++ b/source/blender/blenlib/BLI_profile.h
@@ -28,6 +28,11 @@ typedef struct BLI_ProfileTask {
   uint64_t id;
 } BLI_ProfileTask;
 
+BLI_INLINE bool BLI_profile_is_enabled(void)
+{
+  return bli_profiling_is_enabled;
+}
+
 void _bli_profile_task_begin(BLI_ProfileTask *task, const char *name);
 void _bli_profile_task_begin_subtask(BLI_ProfileTask *task,
                                      const char *name,
diff --git a/source/blender/editors/space_profiler/profiler_draw.cc b/source/blender/editors/space_profiler/profiler_draw.cc
index ae40f963adf..7008a544d57 100644
--- a/source/blender/editors/space_profiler/profiler_draw.cc
+++ b/source/blender/editors/space_profiler/profiler_draw.cc
@@ -42,8 +42,8 @@ void draw_profiler(const bContext *C, ARegion *region)
   if (!runtime.profiler_layout) {
     runtime.profiler_layout = std::make_unique<ProfilerLayout>();
   }
+  profile::ProfileListener::flush_to_all();
   ProfilerLayout &profiler_layout = *runtime.profiler_layout;
-  std::cout << profiler_layout.root_nodes().size() << "\n";
 
   UI_ThemeClearColor(TH_BACK);
 }
diff --git a/source/blender/editors/space_profiler/space_profiler.cc b/source/blender/editors/space_profiler/space_profiler.cc
index 7e736b464ca..32d980ea5e2 100644
--- a/source/blender/editors/space_profiler/space_profiler.cc
+++ b/source/blender/editors/space_profiler/space_profiler.cc
@@ -96,8 +96,23 @@ static void profiler_main_region_draw(const bContext *C, ARegion *region)
   blender::ed::profiler::draw_profiler(C, region);
 }
 
-static void profiler_main_region_listener(const wmRegionListenerParams *UNUSED(params))
+static void profiler_main_region_listener(const wmRegionListenerParams *params)
 {
+  ARegion *region = params->region;
+  wmNotifier *wmn = params->notifier;
+
+  switch (wmn->category) {
+    case NC_SPACE: {
+      if (wmn->data == ND_SPACE_PROFILER) {
+        ED_region_tag_redraw(region);
+      }
+      break;
+    }
+    case NC_PROFILE: {
+      ED_region_tag_redraw(region);
+      break;
+    }
+  }
 }
 
 static void profiler_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 7070419af29..884ae6952fd 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -307,6 +307,7 @@ typedef struct wmNotifier {
 #define NC_LIGHTPROBE (25 << 24)
 /* Changes to asset data in the current .blend. */
 #define NC_ASSET (26 << 24)
+#define NC_PROFILE (27 << 24)
 
 /* data type, 256 entries is enough, it can overlap */
 #define NOTE_DATA 0x00FF0000
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 5dfbd393c14..dfd36850c00 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -44,6 +44,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
 #include "BLI_math.h"
+#include "BLI_profile.h"
 #include "BLI_timer.h"
 #include "BLI_utildefines.h"
 
@@ -434,12 +435,18 @@ void wm_event_do_notifiers(bContext *C)
 {
   /* Run the timer before assigning 'wm' in the unlikely case a timer loads a file, see T80028. */
   wm_event_execute_timers(C);
+  if (BLI_profile_is_enabled()) {
+    WM_main_add_notifier(NC_PROFILE, NULL);
+  }
 
   wmWindowManager *wm = CTX_wm_manager(C);
   if (wm == NULL) {
     return;
   }
 
+  BLI_ProfileTask profile_task;
+  BLI_profile_task_begin(&profile_task, __func__);
+
   /* Disable? - Keep for now since its used for window level notifiers. */
 #if 1
   /* Cache & catch WM level notifiers, such as frame change, scene/screen set. */
@@ -630,6 +637,8 @@ void wm_event_do_notifiers(bContext *C)
 
   /* Autorun warning */
   wm_test_autorun_warning(C);
+
+  BLI_profile_task_end(&profile_task);
 }
 
 static int wm_event_always_pass(const wmEvent *event)



More information about the Bf-blender-cvs mailing list