Draw callstack sample data.

This commit is contained in:
Bartosz Taudul 2020-02-22 18:51:45 +01:00
parent 4502858407
commit d4f9810006
2 changed files with 40 additions and 4 deletions

View File

@ -2482,11 +2482,11 @@ void View::DrawZones()
offset += ostep; offset += ostep;
if( showFull ) if( showFull )
{ {
const auto sampleOffset = offset;
if( m_vd.drawSamples && !v->samples.empty() ) offset += round( ostep * 0.5f );
const auto ctxOffset = offset; const auto ctxOffset = offset;
if( m_vd.drawContextSwitches ) if( m_vd.drawContextSwitches ) offset += round( ostep * 0.75f );
{
offset += round( ostep * 0.75f );
}
if( m_vd.drawZones ) if( m_vd.drawZones )
{ {
@ -2503,6 +2503,11 @@ void View::DrawZones()
} }
} }
if( m_vd.drawSamples && !v->samples.empty() )
{
DrawSamples( v->samples, hover, pxns, int64_t( nspx ), wpos, sampleOffset );
}
if( m_vd.drawLocks ) if( m_vd.drawLocks )
{ {
const auto lockDepth = DrawLocks( v->id, hover, pxns, wpos, offset, nextLockHighlight, yMin, yMax ); const auto lockDepth = DrawLocks( v->id, hover, pxns, wpos, offset, nextLockHighlight, yMin, yMax );
@ -3199,6 +3204,36 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
} }
} }
void View::DrawSamples( const Vector<SampleData>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset )
{
auto it = std::lower_bound( vec.begin(), vec.end(), m_vd.zvStart, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
if( it == vec.end() ) return;
const auto itend = std::lower_bound( it, vec.end(), m_vd.zvEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } );
if( it == itend ) return;
const auto ty0375 = offset + round( ImGui::GetFontSize() * 0.375f );
const auto ty02 = round( ImGui::GetFontSize() * 0.2f );
const auto y0 = ty0375 - ty02;
const auto y1 = ty0375 + ty02 - 1;
auto draw = ImGui::GetWindowDrawList();
while( it < itend )
{
auto& ev = *it;
const auto px0 = ( it->time.Val() - m_vd.zvStart ) * pxns;
draw->AddCircleFilled( wpos + ImVec2( px0, ty0375 ), ty02, 0xFFDD8888, 7 );
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0 - ty02, y0 ), wpos + ImVec2( px0 + ty02, y1 ) ) )
{
CallstackTooltip( it->callstack.Val() );
if( ImGui::IsMouseClicked( 0 ) )
{
m_callstackInfoWindow = it->callstack.Val();
}
}
++it;
}
}
int View::DispatchZoneLevel( const Vector<short_ptr<ZoneEvent>>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid ) int View::DispatchZoneLevel( const Vector<short_ptr<ZoneEvent>>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, float yMin, float yMax, uint64_t tid )
{ {
const auto ty = ImGui::GetFontSize(); const auto ty = ImGui::GetFontSize();

View File

@ -119,6 +119,7 @@ private:
bool DrawZoneFrames( const FrameData& frames ); bool DrawZoneFrames( const FrameData& frames );
void DrawZones(); void DrawZones();
void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset ); void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset );
void DrawSamples( const Vector<SampleData>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset );
int DispatchZoneLevel( const Vector<short_ptr<ZoneEvent>>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); int DispatchZoneLevel( const Vector<short_ptr<ZoneEvent>>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );
template<typename Adapter, typename V> template<typename Adapter, typename V>
int DrawZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); int DrawZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );