1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Use font helpers.

This commit is contained in:
Bartosz Taudul 2021-11-19 21:09:13 +01:00
parent e0a6c51a2f
commit d0d0aca758
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -956,7 +956,7 @@ void SourceView::RenderSimpleSourceView()
{ {
ImGui::SetNextWindowContentSize( ImVec2( m_srcWidth, 0 ) ); ImGui::SetNextWindowContentSize( ImVec2( m_srcWidth, 0 ) );
ImGui::BeginChild( "##sourceView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_HorizontalScrollbar ); ImGui::BeginChild( "##sourceView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_HorizontalScrollbar );
if( m_font ) ImGui::PushFont( m_font ); SetFont();
auto& lines = m_source.get(); auto& lines = m_source.get();
auto draw = ImGui::GetWindowDrawList(); auto draw = ImGui::GetWindowDrawList();
@ -999,7 +999,7 @@ void SourceView::RenderSimpleSourceView()
} }
} }
} }
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::EndChild(); ImGui::EndChild();
} }
@ -1778,7 +1778,7 @@ void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker,
const float bottom = m_srcSampleSelect.empty() ? 0 : ImGui::GetFrameHeight(); const float bottom = m_srcSampleSelect.empty() ? 0 : ImGui::GetFrameHeight();
ImGui::SetNextWindowContentSize( ImVec2( m_srcWidth, 0 ) ); ImGui::SetNextWindowContentSize( ImVec2( m_srcWidth, 0 ) );
ImGui::BeginChild( "##sourceView", ImVec2( 0, -bottom ), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_HorizontalScrollbar ); ImGui::BeginChild( "##sourceView", ImVec2( 0, -bottom ), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_HorizontalScrollbar );
if( m_font ) ImGui::PushFont( m_font ); SetFont();
auto& lines = m_source.get(); auto& lines = m_source.get();
auto draw = ImGui::GetWindowDrawList(); auto draw = ImGui::GetWindowDrawList();
@ -1913,7 +1913,7 @@ void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker,
ImGui::PopClipRect(); ImGui::PopClipRect();
} }
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::EndChild(); ImGui::EndChild();
if( !m_srcSampleSelect.empty() ) if( !m_srcSampleSelect.empty() )
@ -2166,7 +2166,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
const float bottom = m_asmSampleSelect.empty() ? 0 : ImGui::GetFrameHeight(); const float bottom = m_asmSampleSelect.empty() ? 0 : ImGui::GetFrameHeight();
ImGui::SetNextWindowContentSize( ImVec2( m_asmWidth, 0 ) ); ImGui::SetNextWindowContentSize( ImVec2( m_asmWidth, 0 ) );
ImGui::BeginChild( "##asmView", ImVec2( 0, -bottom ), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_HorizontalScrollbar ); ImGui::BeginChild( "##asmView", ImVec2( 0, -bottom ), true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_HorizontalScrollbar );
if( m_font ) ImGui::PushFont( m_font ); SetFont();
int maxAddrLen; int maxAddrLen;
{ {
@ -2259,7 +2259,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
if( ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos + ImVec2( xoff + JumpSeparation * ( mjl - v.second.level ) - JumpSeparation / 2, y0 + th2 ), wpos + ImVec2( xoff + JumpSeparation * ( mjl - v.second.level ) + JumpSeparation / 2, y1 + th2 ) ) ) if( ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos + ImVec2( xoff + JumpSeparation * ( mjl - v.second.level ) - JumpSeparation / 2, y0 + th2 ), wpos + ImVec2( xoff + JumpSeparation * ( mjl - v.second.level ) + JumpSeparation / 2, y1 + th2 ) ) )
{ {
thickness = 2; thickness = 2;
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
char tmp[32]; char tmp[32];
sprintf( tmp, "+%" PRIu64, v.first - m_baseAddr ); sprintf( tmp, "+%" PRIu64, v.first - m_baseAddr );
@ -2286,7 +2286,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
TextFocused( "Jump range:", MemSizeToString( v.second.max - v.second.min ) ); TextFocused( "Jump range:", MemSizeToString( v.second.max - v.second.min ) );
TextFocused( "Jump sources:", RealToString( v.second.source.size() ) ); TextFocused( "Jump sources:", RealToString( v.second.source.size() ) );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
if( ImGui::IsMouseClicked( 0 ) ) if( ImGui::IsMouseClicked( 0 ) )
{ {
m_targetAddr = v.first; m_targetAddr = v.first;
@ -2331,7 +2331,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
} }
#ifndef TRACY_NO_FILESELECTOR #ifndef TRACY_NO_FILESELECTOR
if( m_font ) ImGui::PopFont(); UnsetFont();
if( ImGui::BeginPopup( "jumpPopup" ) ) if( ImGui::BeginPopup( "jumpPopup" ) )
{ {
if( ImGui::Button( ICON_FA_FILE_IMPORT " Save jump range" ) ) if( ImGui::Button( ICON_FA_FILE_IMPORT " Save jump range" ) )
@ -2365,7 +2365,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
if( m_font ) ImGui::PushFont( m_font ); SetFont();
#endif #endif
} }
@ -2521,7 +2521,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
} }
} }
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::EndChild(); ImGui::EndChild();
if( !m_asmSampleSelect.empty() ) if( !m_asmSampleSelect.empty() )
@ -2698,11 +2698,11 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add
ImGui::ItemSize( ImVec2( 7 * ts.x, ts.y ) ); ImGui::ItemSize( ImVec2( 7 * ts.x, ts.y ) );
if( hasHwData && ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( ts.x * 7, ty ) ) ) if( hasHwData && ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( ts.x * 7, ty ) ) )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, true ); PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, true );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else
@ -2719,7 +2719,7 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add
} }
if( hover ) if( hover )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( ipcnt.local ) if( ipcnt.local )
{ {
@ -2740,7 +2740,7 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add
} }
if( hasHwData ) PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, false ); if( hasHwData ) PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, false );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
if( ImGui::IsMouseClicked( 0 ) ) if( ImGui::IsMouseClicked( 0 ) )
{ {
@ -2974,11 +2974,11 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
ImGui::ItemSize( ImVec2( 7 * ts.x, ts.y ) ); ImGui::ItemSize( ImVec2( 7 * ts.x, ts.y ) );
if( hw && ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( ts.x * 7, ty ) ) ) if( hw && ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( ts.x * 7, ty ) ) )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, true ); PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, true );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else
@ -3017,7 +3017,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
} }
} }
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( ipcnt.local ) if( ipcnt.local )
{ {
@ -3048,7 +3048,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
TextDisabledUnformatted( "(middle click to view)" ); TextDisabledUnformatted( "(middle click to view)" );
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
if( ImGui::IsMouseClicked( 0 ) ) if( ImGui::IsMouseClicked( 0 ) )
{ {
@ -3185,7 +3185,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
} }
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( m_asmCountBase >= 0 ) if( m_asmCountBase >= 0 )
{ {
@ -3209,7 +3209,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
ImGui::Text( "+%" PRIx64, line.addr - m_baseAddr ); ImGui::Text( "+%" PRIx64, line.addr - m_baseAddr );
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
if( ImGui::IsItemClicked( 0 ) ) if( ImGui::IsItemClicked( 0 ) )
{ {
@ -3249,7 +3249,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
lineHovered = true; lineHovered = true;
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( worker.HasInlineSymbolAddresses() ) if( worker.HasInlineSymbolAddresses() )
{ {
@ -3273,7 +3273,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
if( !m_sourceTooltip.empty() ) if( !m_sourceTooltip.empty() )
{ {
ImGui::Separator(); ImGui::Separator();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
auto& lines = m_sourceTooltip.get(); auto& lines = m_sourceTooltip.get();
const int start = std::max( 0, (int)srcline - 4 ); const int start = std::max( 0, (int)srcline - 4 );
const int end = std::min<int>( m_sourceTooltip.get().size(), srcline + 3 ); const int end = std::min<int>( m_sourceTooltip.get().size(), srcline + 3 );
@ -3318,11 +3318,11 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
ImGui::ItemSize( ImVec2( 0, 0 ), 0 ); ImGui::ItemSize( ImVec2( 0, 0 ), 0 );
} }
} }
if( m_font ) ImGui::PopFont(); UnsetFont();
} }
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
if( ImGui::IsItemClicked( 0 ) || ImGui::IsItemClicked( 1 ) ) if( ImGui::IsItemClicked( 0 ) || ImGui::IsItemClicked( 1 ) )
{ {
if( m_source.filename() == fileName ) if( m_source.filename() == fileName )
@ -3563,7 +3563,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
if( asmVar ) if( asmVar )
{ {
const auto& var = *asmVar; const auto& var = *asmVar;
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( jumpName || opdesc != 0 ) if( jumpName || opdesc != 0 )
{ {
@ -3688,11 +3688,11 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
} }
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
else if( jumpName ) else if( jumpName )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( jumpBase == m_baseAddr ) if( jumpBase == m_baseAddr )
{ {
@ -3705,13 +3705,13 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text( "%s+%" PRIu32, jumpName, jumpOffset ); ImGui::Text( "%s+%" PRIu32, jumpName, jumpOffset );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
if( m_cpuArch == CpuArchX86 || m_cpuArch == CpuArchX64 ) if( m_cpuArch == CpuArchX86 || m_cpuArch == CpuArchX64 )
{ {
if( line.readX86[0] != RegsX86::invalid || line.writeX86[0] != RegsX86::invalid ) if( line.readX86[0] != RegsX86::invalid || line.writeX86[0] != RegsX86::invalid )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( asmVar ) ImGui::Separator(); if( asmVar ) ImGui::Separator();
if( line.readX86[0] != RegsX86::invalid ) if( line.readX86[0] != RegsX86::invalid )
@ -3753,7 +3753,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
} }
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
if( ImGui::IsMouseClicked( 0 ) ) if( ImGui::IsMouseClicked( 0 ) )
@ -3904,7 +3904,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
} }
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::TextUnformatted( "Instructions Per Cycle (IPC)" ); ImGui::TextUnformatted( "Instructions Per Cycle (IPC)" );
ImGui::SameLine(); ImGui::SameLine();
@ -3914,7 +3914,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
TextFocused( "Retirements:", RealToString( retired ) ); TextFocused( "Retirements:", RealToString( retired ) );
if( unreliable ) TextColoredUnformatted( 0xFF4444FF, "Not enough samples for reliable data!" ); if( unreliable ) TextColoredUnformatted( 0xFF4444FF, "Not enough samples for reliable data!" );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else
@ -3951,7 +3951,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
} }
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::TextUnformatted( "Branch mispredictions impact" ); ImGui::TextUnformatted( "Branch mispredictions impact" );
ImGui::SameLine(); ImGui::SameLine();
@ -3960,7 +3960,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
TextFocused( "Impact value:", RealToString( branchRel ) ); TextFocused( "Impact value:", RealToString( branchRel ) );
TextFocused( "Relative to:", RealToString( branchRelMax ) ); TextFocused( "Relative to:", RealToString( branchRelMax ) );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else
@ -3995,7 +3995,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
} }
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::TextUnformatted( "Cache miss rate impact" ); ImGui::TextUnformatted( "Cache miss rate impact" );
ImGui::SameLine(); ImGui::SameLine();
@ -4004,7 +4004,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
TextFocused( "Impact value:", RealToString( cacheRel ) ); TextFocused( "Impact value:", RealToString( cacheRel ) );
TextFocused( "Relative to:", RealToString( cacheRelMax ) ); TextFocused( "Relative to:", RealToString( cacheRelMax ) );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else
@ -4046,7 +4046,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
} }
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::TextUnformatted( "Branch mispredictions rate" ); ImGui::TextUnformatted( "Branch mispredictions rate" );
ImGui::SameLine(); ImGui::SameLine();
@ -4056,7 +4056,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
TextFocused( "Branch mispredictions:", RealToString( branchMiss ) ); TextFocused( "Branch mispredictions:", RealToString( branchMiss ) );
if( unreliable ) TextColoredUnformatted( 0xFF4444FF, "Not enough samples for reliable data!" ); if( unreliable ) TextColoredUnformatted( 0xFF4444FF, "Not enough samples for reliable data!" );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else
@ -4096,7 +4096,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
} }
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
{ {
if( m_font ) ImGui::PopFont(); UnsetFont();
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::TextUnformatted( "Cache miss rate" ); ImGui::TextUnformatted( "Cache miss rate" );
ImGui::SameLine(); ImGui::SameLine();
@ -4106,7 +4106,7 @@ void SourceView::RenderHwLinePart( size_t cycles, size_t retired, size_t branchR
TextFocused( "Cache misses:", RealToString( cacheMiss ) ); TextFocused( "Cache misses:", RealToString( cacheMiss ) );
if( unreliable ) TextColoredUnformatted( 0xFF4444FF, "Not enough samples for reliable data!" ); if( unreliable ) TextColoredUnformatted( 0xFF4444FF, "Not enough samples for reliable data!" );
ImGui::EndTooltip(); ImGui::EndTooltip();
if( m_font ) ImGui::PushFont( m_font ); SetFont();
} }
} }
else else