From fd5ccc16d62708a67470326eba000c2874d48fe6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 28 Jul 2020 15:12:45 +0200 Subject: [PATCH] Extract find zone range data to a separate struct. --- server/TracyView.cpp | 48 ++++++++++++++++++++++---------------------- server/TracyView.hpp | 17 ++++++++++------ 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 08fc7cda..2052c9d2 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3077,10 +3077,10 @@ void View::DrawZones() draw->AddRect( ImVec2( wpos.x + px0, linepos.y ), ImVec2( wpos.x + px1, linepos.y + lineh ), 0x4488DD88 ); } - if( m_findZone.show && m_findZone.limitRange ) + if( m_findZone.show && m_findZone.range.active ) { - const auto px0 = ( m_findZone.rangeMin - m_vd.zvStart ) * pxns; - const auto px1 = std::max( px0 + std::max( 1.0, pxns * 0.5 ), ( m_findZone.rangeMax - m_vd.zvStart ) * pxns ); + const auto px0 = ( m_findZone.range.min - m_vd.zvStart ) * pxns; + const auto px1 = std::max( px0 + std::max( 1.0, pxns * 0.5 ), ( m_findZone.range.max - m_vd.zvStart ) * pxns ); draw->AddRectFilled( ImVec2( wpos.x + px0, linepos.y ), ImVec2( wpos.x + px1, linepos.y + lineh ), 0x1188DDDD ); draw->AddRect( ImVec2( wpos.x + px0, linepos.y ), ImVec2( wpos.x + px1, linepos.y + lineh ), 0x2288DDDD ); } @@ -8906,30 +8906,30 @@ void View::DrawFindZone() ImGui::SameLine(); ImGui::Checkbox( "Ignore case", &m_findZone.ignoreCase ); ImGui::SameLine(); - if( ImGui::Checkbox( "Limit range", &m_findZone.limitRange ) ) + if( ImGui::Checkbox( "Limit range", &m_findZone.range.active ) ) { m_findZone.ResetMatch(); - if( m_findZone.limitRange ) + if( m_findZone.range.active ) { - m_findZone.rangeMin = m_vd.zvStart; - m_findZone.rangeMax = m_vd.zvEnd; + m_findZone.range.min = m_vd.zvStart; + m_findZone.range.max = m_vd.zvEnd; } } - if( m_findZone.limitRange ) + if( m_findZone.range.active ) { ImGui::TextUnformatted( ICON_FA_LOCK ); ImGui::SameLine(); - TextFocused( "Zone time range:", TimeToStringExact( m_findZone.rangeMin ) ); + TextFocused( "Zone time range:", TimeToStringExact( m_findZone.range.min ) ); ImGui::SameLine(); - TextFocused( "-", TimeToStringExact( m_findZone.rangeMax ) ); + TextFocused( "-", TimeToStringExact( m_findZone.range.max ) ); ImGui::SameLine(); - ImGui::TextDisabled( "(%s)", TimeToString( m_findZone.rangeMax - m_findZone.rangeMin ) ); + ImGui::TextDisabled( "(%s)", TimeToString( m_findZone.range.max - m_findZone.range.min ) ); ImGui::SameLine(); if( ImGui::SmallButton( "Limit to view" ) ) { m_findZone.ResetMatch(); - m_findZone.rangeMin = m_vd.zvStart; - m_findZone.rangeMax = m_vd.zvEnd; + m_findZone.range.min = m_vd.zvStart; + m_findZone.range.max = m_vd.zvEnd; } } @@ -8941,8 +8941,8 @@ void View::DrawFindZone() if( !m_findZone.match.empty() ) { - const auto rangeMin = m_findZone.rangeMin; - const auto rangeMax = m_findZone.rangeMax; + const auto rangeMin = m_findZone.range.min; + const auto rangeMax = m_findZone.range.max; ImGui::Separator(); ImGui::BeginChild( "##findzone" ); @@ -9021,7 +9021,7 @@ void View::DrawFindZone() size_t i; if( m_findZone.runningTime ) { - if( m_findZone.limitRange ) + if( m_findZone.range.active ) { for( i=m_findZone.sortedNum; i 1 || m_findZone.limitRange ) + if( m_findZone.minBinVal > 1 || m_findZone.range.active ) { if( m_findZone.logTime ) { @@ -9556,7 +9556,7 @@ void View::DrawFindZone() } TextFocused( "Mode:", TimeToString( ( t0 + t1 ) / 2 ) ); } - if( !m_findZone.limitRange && m_findZone.sorted.size() > 1 ) + if( !m_findZone.range.active && m_findZone.sorted.size() > 1 ) { const auto sz = m_findZone.sorted.size(); const auto avg = m_findZone.average; @@ -10010,7 +10010,7 @@ void View::DrawFindZone() const auto hmax = std::max( m_findZone.highlight.start, m_findZone.highlight.end ); const auto groupBy = m_findZone.groupBy; const auto highlightActive = m_findZone.highlight.active; - const auto limitRange = m_findZone.limitRange; + const auto limitRange = m_findZone.range.active; FindZone::Group* group = nullptr; uint64_t lastGid = std::numeric_limits::max() - 1; auto zptr = zones.data() + m_findZone.processed; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 983e7ab1..94550a88 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -56,6 +56,12 @@ class View uint64_t count; }; + struct Range + { + int64_t min, max; + bool active = false; + }; + public: struct VisData { @@ -487,8 +493,7 @@ private: int minBinVal = 1; int64_t tmin, tmax; bool showZoneInFrames = false; - bool limitRange = false; - int64_t rangeMin, rangeMax; + Range range; struct { @@ -543,7 +548,7 @@ private: void ShowZone( int16_t srcloc, const char* name ) { show = true; - limitRange = false; + range.active = false; Reset(); match.emplace_back( srcloc ); strcpy( pattern, name ); @@ -553,9 +558,9 @@ private: { assert( limitMin <= limitMax ); show = true; - limitRange = true; - rangeMin = limitMin; - rangeMax = limitMax; + range.active = true; + range.min = limitMin; + range.max = limitMax; Reset(); match.emplace_back( srcloc ); strcpy( pattern, name );