diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index d1b60fc0..2495a388 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -327,6 +327,7 @@ private: template int SkipGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); void DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint16_t tid ); + static const char* GetLockDisplayName( const Worker& worker, const LockMap& lockmap ); int DrawLocks( const TimelineContext& ctx, const std::vector>& lockDraw, uint64_t tid, int _offset, LockHighlight& highlight ); void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, const PlotItem& item, double prev, PlotType type, PlotValueFormatting format, float PlotHeight, uint64_t name ); void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, double val, PlotValueFormatting format, float PlotHeight ); diff --git a/profiler/src/profiler/TracyView_Locks.cpp b/profiler/src/profiler/TracyView_Locks.cpp index fb06a2b6..a2005f56 100644 --- a/profiler/src/profiler/TracyView_Locks.cpp +++ b/profiler/src/profiler/TracyView_Locks.cpp @@ -45,17 +45,16 @@ static bool SharedHoldEnded( const LockMap& lockmap, uint16_t slot, const LockSe return ev.thread == slot && ( LockEvent::Type )ev.type == LockEvent::Type::ReleaseShared; } +const char* View::GetLockDisplayName( const Worker& worker, const LockMap& lockmap ) +{ + if( lockmap.customName.Active() ) return worker.GetString( lockmap.customName ); + return worker.GetString( worker.GetSourceLocation( lockmap.srcloc ).function ); +} + void View::DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint16_t tid ) { char buf[1024]; - if( lockmap.customName.Active() ) - { - sprintf( buf, "%" PRIu32 ": %s", id, m_worker.GetString( lockmap.customName ) ); - } - else - { - sprintf( buf, "%" PRIu32 ": %s", id, m_worker.GetString( srcloc.function ) ); - } + sprintf( buf, "%" PRIu32 ": %s", id, GetLockDisplayName( m_worker, lockmap ) ); ImGui::PushFont( g_fonts.normal, FontSmall ); DrawTextContrast( draw, wpos + ImVec2( 0, offset ), 0xFF8888FF, buf ); ImGui::PopFont(); @@ -266,14 +265,7 @@ int View::DrawLocks( const TimelineContext& ctx, const std::vectorcustomName.Active() ) - { - sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( l.second->customName ) ); - } - else - { - sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) ); - } + sprintf( buf, "%" PRIu32 ": %s", l.first, GetLockDisplayName( m_worker, *l.second ) ); SmallCheckbox( buf, &Vis( l.second ) ); if( ImGui::IsItemHovered() ) { @@ -532,14 +525,7 @@ void View::DrawOptions() auto fileName = m_worker.GetString( sl.file ); char buf[1024]; - if( l.second->customName.Active() ) - { - sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( l.second->customName ) ); - } - else - { - sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) ); - } + sprintf( buf, "%" PRIu32 ": %s", l.first, GetLockDisplayName( m_worker, *l.second ) ); SmallCheckbox( buf, &Vis( l.second ) ); if( ImGui::IsItemHovered() ) { @@ -619,14 +605,7 @@ void View::DrawOptions() auto fileName = m_worker.GetString( sl.file ); char buf[1024]; - if( l.second->customName.Active() ) - { - sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( l.second->customName ) ); - } - else - { - sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) ); - } + sprintf( buf, "%" PRIu32 ": %s", l.first, GetLockDisplayName( m_worker, *l.second ) ); SmallCheckbox( buf, &Vis( l.second ) ); if( ImGui::IsItemHovered() ) {