mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Rewrite ghost zone folding.
This commit is contained in:
parent
c75b62e3d6
commit
527b5f3311
@ -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
|
||||
{
|
||||
|
@ -29,7 +29,6 @@ bool View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con
|
||||
const auto ty = ctx.ty;
|
||||
const auto ostep = ty + 1;
|
||||
const auto pxns = ctx.pxns;
|
||||
const auto nspx = ctx.nspx;
|
||||
const auto hover = ctx.hover;
|
||||
const auto yMin = ctx.yMin;
|
||||
const auto yMax = ctx.yMax;
|
||||
@ -446,7 +445,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector<TimelineD
|
||||
const auto color = m_vd.dynamicColors == 2 ? 0xFF666666 : MixGhostColor( GetThreadColor( tid, v.depth ), 0x665555 );
|
||||
const auto rend = v.rend.Val();
|
||||
const auto px0 = ( ev.start.Val() - m_vd.zvStart ) * pxns;
|
||||
const auto px1 = ( rend - ev.end.Val() ) * pxns;
|
||||
const auto px1 = ( rend - m_vd.zvStart ) * pxns;
|
||||
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 ) );
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty + 1 ) ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user