Build samples draw list only if visible.

This commit is contained in:
Bartosz Taudul
2023-04-05 19:03:40 +02:00
parent a9ee4c499e
commit f48415315a
2 changed files with 13 additions and 4 deletions

View File

@@ -318,8 +318,8 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
m_hasSamples = false;
if( vd.drawSamples && !m_thread->samples.empty() )
{
td.Queue( [this, &ctx, visible] {
PreprocessSamples( ctx, m_thread->samples, visible );
td.Queue( [this, &ctx, visible, yPos] {
PreprocessSamples( ctx, m_thread->samples, visible, yPos );
} );
}
@@ -532,11 +532,14 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
}
}
void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Vector<SampleData>& vec, bool visible )
void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Vector<SampleData>& vec, bool visible, int yPos )
{
const auto vStart = ctx.vStart;
const auto vEnd = ctx.vEnd;
const auto nspx = ctx.nspx;
const auto ty = ctx.ty;
const auto ostep = ty + 1;
const auto pos = yPos + ostep;
const auto MinVis = 5 * GetScale();
const auto MinVisNs = int64_t( round( MinVis * nspx ) );
@@ -549,6 +552,12 @@ void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Ve
m_hasSamples = true;
if( !visible ) return;
const auto ty0375 = pos + round( ty * 0.375f );
const auto ty02 = round( ty * 0.2f );
const auto y0 = ty0375 - ty02 - 3;
const auto y1 = ty0375 + ty02 - 1;
if( y0 > ctx.yMax || y1 < ctx.yMin ) return;
while( it < itend )
{
auto next = it + 1;