From fddba168c6074ba9319984c42fb62a2788559729 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 18 Mar 2019 19:39:37 +0100 Subject: [PATCH] Track next time to search for. --- server/TracyView.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index b0836004..142fa6a6 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2346,10 +2346,11 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, const auto px0 = ( ev.start - m_zvStart ) * pxns; auto px1 = ( end - m_zvStart ) * pxns; auto rend = end; + auto nextTime = end + MinVisSize; for(;;) { const auto prevIt = it; - it = std::lower_bound( it, zitend, std::max( rend + nspx, end + MinVisSize ), [] ( const auto& l, const auto& r ) { return (uint64_t)l->end < (uint64_t)r; } ); + it = std::lower_bound( it, zitend, nextTime, [] ( const auto& l, const auto& r ) { return (uint64_t)l->end < (uint64_t)r; } ); if( it == prevIt ) ++it; num += std::distance( prevIt, it ); if( it == zitend ) break; @@ -2358,6 +2359,7 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, if( pxnext - px1 >= MinVisSize * 2 ) break; px1 = pxnext; rend = nend; + nextTime = nend + nspx; } draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ), color ); DrawZigZag( draw, wpos + ImVec2( 0, offset + ty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), ty/4, DarkenColor( color ) ); @@ -2525,18 +2527,18 @@ int View::SkipZoneLevel( const Vector& vec, bool hover, double pxns, if( zsz < MinVisSize ) { auto px1 = ( end - m_zvStart ) * pxns; - auto rend = end; + auto nextTime = end + MinVisSize; for(;;) { const auto prevIt = it; - it = std::lower_bound( it, zitend, std::max( rend + nspx, end + MinVisSize ), [] ( const auto& l, const auto& r ) { return (uint64_t)l->end < (uint64_t)r; } ); + it = std::lower_bound( it, zitend, nextTime, [] ( const auto& l, const auto& r ) { return (uint64_t)l->end < (uint64_t)r; } ); if( it == prevIt ) ++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; - rend = nend; + nextTime = nend + nspx; } } else @@ -2620,10 +2622,11 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn const auto px0 = ( start - m_zvStart ) * pxns; auto px1 = ( end - m_zvStart ) * pxns; auto rend = end; + auto nextTime = end + MinVisSize; for(;;) { const auto prevIt = it; - it = std::lower_bound( it, zitend, std::max( rend + nspx, end + MinVisSize ), [] ( const auto& l, const auto& r ) { return (uint64_t)l->gpuEnd < (uint64_t)r; } ); + it = std::lower_bound( it, zitend, nextTime, [] ( const auto& l, const auto& r ) { return (uint64_t)l->gpuEnd < (uint64_t)r; } ); if( it == prevIt ) ++it; num += std::distance( prevIt, it ); if( it == zitend ) break; @@ -2632,6 +2635,7 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn if( pxnext - px1 >= MinVisSize * 2 ) break; px1 = pxnext; rend = nend; + nextTime = nend + nspx; } draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ), color ); DrawZigZag( draw, wpos + ImVec2( 0, offset + ty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), ty/4, DarkenColor( color ) ); @@ -2783,18 +2787,18 @@ int View::SkipGpuZoneLevel( const Vector& vec, bool hover, double pxn if( zsz < MinVisSize ) { auto px1 = ( end - m_zvStart ) * pxns; - auto rend = end; + auto nextTime = end; for(;;) { const auto prevIt = it; - it = std::lower_bound( it, zitend, std::max( rend + nspx, end + MinVisSize ), [] ( const auto& l, const auto& r ) { return (uint64_t)l->gpuEnd < (uint64_t)r; } ); + it = std::lower_bound( it, zitend, nextTime, [] ( const auto& l, const auto& r ) { return (uint64_t)l->gpuEnd < (uint64_t)r; } ); if( it == prevIt ) ++it; if( it == zitend ) break; const auto nend = AdjustGpuTime( m_worker.GetZoneEnd( **it ), begin, drift ); const auto pxnext = ( nend - m_zvStart ) * pxns; if( pxnext - px1 >= MinVisSize * 2 ) break; px1 = pxnext; - rend = nend; + nextTime = nend + nspx; } } else