From 3d6e85db4a070cf2d44800b970f73848f2551ef8 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 23 Sep 2017 15:39:39 +0200 Subject: [PATCH] Take children into account when determining zone end. --- server/TracyView.cpp | 9 ++++++++- server/TracyView.hpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 8b1ba34c..ca443ed5 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -435,6 +435,13 @@ uint64_t View::GetLastTime() const return last; } +uint64_t View::GetZoneEnd( const Event& ev ) const +{ + if( ev.end != -1 ) return ev.end; + if( ev.child.empty() ) return ev.start; + return GetZoneEnd( *ev.child.back() ); +} + const char* View::TimeToString( uint64_t ns ) const { enum { Pool = 4 }; @@ -901,7 +908,7 @@ void View::DrawZones() auto& ev = **it; const auto& srcFile = m_srcFile[ev.srcloc]; const char* func = GetString( srcFile.function ); - const auto end = ev.end != -1 ? ev.end : ev.start; + const auto end = GetZoneEnd( ev ); const auto zsz = ( ev.end - ev.start ) * pxns; const auto tsz = ImGui::CalcTextSize( func ); draw->AddRectFilled( wpos + ImVec2( ( ev.start - m_zvStart ) * pxns, offset ), wpos + ImVec2( ( end - m_zvStart ) * pxns, offset + tsz.y ), 0xDDDD6666, 2.f ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 5867ba71..4bedbddf 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -61,6 +61,7 @@ private: uint64_t GetFrameBegin( size_t idx ) const; uint64_t GetFrameEnd( size_t idx ) const; uint64_t GetLastTime() const; + uint64_t GetZoneEnd( const Event& ev ) const; const char* TimeToString( uint64_t ns ) const; const char* GetString( uint64_t ptr ) const; const char* GetThreadString( uint64_t id ) const;