diff --git a/server/TracyView.cpp b/server/TracyView.cpp index fdd5e416..537739d5 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2482,11 +2482,11 @@ void View::DrawZones() offset += ostep; if( showFull ) { + const auto sampleOffset = offset; + if( m_vd.drawSamples && !v->samples.empty() ) offset += round( ostep * 0.5f ); + const auto ctxOffset = offset; - if( m_vd.drawContextSwitches ) - { - offset += round( ostep * 0.75f ); - } + if( m_vd.drawContextSwitches ) offset += round( ostep * 0.75f ); 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 ) { 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& 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>& 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(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 98bbf40f..a6bd4a1b 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -119,6 +119,7 @@ private: bool DrawZoneFrames( const FrameData& frames ); void DrawZones(); void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset ); + void DrawSamples( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset ); int DispatchZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid ); template 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 );