From 126a587aa3b8ea46c42f03e04fc2c47cfeb5c5c0 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 10 Apr 2020 23:07:52 +0200 Subject: [PATCH] Less code duplication. --- server/TracySourceView.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 03306704..97b464e2 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -687,20 +687,22 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_mapAddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), 0x000000FF | ( a << 24 ) ); + color = 0x000000FF | ( a << 24 ); } else if( ipPercent <= 1.f ) { const auto g = int( ( ipPercent - 0.5f ) * 511 ); - draw->AddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), 0xFF0000FF | ( g << 8 ) ); + color = 0xFF0000FF | ( g << 8 ); } else { - draw->AddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), 0xFF00FFFF ); + color = 0xFF00FFFF; } + draw->AddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), color ); } ImGui::PopClipRect(); @@ -938,20 +940,22 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_mapAddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), 0x000000FF | ( a << 24 ) ); + color = 0x000000FF | ( a << 24 ); } else if( ipPercent <= 1.f ) { const auto g = int( ( ipPercent - 0.5f ) * 511 ); - draw->AddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), 0xFF0000FF | ( g << 8 ) ); + color = 0xFF0000FF | ( g << 8 ); } else { - draw->AddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), 0xFF00FFFF ); + color = 0xFF00FFFF; } + draw->AddRectFilled( ImVec2( x14, ly ), ImVec2( x34, ly+3 ), color ); } }