From 865e8d850643c47031db33f436079a330a05da97 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 29 Jun 2018 15:14:20 +0200 Subject: [PATCH] Extract zone name getting functionality. --- server/TracyView.cpp | 63 ++++++++---------------------------------- server/TracyWorker.cpp | 30 ++++++++++++++++++++ server/TracyWorker.hpp | 5 ++++ 3 files changed, 47 insertions(+), 51 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 9889cd0e..80a3fd05 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -1244,7 +1244,6 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, while( it < zitend ) { auto& ev = **it; - auto& srcloc = m_worker.GetSourceLocation( ev.srcloc ); const auto color = GetZoneColor( ev ); const auto end = m_worker.GetZoneEnd( ev ); const auto zsz = std::max( ( end - ev.start ) * pxns, pxns * 0.5 ); @@ -1306,16 +1305,7 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, } else { - const char* zoneName; - if( srcloc.name.active ) - { - zoneName = m_worker.GetString( srcloc.name ); - } - else - { - zoneName = m_worker.GetString( srcloc.function ); - } - + const char* zoneName = m_worker.GetZoneName( ev ); int dmul = ev.text.active ? 2 : 1; bool migration = false; @@ -1514,7 +1504,6 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn while( it < zitend ) { auto& ev = **it; - auto& srcloc = m_worker.GetSourceLocation( ev.srcloc ); const auto color = GetZoneColor( ev ); auto end = m_worker.GetZoneEnd( ev ); if( end == std::numeric_limits::max() ) break; @@ -1589,7 +1578,7 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn if( d > maxdepth ) maxdepth = d; } - const char* zoneName = m_worker.GetString( srcloc.name ); + const char* zoneName = m_worker.GetZoneName( ev ); auto tsz = ImGui::CalcTextSize( zoneName ); const auto pr0 = ( start - m_zvStart ) * pxns; @@ -3054,7 +3043,7 @@ void View::DrawZoneInfoWindow() int idx = 0; DrawZoneTrace( &ev, zoneTrace, m_worker, [&idx, this] ( const ZoneEvent* v ) { const auto& srcloc = m_worker.GetSourceLocation( v->srcloc ); - const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function ); + const auto txt = m_worker.GetZoneName( *v, srcloc ); ImGui::PushID( idx++ ); auto sel = ImGui::Selectable( txt, false ); auto hover = ImGui::IsItemHovered(); @@ -3108,8 +3097,7 @@ void View::DrawZoneInfoWindow() for( size_t i=0; i( &ev, zoneTrace, m_worker, [&idx, this] ( const GpuEvent* v ) { const auto& srcloc = m_worker.GetSourceLocation( v->srcloc ); - const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function ); + const auto txt = m_worker.GetZoneName( *v, srcloc ); ImGui::PushID( idx++ ); auto sel = ImGui::Selectable( txt, false ); auto hover = ImGui::IsItemHovered(); @@ -3297,10 +3285,9 @@ void View::DrawGpuInfoWindow() for( size_t i=0; i Worker::GetMatchingSourceLocation( const char* query ) const { std::vector match; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 0c707b00..a713a280 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -180,6 +180,11 @@ public: const char* GetThreadString( uint64_t id ) const; const SourceLocation& GetSourceLocation( int32_t srcloc ) const; + const char* GetZoneName( const ZoneEvent& ev ) const; + const char* GetZoneName( const ZoneEvent& ev, const SourceLocation& srcloc ) const; + const char* GetZoneName( const GpuEvent& ev ) const; + const char* GetZoneName( const GpuEvent& ev, const SourceLocation& srcloc ) const; + std::vector GetMatchingSourceLocation( const char* query ) const; #ifndef TRACY_NO_STATISTICS