From a7cedddcef1531465a6f1a0a42395e26cdf0134b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 24 Mar 2020 18:10:56 +0100 Subject: [PATCH] Use clipper to render source view. --- server/TracySourceView.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 9f1b8df4..90dd22c5 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -74,15 +74,29 @@ void SourceView::Render() ImGui::BeginChild( "##sourceView", ImVec2( 0, 0 ), true ); if( m_font ) ImGui::PushFont( m_font ); const auto nw = ImGui::CalcTextSize( "123,345" ).x; - int lineNum = 1; - for( auto& line : m_lines ) + if( m_targetLine != 0 ) { - if( m_targetLine == lineNum ) + int lineNum = 1; + for( auto& line : m_lines ) { - m_targetLine = 0; - ImGui::SetScrollHereY(); + if( m_targetLine == lineNum ) + { + m_targetLine = 0; + ImGui::SetScrollHereY(); + } + RenderLine( line, lineNum++ ); + } + } + else + { + ImGuiListClipper clipper( m_lines.size() ); + while( clipper.Step() ) + { + for( auto i=clipper.DisplayStart; i