mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Split View navigation functions.
This commit is contained in:
parent
5b8c8c5309
commit
d19b337573
@ -137,6 +137,7 @@
|
||||
<ClCompile Include="..\..\..\server\TracyUserData.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView_FindZone.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView_Navigation.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView_Utility.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyWeb.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
|
||||
|
@ -249,6 +249,9 @@
|
||||
<ClCompile Include="..\..\..\server\TracyView_Utility.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyView_Navigation.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||
|
@ -4915,13 +4915,6 @@ int View::DispatchGpuZoneLevel( const Vector<short_ptr<GpuEvent>>& vec, bool hov
|
||||
}
|
||||
}
|
||||
|
||||
static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift )
|
||||
{
|
||||
if( time < 0 ) return time;
|
||||
const auto t = time - begin;
|
||||
return time + t / 1000000000 * drift;
|
||||
}
|
||||
|
||||
template<typename Adapter, typename V>
|
||||
int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift )
|
||||
{
|
||||
@ -16847,133 +16840,6 @@ const char* View::GetPlotName( const PlotData* plot ) const
|
||||
}
|
||||
}
|
||||
|
||||
void View::ZoomToZone( const ZoneEvent& ev )
|
||||
{
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
if( end - ev.Start() <= 0 ) return;
|
||||
ZoomToRange( ev.Start(), end );
|
||||
}
|
||||
|
||||
void View::ZoomToZone( const GpuEvent& ev )
|
||||
{
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
if( end - ev.GpuStart() <= 0 ) return;
|
||||
auto ctx = GetZoneCtx( ev );
|
||||
if( !ctx )
|
||||
{
|
||||
ZoomToRange( ev.GpuStart(), end );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) );
|
||||
assert( td != ctx->threadData.end() );
|
||||
int64_t begin;
|
||||
if( td->second.timeline.is_magic() )
|
||||
{
|
||||
begin = ((Vector<GpuEvent>*)&td->second.timeline)->front().GpuStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
begin = td->second.timeline.front()->GpuStart();
|
||||
}
|
||||
const auto drift = GpuDrift( ctx );
|
||||
ZoomToRange( AdjustGpuTime( ev.GpuStart(), begin, drift ), AdjustGpuTime( end, begin, drift ) );
|
||||
}
|
||||
}
|
||||
|
||||
void View::ZoomToRange( int64_t start, int64_t end, bool pause )
|
||||
{
|
||||
if( start == end )
|
||||
{
|
||||
end = start + 1;
|
||||
}
|
||||
|
||||
if( pause )
|
||||
{
|
||||
m_viewMode = ViewMode::Paused;
|
||||
m_viewModeHeuristicTry = false;
|
||||
}
|
||||
m_highlightZoom.active = false;
|
||||
if( !m_playback.pause && m_playback.sync ) m_playback.pause = true;
|
||||
|
||||
m_zoomAnim.active = true;
|
||||
if( m_viewMode == ViewMode::LastRange )
|
||||
{
|
||||
const auto rangeCurr = m_vd.zvEnd - m_vd.zvStart;
|
||||
const auto rangeDest = end - start;
|
||||
m_zoomAnim.start0 = m_vd.zvStart;
|
||||
m_zoomAnim.start1 = m_vd.zvStart - ( rangeDest - rangeCurr );
|
||||
m_zoomAnim.end0 = m_vd.zvEnd;
|
||||
m_zoomAnim.end1 = m_vd.zvEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_zoomAnim.start0 = m_vd.zvStart;
|
||||
m_zoomAnim.start1 = start;
|
||||
m_zoomAnim.end0 = m_vd.zvEnd;
|
||||
m_zoomAnim.end1 = end;
|
||||
}
|
||||
m_zoomAnim.progress = 0;
|
||||
}
|
||||
|
||||
void View::ZoomToPrevFrame()
|
||||
{
|
||||
if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
{
|
||||
size_t frame;
|
||||
if( m_frames->continuous )
|
||||
{
|
||||
frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).first;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).second;
|
||||
}
|
||||
|
||||
if( frame > 0 )
|
||||
{
|
||||
frame--;
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
|
||||
ZoomToRange( fbegin, fend );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::ZoomToNextFrame()
|
||||
{
|
||||
int64_t start;
|
||||
if( m_zoomAnim.active )
|
||||
{
|
||||
start = m_zoomAnim.start1;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = m_vd.zvStart;
|
||||
}
|
||||
|
||||
size_t frame;
|
||||
if( start < m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
{
|
||||
frame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = (size_t)m_worker.GetFrameRange( *m_frames, start, start ).first + 1;
|
||||
}
|
||||
if( frame >= m_worker.GetFrameCount( *m_frames ) ) return;
|
||||
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
|
||||
ZoomToRange( fbegin, fend );
|
||||
}
|
||||
|
||||
void View::CenterAtTime( int64_t t )
|
||||
{
|
||||
const auto hr = std::max<uint64_t>( 1, ( m_vd.zvEnd - m_vd.zvStart ) / 2 );
|
||||
ZoomToRange( t - hr, t + hr );
|
||||
}
|
||||
|
||||
void View::ShowZoneInfo( const ZoneEvent& ev )
|
||||
{
|
||||
if( m_zoneInfoWindow && m_zoneInfoWindow != &ev )
|
||||
|
@ -380,6 +380,7 @@ private:
|
||||
|
||||
void AdjustThreadHeight( View::VisData& vis, int oldOffset, int& offset );
|
||||
void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty );
|
||||
static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift );
|
||||
|
||||
Worker m_worker;
|
||||
std::string m_filename, m_filenameStaging;
|
||||
|
133
server/TracyView_Navigation.cpp
Normal file
133
server/TracyView_Navigation.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
#include "TracyView.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
void View::ZoomToZone( const ZoneEvent& ev )
|
||||
{
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
if( end - ev.Start() <= 0 ) return;
|
||||
ZoomToRange( ev.Start(), end );
|
||||
}
|
||||
|
||||
void View::ZoomToZone( const GpuEvent& ev )
|
||||
{
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
if( end - ev.GpuStart() <= 0 ) return;
|
||||
auto ctx = GetZoneCtx( ev );
|
||||
if( !ctx )
|
||||
{
|
||||
ZoomToRange( ev.GpuStart(), end );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) );
|
||||
assert( td != ctx->threadData.end() );
|
||||
int64_t begin;
|
||||
if( td->second.timeline.is_magic() )
|
||||
{
|
||||
begin = ((Vector<GpuEvent>*)&td->second.timeline)->front().GpuStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
begin = td->second.timeline.front()->GpuStart();
|
||||
}
|
||||
const auto drift = GpuDrift( ctx );
|
||||
ZoomToRange( AdjustGpuTime( ev.GpuStart(), begin, drift ), AdjustGpuTime( end, begin, drift ) );
|
||||
}
|
||||
}
|
||||
|
||||
void View::ZoomToRange( int64_t start, int64_t end, bool pause )
|
||||
{
|
||||
if( start == end )
|
||||
{
|
||||
end = start + 1;
|
||||
}
|
||||
|
||||
if( pause )
|
||||
{
|
||||
m_viewMode = ViewMode::Paused;
|
||||
m_viewModeHeuristicTry = false;
|
||||
}
|
||||
m_highlightZoom.active = false;
|
||||
if( !m_playback.pause && m_playback.sync ) m_playback.pause = true;
|
||||
|
||||
m_zoomAnim.active = true;
|
||||
if( m_viewMode == ViewMode::LastRange )
|
||||
{
|
||||
const auto rangeCurr = m_vd.zvEnd - m_vd.zvStart;
|
||||
const auto rangeDest = end - start;
|
||||
m_zoomAnim.start0 = m_vd.zvStart;
|
||||
m_zoomAnim.start1 = m_vd.zvStart - ( rangeDest - rangeCurr );
|
||||
m_zoomAnim.end0 = m_vd.zvEnd;
|
||||
m_zoomAnim.end1 = m_vd.zvEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_zoomAnim.start0 = m_vd.zvStart;
|
||||
m_zoomAnim.start1 = start;
|
||||
m_zoomAnim.end0 = m_vd.zvEnd;
|
||||
m_zoomAnim.end1 = end;
|
||||
}
|
||||
m_zoomAnim.progress = 0;
|
||||
}
|
||||
|
||||
void View::ZoomToPrevFrame()
|
||||
{
|
||||
if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
{
|
||||
size_t frame;
|
||||
if( m_frames->continuous )
|
||||
{
|
||||
frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).first;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).second;
|
||||
}
|
||||
|
||||
if( frame > 0 )
|
||||
{
|
||||
frame--;
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
|
||||
ZoomToRange( fbegin, fend );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::ZoomToNextFrame()
|
||||
{
|
||||
int64_t start;
|
||||
if( m_zoomAnim.active )
|
||||
{
|
||||
start = m_zoomAnim.start1;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = m_vd.zvStart;
|
||||
}
|
||||
|
||||
size_t frame;
|
||||
if( start < m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
{
|
||||
frame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = (size_t)m_worker.GetFrameRange( *m_frames, start, start ).first + 1;
|
||||
}
|
||||
if( frame >= m_worker.GetFrameCount( *m_frames ) ) return;
|
||||
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
|
||||
ZoomToRange( fbegin, fend );
|
||||
}
|
||||
|
||||
void View::CenterAtTime( int64_t t )
|
||||
{
|
||||
const auto hr = std::max<uint64_t>( 1, ( m_vd.zvEnd - m_vd.zvStart ) / 2 );
|
||||
ZoomToRange( t - hr, t + hr );
|
||||
}
|
||||
|
||||
}
|
@ -718,4 +718,11 @@ const char* View::SourceSubstitution( const char* srcFile ) const
|
||||
return res.c_str();
|
||||
}
|
||||
|
||||
int64_t View::AdjustGpuTime( int64_t time, int64_t begin, int drift )
|
||||
{
|
||||
if( time < 0 ) return time;
|
||||
const auto t = time - begin;
|
||||
return time + t / 1000000000 * drift;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user