Skip to content

Commit 33e5e07

Browse files
committed
Extract calculation of jump separation.
1 parent 11ea081 commit 33e5e07

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

‎server/TracySourceView.cpp‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ static void PrintSourceFragment( const SourceContents& src, uint32_t srcline, in
228228
constexpr float JumpSeparationBase = 6;
229229
constexpr float JumpArrowBase = 9;
230230

231+
float SourceView::CalcJumpSeparation( float scale )
232+
{
233+
return round( JumpSeparationBase * scale );
234+
}
235+
236+
231237
SourceView::SourceView()
232238
: m_font( nullptr )
233239
, m_smallFont( nullptr )
@@ -2512,7 +2518,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
25122518
const auto maxAddr = m_asm[clipper.DisplayEnd-1].addr;
25132519
const auto mjl = m_maxJumpLevel;
25142520
const auto JumpArrow = JumpArrowBase * ts.y / 15;
2515-
const auto JumpSeparation = round( JumpSeparationBase * ts.y / 15 );
2521+
const auto JumpSeparation = CalcJumpSeparation( ts.y / 15 );
25162522

25172523
int i = -1;
25182524
for( auto& v : m_jumpTable )
@@ -3905,7 +3911,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
39053911
m_jumpOffset = xoff;
39063912

39073913
const auto JumpArrow = JumpArrowBase * ty / 15;
3908-
const auto JumpSeparation = round( JumpSeparationBase * ts.y / 15 );
3914+
const auto JumpSeparation = CalcJumpSeparation( ts.y / 15 );
39093915
ImGui::SameLine( 0, ty + JumpArrow + m_maxJumpLevel * JumpSeparation );
39103916
auto jit = m_jumpOut.find( line.addr );
39113917
if( jit != m_jumpOut.end() )

‎server/TracySourceView.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ class SourceView
205205
bool IsInContext( const Worker& worker, uint64_t addr ) const;
206206
const std::vector<uint64_t>* GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line, const Worker& worker );
207207

208+
tracy_force_inline float CalcJumpSeparation( float scale );
209+
208210
#ifndef TRACY_NO_FILESELECTOR
209211
void Save( const Worker& worker, size_t start = 0, size_t stop = std::numeric_limits<size_t>::max() );
210212
#endif

0 commit comments

Comments
 (0)