diff --git a/server/TracyTimelineItemThread.cpp b/server/TracyTimelineItemThread.cpp index 6d8f696c..380d3b7e 100644 --- a/server/TracyTimelineItemThread.cpp +++ b/server/TracyTimelineItemThread.cpp @@ -229,7 +229,7 @@ void TimelineItemThread::HeaderTooltip( const char* label ) const void TimelineItemThread::HeaderExtraContents( const TimelineContext& ctx, int offset, float labelWidth ) { - m_view.DrawThreadMessages( *m_thread, ctx.pxns, offset, ctx.wpos, ctx.hover ); + m_view.DrawThreadMessages( ctx, *m_thread, offset ); #ifndef TRACY_NO_STATISTICS const bool hasGhostZones = m_worker.AreGhostZonesReady() && !m_thread->ghostZones.empty(); @@ -255,7 +255,7 @@ void TimelineItemThread::HeaderExtraContents( const TimelineContext& ctx, int of bool TimelineItemThread::DrawContents( const TimelineContext& ctx, int& offset ) { - const auto res = m_view.DrawThread( *m_thread, ctx.pxns, offset, ctx.wpos, ctx.hover, ctx.yMin, ctx.yMax, m_ghost ); + const auto res = m_view.DrawThread( ctx, *m_thread, offset, m_ghost ); if( !res ) { auto& crash = m_worker.GetCrashEvent(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index be141f2f..747a2950 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -121,8 +121,8 @@ public: void HighlightThread( uint64_t thread ); void ZoomToRange( int64_t start, int64_t end, bool pause = true ); bool DrawPlot( const TimelineContext& ctx, PlotData& plot, int& offset ); - bool DrawThread( const ThreadData& thread, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax, bool ghostMode ); - void DrawThreadMessages( const ThreadData& thread, double pxns, int offset, const ImVec2& wpos, bool hover ); + bool DrawThread( const TimelineContext& ctx, const ThreadData& thread, int& offset, bool ghostMode ); + void DrawThreadMessages( const TimelineContext& ctx, const ThreadData& thread, int offset ); void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr ); bool DrawGpu( const TimelineContext& ctx, const GpuCtxData& gpu, int& offset ); bool DrawCpuData( const TimelineContext& ctx, int& offset ); diff --git a/server/TracyView_ZoneTimeline.cpp b/server/TracyView_ZoneTimeline.cpp index ac2cc0e2..396936e0 100644 --- a/server/TracyView_ZoneTimeline.cpp +++ b/server/TracyView_ZoneTimeline.cpp @@ -4,7 +4,7 @@ #include "TracyImGui.hpp" #include "TracyMouse.hpp" #include "TracyPrint.hpp" -#include "TracyTimelineItem.hpp" +#include "TracyTimelineContext.hpp" #include "TracyView.hpp" namespace tracy @@ -22,11 +22,16 @@ static tracy_force_inline uint32_t MixGhostColor( uint32_t c0, uint32_t c1 ) ( ( ( ( ( c0 & 0x000000FF ) ) + 3 * ( ( c1 & 0x000000FF ) ) ) >> 2 ) ); } -bool View::DrawThread( const ThreadData& thread, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax, bool ghostMode ) +bool View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, int& offset, bool ghostMode ) { - const auto ty = ImGui::GetTextLineHeight(); + const auto& wpos = ctx.wpos; + const auto ty = ctx.ty; const auto ostep = ty + 1; - const auto nspx = 1.0 / pxns; + const auto pxns = ctx.pxns; + const auto nspx = ctx.nspx; + const auto hover = ctx.hover; + const auto yMin = ctx.yMin; + const auto yMax = ctx.yMax; ImGui::PushFont( m_smallFont ); const auto sty = ImGui::GetTextLineHeight(); @@ -97,14 +102,18 @@ bool View::DrawThread( const ThreadData& thread, double pxns, int& offset, const return true; } -void View::DrawThreadMessages( const ThreadData& thread, double pxns, int offset, const ImVec2& wpos, bool hover ) +void View::DrawThreadMessages( const TimelineContext& ctx, const ThreadData& thread, int offset ) { - const auto nspx = 1.0 / pxns; - auto draw = ImGui::GetWindowDrawList(); - const auto ty = ImGui::GetTextLineHeight(); + const auto& wpos = ctx.wpos; + const auto pxns = ctx.pxns; + const auto nspx = ctx.nspx; + const auto hover = ctx.hover; + const auto ty = ctx.ty; const auto to = 9.f * GetScale(); const auto th = ( ty - to ) * sqrt( 3 ) * 0.5; + auto draw = ImGui::GetWindowDrawList(); + auto msgit = std::lower_bound( thread.messages.begin(), thread.messages.end(), m_vd.zvStart, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); auto msgend = std::lower_bound( msgit, thread.messages.end(), m_vd.zvEnd+1, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } );