From ee5d6f1adb697875f7edc21313e1fa9258ae73bc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 19 Mar 2023 00:28:14 +0100 Subject: [PATCH] Use TimelineContext for drawing GPU zones. --- server/TracyTimelineItemGpu.cpp | 2 +- server/TracyView.hpp | 2 +- server/TracyView_GpuTimeline.cpp | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/server/TracyTimelineItemGpu.cpp b/server/TracyTimelineItemGpu.cpp index 5242e237..4ae1d683 100644 --- a/server/TracyTimelineItemGpu.cpp +++ b/server/TracyTimelineItemGpu.cpp @@ -191,7 +191,7 @@ int64_t TimelineItemGpu::RangeEnd() const bool TimelineItemGpu::DrawContents( const TimelineContext& ctx, int& offset ) { - return m_view.DrawGpu( *m_gpu, ctx.pxns, offset, ctx.wpos, ctx.hover, ctx.yMin, ctx.yMax ); + return m_view.DrawGpu( ctx, *m_gpu, offset ); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 9ef0dbe2..be141f2f 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -124,7 +124,7 @@ public: 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 ); - bool DrawGpu( const GpuCtxData& gpu, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax ); + bool DrawGpu( const TimelineContext& ctx, const GpuCtxData& gpu, int& offset ); bool DrawCpuData( const TimelineContext& ctx, int& offset ); bool m_showRanges = false; diff --git a/server/TracyView_GpuTimeline.cpp b/server/TracyView_GpuTimeline.cpp index d4de52fa..9196bcb6 100644 --- a/server/TracyView_GpuTimeline.cpp +++ b/server/TracyView_GpuTimeline.cpp @@ -2,6 +2,7 @@ #include "TracyImGui.hpp" #include "TracyMouse.hpp" #include "TracyPrint.hpp" +#include "TracyTimelineContext.hpp" #include "TracyView.hpp" namespace tracy @@ -9,14 +10,20 @@ namespace tracy constexpr float MinVisSize = 3; -bool View::DrawGpu( const GpuCtxData& gpu, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax ) +bool View::DrawGpu( const TimelineContext& ctx, const GpuCtxData& gpu, int& offset ) { - const auto w = ImGui::GetContentRegionAvail().x - 1; - const auto ty = ImGui::GetTextLineHeight(); + const auto w = ctx.w; + const auto ty = ctx.ty; const auto ostep = ty + 1; - const auto nspx = 1.0 / pxns; - auto draw = ImGui::GetWindowDrawList(); + const auto pxns = ctx.pxns; + const auto nspx = ctx.nspx; + const auto& wpos = ctx.wpos; const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); + const auto hover = ctx.hover; + const auto yMin = ctx.yMin; + const auto yMax = ctx.yMax; + + auto draw = ImGui::GetWindowDrawList(); ImGui::PushFont( m_smallFont ); const auto sty = ImGui::GetTextLineHeight();