From 33e5e076292ec6993ac52d58024c6bda87fc7684 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 19 Oct 2022 00:59:46 +0200 Subject: Extract calculation of jump separation. --- server/TracySourceView.cpp | 10 ++++++++-- server/TracySourceView.hpp | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 5e17aaff..bd774901 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -228,6 +228,12 @@ static void PrintSourceFragment( const SourceContents& src, uint32_t srcline, in constexpr float JumpSeparationBase = 6; constexpr float JumpArrowBase = 9; +float SourceView::CalcJumpSeparation( float scale ) +{ + return round( JumpSeparationBase * scale ); +} + + SourceView::SourceView() : m_font( nullptr ) , m_smallFont( nullptr ) @@ -2512,7 +2518,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker const auto maxAddr = m_asm[clipper.DisplayEnd-1].addr; const auto mjl = m_maxJumpLevel; const auto JumpArrow = JumpArrowBase * ts.y / 15; - const auto JumpSeparation = round( JumpSeparationBase * ts.y / 15 ); + const auto JumpSeparation = CalcJumpSeparation( ts.y / 15 ); int i = -1; for( auto& v : m_jumpTable ) @@ -3905,7 +3911,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr m_jumpOffset = xoff; const auto JumpArrow = JumpArrowBase * ty / 15; - const auto JumpSeparation = round( JumpSeparationBase * ts.y / 15 ); + const auto JumpSeparation = CalcJumpSeparation( ts.y / 15 ); ImGui::SameLine( 0, ty + JumpArrow + m_maxJumpLevel * JumpSeparation ); auto jit = m_jumpOut.find( line.addr ); if( jit != m_jumpOut.end() ) diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index f8f8e1cf..302bb425 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -205,6 +205,8 @@ private: bool IsInContext( const Worker& worker, uint64_t addr ) const; const std::vector* GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line, const Worker& worker ); + tracy_force_inline float CalcJumpSeparation( float scale ); + #ifndef TRACY_NO_FILESELECTOR void Save( const Worker& worker, size_t start = 0, size_t stop = std::numeric_limits::max() ); #endif -- cgit v1.2.3