From 785a30a68be681f7b2d25290324afd8ffd038fe1 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 2 Jun 2018 22:27:35 +0200 Subject: [PATCH] Implement going to next/previous frame. --- server/TracyView.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- server/TracyView.hpp | 2 ++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index cb71ca29..18f4cafe 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -338,7 +338,13 @@ bool View::DrawImpl() ImGui::SameLine(); if( ImGui::Button( "Compare" ) ) m_compare.show = true; ImGui::SameLine(); - ImGui::Text( "Frames: %-7" PRIu64 " Time span: %-10s View span: %-10s Zones: %-13s Queue delay: %s Timer resolution: %s", m_worker.GetFrameCount(), TimeToString( m_worker.GetLastTime() - m_worker.GetFrameBegin( 0 ) ), TimeToString( m_zvEnd - m_zvStart ), RealToString( m_worker.GetZoneCount(), true ), TimeToString( m_worker.GetDelay() ), TimeToString( m_worker.GetResolution() ) ); + if( ImGui::SmallButton( "<" ) ) ZoomToPrevFrame(); + ImGui::SameLine(); + ImGui::Text( "Frames: %" PRIu64, m_worker.GetFrameCount() ); + ImGui::SameLine(); + if( ImGui::SmallButton( ">" ) ) ZoomToNextFrame(); + ImGui::SameLine(); + ImGui::Text( "Time span: %-10s View span: %-10s Zones: %-13s Queue delay: %s Timer resolution: %s", TimeToString( m_worker.GetLastTime() - m_worker.GetFrameBegin( 0 ) ), TimeToString( m_zvEnd - m_zvStart ), RealToString( m_worker.GetZoneCount(), true ), TimeToString( m_worker.GetDelay() ), TimeToString( m_worker.GetResolution() ) ); DrawFrames(); DrawZones(); ImGui::End(); @@ -5294,6 +5300,41 @@ void View::ZoomToRange( int64_t start, int64_t end ) m_zoomAnim.lenMod = 10.0 / log10( diff ); } +void View::ZoomToPrevFrame() +{ + if( m_zvStart >= m_worker.GetFrameBegin( 0 ) ) + { + auto frame = m_worker.GetFrameRange( m_zvStart, m_zvStart ).first; + if( frame > 0 ) + { + frame--; + const auto fbegin = m_worker.GetFrameBegin( frame ); + const auto fend = m_worker.GetFrameEnd( frame ); + ZoomToRange( fbegin, fend ); + } + } +} + +void View::ZoomToNextFrame() +{ + int frame; + if( m_zvStart < m_worker.GetFrameBegin( 0 ) ) + { + frame = -1; + } + else + { + frame = m_worker.GetFrameRange( m_zvStart, m_zvStart ).first; + if( frame == -1 ) return; + } + frame++; + if( frame >= m_worker.GetFrameCount() ) return; + + const auto fbegin = m_worker.GetFrameBegin( frame ); + const auto fend = m_worker.GetFrameEnd( frame ); + ZoomToRange( fbegin, fend ); +} + void View::ShowZoneInfo( const ZoneEvent& ev ) { if( m_zoneInfoWindow ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 7405f2f5..392b5b1e 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -102,6 +102,8 @@ private: void ZoomToZone( const ZoneEvent& ev ); void ZoomToZone( const GpuEvent& ev ); void ZoomToRange( int64_t start, int64_t end ); + void ZoomToPrevFrame(); + void ZoomToNextFrame(); void ShowZoneInfo( const ZoneEvent& ev ); void ShowZoneInfo( const GpuEvent& ev, uint64_t thread );