From da36ddd1c69632c4c587df041ea7a340bfd5c47f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 18 Sep 2017 21:26:22 +0200 Subject: [PATCH] Refactor drawing frames. --- server/TracyView.cpp | 33 ++++++++++++++++++++------------- server/TracyView.hpp | 3 ++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index a1a423fd..b855e243 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -300,7 +300,20 @@ void View::UpdateZone( Event* zone ) assert( zone->end != -1 ); } -uint64_t View::GetLastTime() +uint64_t View::GetFrameTime( size_t idx ) const +{ + if( idx < m_frames.size() - 1 ) + { + return m_frames[idx+1] - m_frames[idx]; + } + else + { + const auto last = GetLastTime(); + return last == 0 ? 0 : last - m_frames.back(); + } +} + +uint64_t View::GetLastTime() const { uint64_t last = 0; if( !m_frames.empty() ) last = m_frames.back(); @@ -402,24 +415,17 @@ void View::DrawFrames() if( m_frameScale < 10 ) m_frameScale++; } } + const int fwidth = m_frameScale == 0 ? 4 : 1; //const int group = m_frameScale < 2 ? 1 : ( 1 << ( m_frameScale - 1 ) ); const int total = m_frames.size(); const int onScreen = ( w + fwidth-1 ) / fwidth; const int start = total < onScreen ? 0 : total - onScreen; - for( int i=0; i( MaxFrameTime, f ) ) / MaxFrameTime * ( Height - 2 ); if( fwidth != 1 ) { @@ -429,6 +435,7 @@ void View::DrawFrames() { draw->AddLine( wpos + ImVec2( 1+i, Height-2-h ), wpos + ImVec2( 1+i, Height-2 ), GetFrameColor( f ) ); } + i++; } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index d4a809a1..2032c55d 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -48,7 +48,8 @@ private: void NewZone( Event* zone ); void UpdateZone( Event* zone ); - uint64_t GetLastTime(); + uint64_t GetFrameTime( size_t idx ) const; + uint64_t GetLastTime() const; void DrawImpl(); void DrawFrames();