mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Extend plots to the end of the trace.
This commit is contained in:
parent
90c072b66c
commit
1bd84419c0
@ -112,7 +112,7 @@ int64_t TimelineItemPlot::RangeEnd() const
|
|||||||
|
|
||||||
bool TimelineItemPlot::DrawContents( const TimelineContext& ctx, int& offset )
|
bool TimelineItemPlot::DrawContents( const TimelineContext& ctx, int& offset )
|
||||||
{
|
{
|
||||||
return m_view.DrawPlot( ctx, *m_plot, m_draw, offset );
|
return m_view.DrawPlot( ctx, *m_plot, m_draw, offset, m_rightEnd );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineItemPlot::DrawFinished()
|
void TimelineItemPlot::DrawFinished()
|
||||||
@ -138,17 +138,30 @@ void TimelineItemPlot::Preprocess( const TimelineContext& ctx, TaskDispatch& td,
|
|||||||
|
|
||||||
auto& vec = m_plot->data;
|
auto& vec = m_plot->data;
|
||||||
vec.ensure_sorted();
|
vec.ensure_sorted();
|
||||||
if( vec.front().time.Val() > vEnd || vec.back().time.Val() < vStart )
|
if( vec.front().time.Val() > vEnd )
|
||||||
{
|
{
|
||||||
m_plot->rMin = 0;
|
m_plot->rMin = 0;
|
||||||
m_plot->rMax = 0;
|
m_plot->rMax = 0;
|
||||||
m_plot->num = 0;
|
m_plot->num = 0;
|
||||||
|
m_rightEnd = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if( vec.back().time.Val() < vStart )
|
||||||
|
{
|
||||||
|
const auto lastTime = m_worker.GetLastTime();
|
||||||
|
const auto val = vec.back().val;
|
||||||
|
m_plot->rMin = val - 1;
|
||||||
|
m_plot->rMax = val + 1;
|
||||||
|
m_plot->num = lastTime < vStart ? 0 : 1;
|
||||||
|
m_rightEnd = vec.back().time.Val() < lastTime;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = std::lower_bound( vec.begin(), vec.end(), vStart, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
auto it = std::lower_bound( vec.begin(), vec.end(), vStart, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
auto end = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
auto end = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
|
||||||
|
|
||||||
|
m_rightEnd = end == vec.end() && vec.back().time.Val() < m_worker.GetLastTime();
|
||||||
|
|
||||||
if( end != vec.end() ) end++;
|
if( end != vec.end() ) end++;
|
||||||
if( it != vec.begin() ) it--;
|
if( it != vec.begin() ) it--;
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ private:
|
|||||||
PlotData* m_plot;
|
PlotData* m_plot;
|
||||||
|
|
||||||
std::vector<uint32_t> m_draw;
|
std::vector<uint32_t> m_draw;
|
||||||
|
bool m_rightEnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public:
|
|||||||
|
|
||||||
void HighlightThread( uint64_t thread );
|
void HighlightThread( uint64_t thread );
|
||||||
void ZoomToRange( int64_t start, int64_t end, bool pause = true );
|
void ZoomToRange( int64_t start, int64_t end, bool pause = true );
|
||||||
bool DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector<uint32_t>& plotDraw, int& offset );
|
bool DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector<uint32_t>& plotDraw, int& offset, bool rightEnd );
|
||||||
void DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector<TimelineDraw>& draw, const std::vector<ContextSwitchDraw>& ctxDraw, const std::vector<SamplesDraw>& samplesDraw, const std::vector<std::unique_ptr<LockDraw>>& lockDraw, int& offset, int depth, bool hasCtxSwitches, bool hasSamples );
|
void DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector<TimelineDraw>& draw, const std::vector<ContextSwitchDraw>& ctxDraw, const std::vector<SamplesDraw>& samplesDraw, const std::vector<std::unique_ptr<LockDraw>>& lockDraw, int& offset, int depth, bool hasCtxSwitches, bool hasSamples );
|
||||||
void DrawThreadMessagesList( const TimelineContext& ctx, const std::vector<MessagesDraw>& drawList, int offset, uint64_t tid );
|
void DrawThreadMessagesList( const TimelineContext& ctx, const std::vector<MessagesDraw>& drawList, int offset, uint64_t tid );
|
||||||
void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr );
|
void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr );
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector<uint32_t>& plotDraw, int& offset )
|
bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector<uint32_t>& plotDraw, int& offset, bool rightEnd )
|
||||||
{
|
{
|
||||||
auto draw = ImGui::GetWindowDrawList();
|
auto draw = ImGui::GetWindowDrawList();
|
||||||
const auto& wpos = ctx.wpos;
|
const auto& wpos = ctx.wpos;
|
||||||
@ -173,6 +173,34 @@ bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( rightEnd )
|
||||||
|
{
|
||||||
|
const auto lastTime = m_worker.GetLastTime();
|
||||||
|
if( lastTime > m_vd.zvStart )
|
||||||
|
{
|
||||||
|
double y;
|
||||||
|
double x0 = 0;
|
||||||
|
const auto x1 = std::min<double>( ( lastTime - m_vd.zvStart ) * pxns, w );
|
||||||
|
|
||||||
|
if( plotDraw.empty() )
|
||||||
|
{
|
||||||
|
y = PlotHeight * 0.5;
|
||||||
|
DrawLine( draw, dpos + ImVec2( 0, offset + y ), dpos + ImVec2( x1, offset + y ), color );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x0 = ( plot.data.back().time.Val() - m_vd.zvStart ) * pxns;
|
||||||
|
y = PlotHeight - ( plot.data.back().val - min ) * revrange * PlotHeight;
|
||||||
|
DrawLine( draw, dpos + ImVec2( x0, offset + y ), dpos + ImVec2( x1, offset + y ), color );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( plot.fill )
|
||||||
|
{
|
||||||
|
draw->AddRectFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x1, offset + y ), fill );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto tmp = FormatPlotValue( plot.rMax, plot.format );
|
auto tmp = FormatPlotValue( plot.rMax, plot.format );
|
||||||
DrawTextSuperContrast( draw, wpos + ImVec2( 0, offset ), color, tmp );
|
DrawTextSuperContrast( draw, wpos + ImVec2( 0, offset ), color, tmp );
|
||||||
offset += PlotHeight - ty;
|
offset += PlotHeight - ty;
|
||||||
|
Loading…
Reference in New Issue
Block a user