mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Rewrite ghost zone folding.
This commit is contained in:
@@ -323,45 +323,40 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
int TimelineItemThread::PreprocessGhostLevel( const TimelineContext& ctx, const Vector<GhostZone>& vec, int depth )
|
||||
{
|
||||
const auto pxns = ctx.pxns;
|
||||
const auto nspx = ctx.nspx;
|
||||
const auto vStart = ctx.vStart;
|
||||
const auto vEnd = ctx.vEnd;
|
||||
|
||||
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, vStart - 2 * MinVisSize * nspx ), [] ( const auto& l, const auto& r ) { return l.end.Val() < r; } );
|
||||
const auto MinVisNs = int64_t( round( MinVisSize * nspx ) );
|
||||
|
||||
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, vStart - 2 * MinVisNs ), [] ( const auto& l, const auto& r ) { return l.end.Val() < r; } );
|
||||
if( it == vec.end() ) return depth;
|
||||
|
||||
const auto zitend = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.start.Val() < r; } );
|
||||
if( it == zitend ) return depth;
|
||||
if( (zitend-1)->end.Val() < vStart ) return depth;
|
||||
|
||||
const auto MinVisNs = MinVisSize * nspx;
|
||||
int maxdepth = depth + 1;
|
||||
|
||||
while( it < zitend )
|
||||
{
|
||||
auto& ev = *it;
|
||||
const auto end = ev.end.Val();
|
||||
const auto zsz = std::max( ( end - ev.start.Val() ) * pxns, pxns * 0.5 );
|
||||
if( zsz < MinVisSize )
|
||||
const auto zsz = end - ev.start.Val();
|
||||
if( zsz < MinVisNs )
|
||||
{
|
||||
auto px1ns = ev.end.Val() - vStart;
|
||||
auto rend = end;
|
||||
auto nextTime = end + MinVisNs;
|
||||
auto next = it + 1;
|
||||
for(;;)
|
||||
{
|
||||
const auto prevIt = it;
|
||||
it = std::lower_bound( it, zitend, nextTime, [] ( const auto& l, const auto& r ) { return l.end.Val() < r; } );
|
||||
if( it == prevIt ) ++it;
|
||||
if( it == zitend ) break;
|
||||
const auto nend = it->end.Val();
|
||||
const auto nsnext = nend - vStart;
|
||||
if( nsnext - px1ns >= MinVisNs * 2 ) break;
|
||||
px1ns = nsnext;
|
||||
rend = nend;
|
||||
nextTime = nend + nspx;
|
||||
next = std::lower_bound( next, zitend, nextTime, [] ( const auto& l, const auto& r ) { return l.end.Val() < r; } );
|
||||
if( next == zitend ) break;
|
||||
const auto nt = next->end.Val();
|
||||
if( nt - nextTime >= MinVisNs ) break;
|
||||
nextTime = nt + MinVisNs;
|
||||
}
|
||||
m_draw.emplace_back( TimelineDraw { TimelineDrawType::GhostFolded, uint16_t( depth ), (void**)&ev, rend } );
|
||||
m_draw.emplace_back( TimelineDraw { TimelineDrawType::GhostFolded, uint16_t( depth ), (void**)&ev, (next-1)->end } );
|
||||
it = next;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user