diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 203822b7..3090fc9c 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -253,7 +253,7 @@ private: void DrawTimeline(); void DrawSampleList( const TimelineContext& ctx, const std::vector& drawList, const Vector& vec, int offset ); void DrawZoneList( const TimelineContext& ctx, const std::vector& drawList, int offset, uint64_t tid, int maxDepth, double margin ); - int DrawThreadCropper( const int depth, const uint64_t tid, const float xPos, const float yPos, const float ostep, const float radius, const float margin, const bool hasCtxSwitches ); + void DrawThreadCropper( const int depth, const uint64_t tid, const float xPos, const float yPos, const float ostep, const float radius, const float margin, const bool hasCtxSwitches ); void DrawContextSwitchList( const TimelineContext& ctx, const std::vector& drawList, const Vector& ctxSwitch, int offset, int endOffset, bool isFiber ); int DispatchGpuZoneLevel( const Vector>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); template diff --git a/profiler/src/profiler/TracyView_ZoneTimeline.cpp b/profiler/src/profiler/TracyView_ZoneTimeline.cpp index 69cd428c..6bd9d2de 100644 --- a/profiler/src/profiler/TracyView_ZoneTimeline.cpp +++ b/profiler/src/profiler/TracyView_ZoneTimeline.cpp @@ -64,22 +64,21 @@ void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con // Display cropper if currently limited or if hovering the cropper area const auto threadDepthLimitIt = m_threadDepthLimit.find( thread.id ); const bool croppingActive = ( threadDepthLimitIt != m_threadDepthLimit.end() && threadDepthLimitIt->second <= depth ); + const int croppedDepth = croppingActive ? threadDepthLimitIt->second : depth; const bool mouseInCropperDisplayZone = ctx.hover && ImGui::GetMousePos().x >= wpos.x && ImGui::GetMousePos().x < wpos.x + cropperAdditionalMargin && ImGui::GetMousePos().y > ctx.yMin && ImGui::GetMousePos().y < ctx.yMax; const bool displayCropper = croppingActive || mouseInCropperDisplayZone; if( displayCropper ) { - if(depth > 0) depth = DrawThreadCropper( depth, thread.id, wpos.x, yPos, ostep, cropperCircleRadius, cropperWidth, hasCtxSwitch ); - const auto* drawList = ImGui::GetWindowDrawList(); ImGui::PushClipRect( drawList->GetClipRectMin() + ImVec2( cropperAdditionalMargin, 0 ), drawList->GetClipRectMax(), true ); } - if( !draw.empty() && yPos <= yMax && yPos + ostep * depth >= yMin ) + if( !draw.empty() && yPos <= yMax && yPos + ostep * croppedDepth >= yMin ) { // Only apply margin when croppingActive to avoid text moving around when mouse is getting close to the cropper widget - DrawZoneList( ctx, draw, offset, thread.id, depth, croppingActive ? cropperAdditionalMargin + GetScale() /* Ensure text has a bit of space for text */ : 0.f ); + DrawZoneList( ctx, draw, offset, thread.id, croppedDepth, croppingActive ? cropperAdditionalMargin + GetScale() /* Ensure text has a bit of space for text */ : 0.f ); } - offset += ostep * depth; + offset += ostep * croppedDepth; if( hasCtxSwitch && !ctxDraw.empty() ) { @@ -97,7 +96,11 @@ void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con const auto lockDepth = DrawLocks( ctx, lockDraw, thread.id, offset, m_nextLockHighlight ); offset += sstep * lockDepth; } - if( displayCropper ) ImGui::PopClipRect(); + if( displayCropper ) + { + ImGui::PopClipRect(); + if( depth > 0 ) DrawThreadCropper( depth, thread.id, wpos.x, yPos, ostep, cropperCircleRadius, cropperWidth, hasCtxSwitch ); + } } void View::DrawThreadMessagesList( const TimelineContext& ctx, const std::vector& drawList, int offset, uint64_t tid ) @@ -602,12 +605,11 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vectorAddCircle( center, hradius, 0xFFFFFFFF, 0, GetScale() ); - foreground->AddLine( ImVec2( 0, yPos + ( lane + 1 ) * ostep ), ImVec2( ImGui::GetWindowSize().x, yPos + ( lane + 1 ) * ostep ), 0x880000FF, 2.0f * GetScale() ); + draw->AddCircle( center, hradius, 0xFFFFFFFF, 0, GetScale() ); + const float wPosX = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMin().x; + const float wSizeX = ImGui::GetWindowContentRegionMax().x; + draw->AddLine( ImVec2( wPosX, yPos + ( lane + 1 ) * ostep ), ImVec2( wPosX + wSizeX, yPos + ( lane + 1 ) * ostep ), 0x880000FF, 2.0f * GetScale() ); if( clicked ) { const int newDepthLimit = lane + 1; @@ -662,9 +666,6 @@ int View::DrawThreadCropper( const int depth, const uint64_t tid, const float xP } draw->AddCircleFilled( center, radius, color ); } - - // Need to take the minimum as depth may be lower after panning or zooming. We however keep the limit value - return isCropped && depthLimit < depth ? depthLimit : depth; } }