mirror of
https://github.com/wolfpld/tracy
synced 2025-05-02 13:43:52 +00:00
Don't draw off-screen zones.
This commit is contained in:
parent
9fc14d2faf
commit
a2779eccaf
@ -1039,7 +1039,7 @@ void View::DrawZones()
|
||||
m_lastCpu = -1;
|
||||
if( m_drawZones )
|
||||
{
|
||||
const auto depth = DrawZoneLevel( v->timeline, hover, pxns, wpos, offset, 0 );
|
||||
const auto depth = DispatchZoneLevel( v->timeline, hover, pxns, wpos, offset, 0, yMin, yMax );
|
||||
offset += ostep * depth;
|
||||
}
|
||||
|
||||
@ -1111,7 +1111,24 @@ void View::DrawZones()
|
||||
}
|
||||
}
|
||||
|
||||
int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth )
|
||||
int View::DispatchZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax )
|
||||
{
|
||||
const auto ty = ImGui::GetFontSize();
|
||||
const auto ostep = ty + 1;
|
||||
const auto offset = _offset + ostep * depth;
|
||||
|
||||
const auto yPos = wpos.y + offset;
|
||||
if( yPos + ostep >= yMin && yPos <= yMax )
|
||||
{
|
||||
return DrawZoneLevel( vec, hover, pxns, wpos, _offset, depth, yMin, yMax );
|
||||
}
|
||||
else
|
||||
{
|
||||
return SkipZoneLevel( vec, hover, pxns, wpos, _offset, depth, yMin, yMax );
|
||||
}
|
||||
}
|
||||
|
||||
int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax )
|
||||
{
|
||||
const auto delay = m_worker.GetDelay();
|
||||
const auto resolution = m_worker.GetResolution();
|
||||
@ -1223,7 +1240,7 @@ int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
|
||||
|
||||
if( !ev.child.empty() )
|
||||
{
|
||||
const auto d = DrawZoneLevel( ev.child, hover, pxns, wpos, _offset, depth );
|
||||
const auto d = DispatchZoneLevel( ev.child, hover, pxns, wpos, _offset, depth, yMin, yMax );
|
||||
if( d > maxdepth ) maxdepth = d;
|
||||
}
|
||||
|
||||
@ -1307,6 +1324,59 @@ int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
int View::SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax )
|
||||
{
|
||||
const auto delay = m_worker.GetDelay();
|
||||
const auto resolution = m_worker.GetResolution();
|
||||
// cast to uint64_t, so that unended zones (end = -1) are still drawn
|
||||
auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - delay, [] ( const auto& l, const auto& r ) { return (uint64_t)l->end < (uint64_t)r; } );
|
||||
if( it == vec.end() ) return depth;
|
||||
|
||||
const auto zitend = std::lower_bound( it, vec.end(), m_zvEnd + resolution, [] ( const auto& l, const auto& r ) { return l->start < r; } );
|
||||
if( it == zitend ) return depth;
|
||||
|
||||
depth++;
|
||||
int maxdepth = depth;
|
||||
|
||||
while( it < zitend )
|
||||
{
|
||||
auto& ev = **it;
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
const auto zsz = std::max( ( end - ev.start ) * pxns, pxns * 0.5 );
|
||||
if( zsz < MinVisSize )
|
||||
{
|
||||
auto px1 = ( end - m_zvStart ) * pxns;
|
||||
for(;;)
|
||||
{
|
||||
++it;
|
||||
if( it == zitend ) break;
|
||||
const auto nend = m_worker.GetZoneEnd( **it );
|
||||
const auto pxnext = ( nend - m_zvStart ) * pxns;
|
||||
if( pxnext - px1 >= MinVisSize * 2 ) break;
|
||||
px1 = pxnext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastCpu = ev.cpu_start;
|
||||
|
||||
if( !ev.child.empty() )
|
||||
{
|
||||
const auto d = DispatchZoneLevel( ev.child, hover, pxns, wpos, _offset, depth, yMin, yMax );
|
||||
if( d > maxdepth ) maxdepth = d;
|
||||
}
|
||||
|
||||
if( ev.end >= 0 && m_lastCpu != ev.cpu_end )
|
||||
{
|
||||
m_lastCpu = ev.cpu_end;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
int View::DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth, uint64_t thread )
|
||||
{
|
||||
const auto delay = m_worker.GetDelay();
|
||||
|
@ -66,7 +66,9 @@ private:
|
||||
void DrawFrames();
|
||||
bool DrawZoneFrames();
|
||||
void DrawZones();
|
||||
int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth );
|
||||
int DispatchZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
|
||||
int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
|
||||
int SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
|
||||
int DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread );
|
||||
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax );
|
||||
int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
|
Loading…
x
Reference in New Issue
Block a user