mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Rewrite samples folding.
This commit is contained in:
parent
83ae9868e2
commit
c75b62e3d6
@ -61,9 +61,8 @@ struct ContextSwitchDraw
|
|||||||
|
|
||||||
struct SamplesDraw
|
struct SamplesDraw
|
||||||
{
|
{
|
||||||
bool folded;
|
|
||||||
uint32_t idx;
|
|
||||||
uint32_t num;
|
uint32_t num;
|
||||||
|
uint32_t idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -554,47 +554,32 @@ void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Ve
|
|||||||
const auto vStart = ctx.vStart;
|
const auto vStart = ctx.vStart;
|
||||||
const auto vEnd = ctx.vEnd;
|
const auto vEnd = ctx.vEnd;
|
||||||
const auto nspx = ctx.nspx;
|
const auto nspx = ctx.nspx;
|
||||||
const auto pxns = ctx.pxns;
|
|
||||||
|
|
||||||
const auto MinVis = 6 * GetScale();
|
const auto MinVis = 3 * GetScale();
|
||||||
auto it = std::lower_bound( vec.begin(), vec.end(), vStart - 2 * MinVis * nspx, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
const auto MinVisNs = int64_t( round( MinVis * nspx ) );
|
||||||
|
|
||||||
|
auto it = std::lower_bound( vec.begin(), vec.end(), vStart - MinVisNs, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
if( it == vec.end() ) return;
|
if( it == vec.end() ) return;
|
||||||
const auto itend = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
const auto itend = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
if( it == itend ) return;
|
if( it == itend ) return;
|
||||||
|
|
||||||
while( it < itend )
|
while( it < itend )
|
||||||
{
|
{
|
||||||
bool visible = true;
|
auto next = it + 1;
|
||||||
const auto t0 = it->time.Val();
|
|
||||||
const auto px0 = ( t0 - vStart ) * pxns;
|
|
||||||
double px1;
|
|
||||||
auto next = it+1;
|
|
||||||
uint32_t num = 0;
|
|
||||||
if( next != itend )
|
if( next != itend )
|
||||||
{
|
{
|
||||||
auto px1ns = next->time.Val() - vStart;
|
const auto t0 = it->time.Val();
|
||||||
px1 = px1ns * pxns;
|
|
||||||
if( px1 - px0 < MinVis )
|
|
||||||
{
|
|
||||||
const auto MinVisNs = MinVis * nspx;
|
|
||||||
visible = false;
|
|
||||||
auto nextTime = t0 + MinVisNs;
|
auto nextTime = t0 + MinVisNs;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
const auto prev = next;
|
|
||||||
next = std::lower_bound( next, itend, nextTime, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
next = std::lower_bound( next, itend, nextTime, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
if( prev == next ) ++next;
|
|
||||||
if( next == itend ) break;
|
if( next == itend ) break;
|
||||||
const auto nsnext = next->time.Val() - vStart;
|
const auto nt = next->time.Val();
|
||||||
if( nsnext - px1ns >= MinVisNs ) break;
|
if( nt - nextTime >= MinVisNs ) break;
|
||||||
px1ns = nsnext;
|
nextTime = nt + MinVisNs;
|
||||||
nextTime = next->time.Val() + nspx;
|
|
||||||
}
|
|
||||||
num = next - it;
|
|
||||||
px1 = px1ns * pxns;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_samplesDraw.emplace_back( SamplesDraw { !visible, uint32_t( it - vec.begin() ), num } );
|
m_samplesDraw.emplace_back( SamplesDraw{ uint32_t( next - it - 1 ), uint32_t( it - vec.begin() ) } );
|
||||||
it = next;
|
it = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ void View::DrawSampleList( const TimelineContext& ctx, const std::vector<Samples
|
|||||||
const auto pxns = ctx.pxns;
|
const auto pxns = ctx.pxns;
|
||||||
const auto hover = ctx.hover;
|
const auto hover = ctx.hover;
|
||||||
|
|
||||||
const auto MinVis = 6 * GetScale();
|
const auto MinVis = 3 * GetScale();
|
||||||
const auto ty0375 = offset + round( ty * 0.375f );
|
const auto ty0375 = offset + round( ty * 0.375f );
|
||||||
const auto ty02 = round( ty * 0.2f );
|
const auto ty02 = round( ty * 0.2f );
|
||||||
const auto ty01 = round( ty * 0.1f );
|
const auto ty01 = round( ty * 0.1f );
|
||||||
@ -36,7 +36,7 @@ void View::DrawSampleList( const TimelineContext& ctx, const std::vector<Samples
|
|||||||
auto it = begin + v.idx;
|
auto it = begin + v.idx;
|
||||||
const auto t0 = it->time.Val();
|
const auto t0 = it->time.Val();
|
||||||
const auto px0 = ( t0 - vStart ) * pxns;
|
const auto px0 = ( t0 - vStart ) * pxns;
|
||||||
if( v.folded )
|
if( v.num > 0 )
|
||||||
{
|
{
|
||||||
const auto eit = it + v.num;
|
const auto eit = it + v.num;
|
||||||
const auto t1 = eit->time.Val();
|
const auto t1 = eit->time.Val();
|
||||||
@ -47,7 +47,7 @@ void View::DrawSampleList( const TimelineContext& ctx, const std::vector<Samples
|
|||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
ImGui::TextUnformatted( "Multiple call stack samples" );
|
ImGui::TextUnformatted( "Multiple call stack samples" );
|
||||||
TextFocused( "Number of samples:", RealToString( v.num ) );
|
TextFocused( "Number of samples:", RealToString( v.num + 1 ) );
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
|
|
||||||
if( IsMouseClicked( 2 ) )
|
if( IsMouseClicked( 2 ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user