diff --git a/server/TracyTimelineItemPlot.cpp b/server/TracyTimelineItemPlot.cpp index 0b0b9e24..f0018438 100644 --- a/server/TracyTimelineItemPlot.cpp +++ b/server/TracyTimelineItemPlot.cpp @@ -107,7 +107,7 @@ int64_t TimelineItemPlot::RangeEnd() const bool TimelineItemPlot::DrawContents( const TimelineContext& ctx, int& offset ) { - return m_view.DrawPlot( *m_plot, ctx.pxns, offset, ctx.wpos, ctx.hover, ctx.yMin, ctx.yMax ); + return m_view.DrawPlot( ctx, *m_plot, offset ); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 92585a0e..7360acfb 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -120,7 +120,7 @@ public: void HighlightThread( uint64_t thread ); void ZoomToRange( int64_t start, int64_t end, bool pause = true ); - bool DrawPlot( PlotData& plot, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax ); + 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 ); void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr ); diff --git a/server/TracyView_Plots.cpp b/server/TracyView_Plots.cpp index 3dd9375b..8fa93ef2 100644 --- a/server/TracyView_Plots.cpp +++ b/server/TracyView_Plots.cpp @@ -4,31 +4,35 @@ #include "TracyImGui.hpp" #include "TracyMouse.hpp" #include "TracyPrint.hpp" +#include "TracyTimelineContext.hpp" #include "TracyUtility.hpp" #include "TracyView.hpp" namespace tracy { -bool View::DrawPlot( PlotData& plot, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax ) +bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, int& offset ) { + auto& vec = plot.data; + vec.ensure_sorted(); + if( vec.front().time.Val() > m_vd.zvEnd || vec.back().time.Val() < m_vd.zvStart ) return false; + const auto PlotHeight = 100 * GetScale(); enum { MaxPoints = 128 }; float tmpvec[MaxPoints*2]; - const auto w = ImGui::GetContentRegionAvail().x - 1; - const auto ty = ImGui::GetTextLineHeight(); auto draw = ImGui::GetWindowDrawList(); - const auto nspx = 1.0 / pxns; + const auto& wpos = ctx.wpos; const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); - - auto& vec = plot.data; - vec.ensure_sorted(); - if( vec.front().time.Val() > m_vd.zvEnd || vec.back().time.Val() < m_vd.zvStart ) return false; + const auto pxns = ctx.pxns; + const auto nspx = ctx.nspx; + const auto w = ctx.w; + const auto hover = ctx.hover; + const auto ty = ctx.ty; auto yPos = wpos.y + offset; - if( yPos + PlotHeight >= yMin && yPos <= yMax ) + if( yPos + PlotHeight >= ctx.yMin && yPos <= ctx.yMax ) { const auto color = GetPlotColor( plot, m_worker ); const auto bg = 0x22000000 | ( DarkenColorMore( color ) & 0xFFFFFF );