[Bf-blender-cvs] [9099b5b93fc] profiler-editor: don't draw nodes that are out of range in the y direction

Jacques Lucke noreply at git.blender.org
Sun May 2 15:50:34 CEST 2021


Commit: 9099b5b93fc3498398a6a29ba688c361422e1928
Author: Jacques Lucke
Date:   Sun May 2 15:39:15 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rB9099b5b93fc3498398a6a29ba688c361422e1928

don't draw nodes that are out of range in the y direction

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

M	source/blender/depsgraph/intern/eval/deg_eval.cc
M	source/blender/editors/space_profiler/profiler_draw.cc
M	source/blender/editors/space_profiler/profiler_layout.cc

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

diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 183c11f1cfd..e3d5399b372 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -101,7 +101,7 @@ struct DepsgraphEvalState {
 
 void evaluate_node(const DepsgraphEvalState *state, OperationNode *operation_node)
 {
-  BLI_PROFILE_SCOPE_SUBTASK(__func__, &state->profile_task);
+  BLI_PROFILE_SCOPE_SUBTASK("Depsgraph Node", &state->profile_task);
 
   ::Depsgraph *depsgraph = reinterpret_cast<::Depsgraph *>(state->graph);
 
diff --git a/source/blender/editors/space_profiler/profiler_draw.cc b/source/blender/editors/space_profiler/profiler_draw.cc
index dbfc3a36ef8..0a505b62d38 100644
--- a/source/blender/editors/space_profiler/profiler_draw.cc
+++ b/source/blender/editors/space_profiler/profiler_draw.cc
@@ -82,8 +82,10 @@ class ProfilerDrawer {
                                              profiler_layout_->begin_time());
 
     float min_bottom_y = 0.0f;
-    for (ProfileNode *node : profiler_layout_->root_nodes().last()) {
-      min_bottom_y = std::min(min_bottom_y, node->bottom_y);
+    if (!profiler_layout_->root_nodes().is_empty()) {
+      for (ProfileNode *node : profiler_layout_->root_nodes().last()) {
+        min_bottom_y = std::min(min_bottom_y, node->bottom_y);
+      }
     }
 
     /* Giving a bit more space on the right side is convenient. */
@@ -105,6 +107,22 @@ class ProfilerDrawer {
 
   void find_nodes_to_draw(Span<ProfileNode *> nodes, Vector<ProfileNode *> &r_nodes)
   {
+    if (nodes.is_empty()) {
+      return;
+    }
+    const float top_y = this->node_y_to_region_y(nodes[0]->top_y);
+    if (top_y < 0) {
+      return;
+    }
+    float node_bottom_y = nodes[0]->bottom_y;
+    for (ProfileNode *node : nodes) {
+      node_bottom_y = std::min(node_bottom_y, node->bottom_y);
+    }
+    const float bottom_y = this->node_y_to_region_y(node_bottom_y);
+    if (bottom_y > region_->winy) {
+      return;
+    }
+
     const TimePoint left_time = this->x_to_time(0);
     const TimePoint right_time = this->x_to_time(region_->winx);
 
@@ -190,7 +208,7 @@ class ProfilerDrawer {
     const Color4f color = this->get_node_color(node);
     immUniformColor4fv(color);
 
-    const float top_y = this->node_y_to_y(node.top_y);
+    const float top_y = this->node_y_to_region_y(node.top_y);
     immRecti(pos, left_x, top_y, right_x, top_y - UI_UNIT_Y);
 
     immUnbindProgram();
@@ -208,7 +226,7 @@ class ProfilerDrawer {
   {
     const int x = std::max(0, left_x);
     const int width = std::max(1, std::min<int>(right_x, region_->winx) - x);
-    const float top_y = this->node_y_to_y(node.top_y);
+    const float top_y = this->node_y_to_region_y(node.top_y);
 
     uiBut *but = uiDefIconTextBut(ui_block,
                                   UI_BTYPE_BUT,
@@ -286,7 +304,7 @@ class ProfilerDrawer {
     return begin_time + ms_to_duration(ms_since_begin);
   }
 
-  float node_y_to_y(const float y) const
+  float node_y_to_region_y(const float y) const
   {
     return region_->winy + y * UI_UNIT_Y - region_->v2d.cur.ymax;
   }
diff --git a/source/blender/editors/space_profiler/profiler_layout.cc b/source/blender/editors/space_profiler/profiler_layout.cc
index bc5fcb4fac4..f2ec99330cb 100644
--- a/source/blender/editors/space_profiler/profiler_layout.cc
+++ b/source/blender/editors/space_profiler/profiler_layout.cc
@@ -16,6 +16,7 @@
 
 #include "profiler_layout.hh"
 
+#include "BLI_profile.hh"
 #include "BLI_set.hh"
 
 namespace blender::ed::profiler {
@@ -147,6 +148,8 @@ void ProfileNode::pack_added_children()
 
 void ProfilerLayout::add(const RecordedProfile &recorded_profile)
 {
+  BLI_PROFILE_SCOPE("Add to ProfilerLayout");
+
   /* Create new nodes for segments and add them to the id map. */
   auto init_node = [](const ProfileTaskBegin &task_begin, ProfileNode &node) {
     node.begin_time_ = task_begin.time;
@@ -242,6 +245,8 @@ void ProfilerLayout::add(const RecordedProfile &recorded_profile)
 
 void ProfilerLayout::update_y_positions()
 {
+  BLI_PROFILE_SCOPE(__func__);
+
   float top_y = 0.0f;
   for (Span<ProfileNode *> nodes : root_nodes_) {
     top_y = this->update_y_positions_of_nodes(nodes, top_y);



More information about the Bf-blender-cvs mailing list