[Bf-blender-cvs] [3bffd137422] profiler-editor: move drawer to class

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


Commit: 3bffd1374220ec3d37c2a60e3ac34a5e6836f3bf
Author: Jacques Lucke
Date:   Tue Apr 27 16:51:11 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rB3bffd1374220ec3d37c2a60e3ac34a5e6836f3bf

move drawer to class

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

M	source/blender/editors/space_profiler/profiler_draw.cc

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

diff --git a/source/blender/editors/space_profiler/profiler_draw.cc b/source/blender/editors/space_profiler/profiler_draw.cc
index 7008a544d57..6957461f129 100644
--- a/source/blender/editors/space_profiler/profiler_draw.cc
+++ b/source/blender/editors/space_profiler/profiler_draw.cc
@@ -34,18 +34,37 @@
 
 namespace blender::ed::profiler {
 
-void draw_profiler(const bContext *C, ARegion *region)
-{
-  SpaceProfiler *sprofiler = CTX_wm_space_profiler(C);
-  SpaceProfiler_Runtime &runtime = *sprofiler->runtime;
+class ProfilerDrawer {
+ private:
+  const bContext *C;
+  ARegion *region_;
+  SpaceProfiler *sprofiler_;
+  SpaceProfiler_Runtime *runtime_;
+  ProfilerLayout *profiler_layout_;
 
-  if (!runtime.profiler_layout) {
-    runtime.profiler_layout = std::make_unique<ProfilerLayout>();
+ public:
+  ProfilerDrawer(const bContext *C, ARegion *region) : C(C), region_(region)
+  {
+    sprofiler_ = CTX_wm_space_profiler(C);
+    runtime_ = sprofiler_->runtime;
+
+    if (!runtime_->profiler_layout) {
+      runtime_->profiler_layout = std::make_unique<ProfilerLayout>();
+    }
+    profile::ProfileListener::flush_to_all();
+    profiler_layout_ = runtime_->profiler_layout.get();
   }
-  profile::ProfileListener::flush_to_all();
-  ProfilerLayout &profiler_layout = *runtime.profiler_layout;
 
-  UI_ThemeClearColor(TH_BACK);
+  void draw()
+  {
+    UI_ThemeClearColor(TH_BACK);
+  }
+};
+
+void draw_profiler(const bContext *C, ARegion *region)
+{
+  ProfilerDrawer drawer{C, region};
+  drawer.draw();
 }
 
 }  // namespace blender::ed::profiler



More information about the Bf-blender-cvs mailing list