From c78aedae624eed22b9442b78be3ec0a250a07556 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 24 Feb 2019 17:30:58 +0100 Subject: [PATCH] Zoom-to-range for lock labels. --- server/TracyView.cpp | 14 +++++++++++--- server/TracyView.hpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 6f822c8c..e1930b3c 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2948,7 +2948,7 @@ static LockState CombineLockState( LockState state, LockState next ) return (LockState)std::max( (int)state, (int)next ); } -void View::DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset ) +void View::DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint8_t tid ) { char buf[1024]; sprintf( buf, "%" PRIu32 ": %s", id, m_worker.GetString( srcloc.function ) ); @@ -2989,6 +2989,14 @@ void View::DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLoca { m_lockInfoWindow = id; } + if( ImGui::IsMouseClicked( 2 ) ) + { + auto lptr = lockmap.timeline.data(); + auto eptr = lptr + lockmap.timeline.size() - 1; + while( (*lptr)->thread != tid ) lptr++; + while( (*eptr)->thread != tid ) eptr--; + ZoomToRange( (*lptr)->time, (*eptr)->time ); + } } } } @@ -3023,7 +3031,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, { draw->AddRectFilled( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + ty ), 0x2288DD88 ); draw->AddRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + ty ), 0x4488DD88 ); - DrawLockHeader( v.first, lockmap, m_worker.GetSourceLocation( lockmap.srcloc ), hover, draw, wpos, w, ty, offset ); + DrawLockHeader( v.first, lockmap, m_worker.GetSourceLocation( lockmap.srcloc ), hover, draw, wpos, w, ty, offset, it->second ); cnt++; } @@ -3468,7 +3476,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, draw->AddRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + ty ), 0x448888DD ); } - DrawLockHeader( v.first, lockmap, srcloc, hover, draw, wpos, w, ty, offset ); + DrawLockHeader( v.first, lockmap, srcloc, hover, draw, wpos, w, ty, offset, it->second ); cnt++; } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 6727b304..e6caefcd 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -105,7 +105,7 @@ private: int DispatchGpuZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); int DrawGpuZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); int SkipGpuZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift ); - void DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset ); + void DrawLockHeader( uint32_t id, const LockMap& lockmap, const SourceLocation& srcloc, bool hover, ImDrawList* draw, const ImVec2& wpos, float w, float ty, float offset, uint8_t tid ); int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax ); int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax ); void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, const PlotItem* item, double prev, bool merged, PlotType type, float PlotHeight );