Skip to content

Commit

Permalink
Push item visibility to Preprocess().
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfpld committed Mar 25, 2023
1 parent 8c1b519 commit 7ec68f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions server/TracyTimelineController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,20 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool
ctx.wpos = wpos;
ctx.hover = hover;

int yOffset = 0;
for( auto& item : m_items )
{
if( item->WantPreprocess() && item->IsVisible() )
{
item->Preprocess( ctx, m_td );
const auto yPos = wpos.y + yOffset;
const bool visible = m_firstFrame || ( yPos < yMax && yPos + item->GetNextFrameHeight() >= yMin );
item->Preprocess( ctx, m_td, visible );
}
yOffset += m_firstFrame ? 0 : item->GetNextFrameHeight();
}
m_td.Sync();

int yOffset = 0;

yOffset = 0;
for( auto& item : m_items )
{
auto currentFrameItemHeight = item->GetNextFrameHeight();
Expand Down
2 changes: 1 addition & 1 deletion server/TracyTimelineItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TimelineItem
void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset );

bool WantPreprocess() const { return m_wantPreprocess; }
virtual void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) { assert( false ); }
virtual void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible ) { assert( false ); }

void VisibilityCheckbox();
virtual void SetVisible( bool visible ) { m_visible = visible; }
Expand Down
2 changes: 1 addition & 1 deletion server/TracyTimelineItemThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void TimelineItemThread::DrawFinished()
m_msgDraw.clear();
}

void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td )
void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible )
{
assert( m_samplesDraw.empty() );
assert( m_ctxDraw.empty() );
Expand Down
2 changes: 1 addition & 1 deletion server/TracyTimelineItemThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TimelineItemThread final : public TimelineItem

bool IsEmpty() const override;

void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) override;
void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible ) override;

private:
#ifndef TRACY_NO_STATISTICS
Expand Down

0 comments on commit 7ec68f8

Please sign in to comment.