mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-29 08:54:34 +00:00
Move vis data to timeline controller.
This commit is contained in:
parent
49bda91be5
commit
655d8a01ea
@ -9,9 +9,15 @@ TimelineController::TimelineController()
|
|||||||
: m_height( 0 )
|
: m_height( 0 )
|
||||||
, m_offset( 0 )
|
, m_offset( 0 )
|
||||||
, m_scroll( 0 )
|
, m_scroll( 0 )
|
||||||
|
, m_firstFrame( true )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimelineController::FirstFrameExpired()
|
||||||
|
{
|
||||||
|
m_firstFrame = false;
|
||||||
|
}
|
||||||
|
|
||||||
void TimelineController::End( float offset )
|
void TimelineController::End( float offset )
|
||||||
{
|
{
|
||||||
const auto scrollPos = ImGui::GetScrollY();
|
const auto scrollPos = ImGui::GetScrollY();
|
||||||
@ -26,4 +32,45 @@ void TimelineController::End( float offset )
|
|||||||
m_scroll = scrollPos;
|
m_scroll = scrollPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float TimelineController::AdjustThreadPosition( VisData& vis, float wy, int& offset )
|
||||||
|
{
|
||||||
|
if( vis.offset < offset )
|
||||||
|
{
|
||||||
|
vis.offset = offset;
|
||||||
|
}
|
||||||
|
else if( vis.offset > offset )
|
||||||
|
{
|
||||||
|
const auto diff = vis.offset - offset;
|
||||||
|
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
||||||
|
offset = vis.offset = int( std::max<double>( vis.offset - move, offset ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset + wy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimelineController::AdjustThreadHeight( VisData& vis, int oldOffset, int& offset )
|
||||||
|
{
|
||||||
|
const auto h = offset - oldOffset;
|
||||||
|
if( vis.height > h )
|
||||||
|
{
|
||||||
|
vis.height = h;
|
||||||
|
offset = oldOffset + vis.height;
|
||||||
|
}
|
||||||
|
else if( vis.height < h )
|
||||||
|
{
|
||||||
|
if( m_firstFrame )
|
||||||
|
{
|
||||||
|
vis.height = h;
|
||||||
|
offset = oldOffset + h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto diff = h - vis.height;
|
||||||
|
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
||||||
|
vis.height = int( std::min<double>( vis.height + move, h ) );
|
||||||
|
offset = oldOffset + vis.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,53 @@
|
|||||||
#ifndef __TRACYTIMELINECONTROLLER_HPP__
|
#ifndef __TRACYTIMELINECONTROLLER_HPP__
|
||||||
#define __TRACYTIMELINECONTROLLER_HPP__
|
#define __TRACYTIMELINECONTROLLER_HPP__
|
||||||
|
|
||||||
|
#include "../public/common/TracyForceInline.hpp"
|
||||||
|
#include "tracy_robin_hood.h"
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
class TimelineController
|
class TimelineController
|
||||||
{
|
{
|
||||||
|
struct VisData
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
bool showFull = true;
|
||||||
|
bool ghost = false;
|
||||||
|
int offset = 0;
|
||||||
|
int height = 0;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimelineController();
|
TimelineController();
|
||||||
|
|
||||||
|
void FirstFrameExpired();
|
||||||
void End( float offset );
|
void End( float offset );
|
||||||
|
|
||||||
float GetHeight() const { return m_height; }
|
float GetHeight() const { return m_height; }
|
||||||
|
const unordered_flat_map<const void*, VisData>& GetVisData() const { return m_visData; }
|
||||||
|
|
||||||
|
void AdjustThreadHeight( VisData& vis, int oldOffset, int& offset );
|
||||||
|
float AdjustThreadPosition( VisData& vis, float wy, int& offset );
|
||||||
|
|
||||||
|
tracy_force_inline VisData& Vis( const void* ptr )
|
||||||
|
{
|
||||||
|
auto it = m_visData.find( ptr );
|
||||||
|
if( it == m_visData.end() )
|
||||||
|
{
|
||||||
|
it = m_visData.emplace( ptr, VisData {} ).first;
|
||||||
|
}
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
unordered_flat_map<const void*, VisData> m_visData;
|
||||||
|
|
||||||
float m_height;
|
float m_height;
|
||||||
float m_offset;
|
float m_offset;
|
||||||
float m_scroll;
|
float m_scroll;
|
||||||
|
|
||||||
|
bool m_firstFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -838,7 +838,7 @@ bool View::DrawImpl()
|
|||||||
if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) ) ZoomToPrevFrame();
|
if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) ) ZoomToPrevFrame();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
{
|
{
|
||||||
const auto vis = Vis( m_frames ).visible;
|
const auto vis = m_tc.Vis( m_frames ).visible;
|
||||||
if( !vis )
|
if( !vis )
|
||||||
{
|
{
|
||||||
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
|
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
|
||||||
@ -1085,6 +1085,7 @@ bool View::DrawImpl()
|
|||||||
if( std::chrono::duration_cast<std::chrono::milliseconds>( now - m_firstFrameTime ).count() > 500 )
|
if( std::chrono::duration_cast<std::chrono::milliseconds>( now - m_firstFrameTime ).count() > 500 )
|
||||||
{
|
{
|
||||||
m_firstFrame = false;
|
m_firstFrame = false;
|
||||||
|
m_tc.FirstFrameExpired();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,15 +80,6 @@ class View
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct VisData
|
|
||||||
{
|
|
||||||
bool visible = true;
|
|
||||||
bool showFull = true;
|
|
||||||
bool ghost = false;
|
|
||||||
int offset = 0;
|
|
||||||
int height = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PlotView
|
struct PlotView
|
||||||
{
|
{
|
||||||
double min;
|
double min;
|
||||||
@ -330,7 +321,6 @@ private:
|
|||||||
void SetPlaybackFrame( uint32_t idx );
|
void SetPlaybackFrame( uint32_t idx );
|
||||||
bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict );
|
bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict );
|
||||||
|
|
||||||
unordered_flat_map<const void*, VisData> m_visData;
|
|
||||||
unordered_flat_map<uint64_t, bool> m_visibleMsgThread;
|
unordered_flat_map<uint64_t, bool> m_visibleMsgThread;
|
||||||
unordered_flat_map<uint64_t, bool> m_waitStackThread;
|
unordered_flat_map<uint64_t, bool> m_waitStackThread;
|
||||||
unordered_flat_map<const void*, int> m_gpuDrift;
|
unordered_flat_map<const void*, int> m_gpuDrift;
|
||||||
@ -338,16 +328,6 @@ private:
|
|||||||
Vector<const ThreadData*> m_threadOrder;
|
Vector<const ThreadData*> m_threadOrder;
|
||||||
Vector<float> m_threadDnd;
|
Vector<float> m_threadDnd;
|
||||||
|
|
||||||
tracy_force_inline VisData& Vis( const void* ptr )
|
|
||||||
{
|
|
||||||
auto it = m_visData.find( ptr );
|
|
||||||
if( it == m_visData.end() )
|
|
||||||
{
|
|
||||||
it = m_visData.emplace( ptr, VisData {} ).first;
|
|
||||||
}
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
tracy_force_inline bool& VisibleMsgThread( uint64_t thread )
|
tracy_force_inline bool& VisibleMsgThread( uint64_t thread )
|
||||||
{
|
{
|
||||||
auto it = m_visibleMsgThread.find( thread );
|
auto it = m_visibleMsgThread.find( thread );
|
||||||
@ -378,8 +358,6 @@ private:
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdjustThreadHeight( View::VisData& vis, int oldOffset, int& offset );
|
|
||||||
float AdjustThreadPosition( View::VisData& vis, float wy, int& offset );
|
|
||||||
static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift );
|
static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift );
|
||||||
|
|
||||||
static const char* DecodeContextSwitchState( uint8_t state );
|
static const char* DecodeContextSwitchState( uint8_t state );
|
||||||
|
@ -28,11 +28,11 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
|
|||||||
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
||||||
|
|
||||||
static int cpuDataVisStub;
|
static int cpuDataVisStub;
|
||||||
auto& vis = Vis( &cpuDataVisStub );
|
auto& vis = m_tc.Vis( &cpuDataVisStub );
|
||||||
bool& showFull = vis.showFull;
|
bool& showFull = vis.showFull;
|
||||||
ImGui::PushID( &vis );
|
ImGui::PushID( &vis );
|
||||||
|
|
||||||
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
const auto yPos = m_tc.AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
const auto oldOffset = offset;
|
const auto oldOffset = offset;
|
||||||
ImGui::PushClipRect( wpos, wpos + ImVec2( w, offset + vis.height ), true );
|
ImGui::PushClipRect( wpos, wpos + ImVec2( w, offset + vis.height ), true );
|
||||||
if( yPos + ty >= yMin && yPos <= yMax )
|
if( yPos + ty >= yMin && yPos <= yMax )
|
||||||
@ -465,7 +465,7 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
|
|||||||
}
|
}
|
||||||
|
|
||||||
offset += ostep * 0.2f;
|
offset += ostep * 0.2f;
|
||||||
AdjustThreadHeight( vis, oldOffset, offset );
|
m_tc.AdjustThreadHeight( vis, oldOffset, offset );
|
||||||
ImGui::PopClipRect();
|
ImGui::PopClipRect();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
for( const auto& v : m_worker.GetLockMap() )
|
for( const auto& v : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
const auto& lockmap = *v.second;
|
const auto& lockmap = *v.second;
|
||||||
if( !lockmap.valid || !Vis( &lockmap ).visible ) continue;
|
if( !lockmap.valid || !m_tc.Vis( &lockmap ).visible ) continue;
|
||||||
if( m_vd.onlyContendedLocks && ( lockmap.threadList.size() == 1 || !lockmap.isContended ) && m_lockInfoWindow != v.first ) continue;
|
if( m_vd.onlyContendedLocks && ( lockmap.threadList.size() == 1 || !lockmap.isContended ) && m_lockInfoWindow != v.first ) continue;
|
||||||
|
|
||||||
auto it = lockmap.threadMap.find( tid );
|
auto it = lockmap.threadMap.find( tid );
|
||||||
|
@ -189,7 +189,7 @@ void View::DrawNotificationArea()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
bool hidden = false;
|
bool hidden = false;
|
||||||
for( auto& v : m_visData )
|
for( auto& v : m_tc.GetVisData() )
|
||||||
{
|
{
|
||||||
if( !v.second.visible )
|
if( !v.second.visible )
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ void View::DrawOptions()
|
|||||||
const auto& timeline = gpuData[i]->threadData.begin()->second.timeline;
|
const auto& timeline = gpuData[i]->threadData.begin()->second.timeline;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
sprintf( buf, "%s context %zu", GpuContextNames[(int)gpuData[i]->type], i );
|
sprintf( buf, "%s context %zu", GpuContextNames[(int)gpuData[i]->type], i );
|
||||||
SmallCheckbox( buf, &Vis( gpuData[i] ).visible );
|
SmallCheckbox( buf, &m_tc.Vis( gpuData[i] ).visible );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if( gpuData[i]->threadData.size() == 1 )
|
if( gpuData[i]->threadData.size() == 1 )
|
||||||
{
|
{
|
||||||
@ -280,7 +280,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
Vis( l.second ).visible = true;
|
m_tc.Vis( l.second ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -288,7 +288,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
Vis( l.second ).visible = false;
|
m_tc.Vis( l.second ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -304,7 +304,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && l.second->isContended ) Vis( l.second ).visible = true;
|
if( l.second->threadList.size() != 1 && l.second->isContended ) m_tc.Vis( l.second ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -312,7 +312,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && l.second->isContended ) Vis( l.second ).visible = false;
|
if( l.second->threadList.size() != 1 && l.second->isContended ) m_tc.Vis( l.second ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
||||||
}
|
}
|
||||||
SmallCheckbox( buf, &Vis( l.second ).visible );
|
SmallCheckbox( buf, &m_tc.Vis( l.second ).visible );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
m_lockHoverHighlight = l.first;
|
m_lockHoverHighlight = l.first;
|
||||||
@ -382,7 +382,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && !l.second->isContended ) Vis( l.second ).visible = true;
|
if( l.second->threadList.size() != 1 && !l.second->isContended ) m_tc.Vis( l.second ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -390,7 +390,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && !l.second->isContended ) Vis( l.second ).visible = false;
|
if( l.second->threadList.size() != 1 && !l.second->isContended ) m_tc.Vis( l.second ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
||||||
}
|
}
|
||||||
SmallCheckbox( buf, &Vis( l.second ).visible );
|
SmallCheckbox( buf, &m_tc.Vis( l.second ).visible );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
m_lockHoverHighlight = l.first;
|
m_lockHoverHighlight = l.first;
|
||||||
@ -460,7 +460,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() == 1 ) Vis( l.second ).visible = true;
|
if( l.second->threadList.size() == 1 ) m_tc.Vis( l.second ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -468,7 +468,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() == 1 ) Vis( l.second ).visible = false;
|
if( l.second->threadList.size() == 1 ) m_tc.Vis( l.second ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
||||||
}
|
}
|
||||||
SmallCheckbox( buf, &Vis( l.second ).visible );
|
SmallCheckbox( buf, &m_tc.Vis( l.second ).visible );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
m_lockHoverHighlight = l.first;
|
m_lockHoverHighlight = l.first;
|
||||||
@ -548,7 +548,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& p : m_worker.GetPlots() )
|
for( const auto& p : m_worker.GetPlots() )
|
||||||
{
|
{
|
||||||
Vis( p ).visible = true;
|
m_tc.Vis( p ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -556,7 +556,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& p : m_worker.GetPlots() )
|
for( const auto& p : m_worker.GetPlots() )
|
||||||
{
|
{
|
||||||
Vis( p ).visible = false;
|
m_tc.Vis( p ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
SmallColorBox( GetPlotColor( p ) );
|
SmallColorBox( GetPlotColor( p ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
SmallCheckbox( GetPlotName( p ), &Vis( p ).visible );
|
SmallCheckbox( GetPlotName( p ), &m_tc.Vis( p ).visible );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "%s data points", RealToString( p->data.size() ) );
|
ImGui::TextDisabled( "%s data points", RealToString( p->data.size() ) );
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& t : m_threadOrder )
|
for( const auto& t : m_threadOrder )
|
||||||
{
|
{
|
||||||
Vis( t ).visible = true;
|
m_tc.Vis( t ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -593,7 +593,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& t : m_threadOrder )
|
for( const auto& t : m_threadOrder )
|
||||||
{
|
{
|
||||||
Vis( t ).visible = false;
|
m_tc.Vis( t ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +608,7 @@ void View::DrawOptions()
|
|||||||
const auto threadColor = GetThreadColor( t->id, 0 );
|
const auto threadColor = GetThreadColor( t->id, 0 );
|
||||||
SmallColorBox( threadColor );
|
SmallColorBox( threadColor );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
SmallCheckbox( threadName, &Vis( t ).visible );
|
SmallCheckbox( threadName, &m_tc.Vis( t ).visible );
|
||||||
if( ImGui::BeginDragDropSource( ImGuiDragDropFlags_SourceNoHoldToOpenOthers ) )
|
if( ImGui::BeginDragDropSource( ImGuiDragDropFlags_SourceNoHoldToOpenOthers ) )
|
||||||
{
|
{
|
||||||
ImGui::SetDragDropPayload( "ThreadOrder", &idx, sizeof(int) );
|
ImGui::SetDragDropPayload( "ThreadOrder", &idx, sizeof(int) );
|
||||||
@ -704,7 +704,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& fd : m_worker.GetFrames() )
|
for( const auto& fd : m_worker.GetFrames() )
|
||||||
{
|
{
|
||||||
Vis( fd ).visible = true;
|
m_tc.Vis( fd ).visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -712,7 +712,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& fd : m_worker.GetFrames() )
|
for( const auto& fd : m_worker.GetFrames() )
|
||||||
{
|
{
|
||||||
Vis( fd ).visible = false;
|
m_tc.Vis( fd ).visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +720,7 @@ void View::DrawOptions()
|
|||||||
for( const auto& fd : m_worker.GetFrames() )
|
for( const auto& fd : m_worker.GetFrames() )
|
||||||
{
|
{
|
||||||
ImGui::PushID( idx++ );
|
ImGui::PushID( idx++ );
|
||||||
SmallCheckbox( GetFrameSetName( *fd ), &Vis( fd ).visible );
|
SmallCheckbox( GetFrameSetName( *fd ), &m_tc.Vis( fd ).visible );
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " );
|
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " );
|
||||||
|
@ -89,7 +89,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
|||||||
|
|
||||||
for( const auto& v : m_worker.GetPlots() )
|
for( const auto& v : m_worker.GetPlots() )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = m_tc.Vis( v );
|
||||||
if( !vis.visible )
|
if( !vis.visible )
|
||||||
{
|
{
|
||||||
vis.height = 0;
|
vis.height = 0;
|
||||||
@ -101,7 +101,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
|||||||
ImGui::PushID( &vis );
|
ImGui::PushID( &vis );
|
||||||
|
|
||||||
float txtx = 0;
|
float txtx = 0;
|
||||||
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
const auto yPos = m_tc.AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
const auto oldOffset = offset;
|
const auto oldOffset = offset;
|
||||||
ImGui::PushClipRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + vis.height ), true );
|
ImGui::PushClipRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + vis.height ), true );
|
||||||
if( yPos + ty >= yMin && yPos <= yMax )
|
if( yPos + ty >= yMin && yPos <= yMax )
|
||||||
@ -426,7 +426,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
offset += 0.2 * ty;
|
offset += 0.2 * ty;
|
||||||
AdjustThreadHeight( vis, oldOffset, offset );
|
m_tc.AdjustThreadHeight( vis, oldOffset, offset );
|
||||||
ImGui::PopClipRect();
|
ImGui::PopClipRect();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
@ -13,47 +13,6 @@ constexpr float MinVisSize = 3;
|
|||||||
|
|
||||||
extern double s_time;
|
extern double s_time;
|
||||||
|
|
||||||
float View::AdjustThreadPosition( View::VisData& vis, float wy, int& offset )
|
|
||||||
{
|
|
||||||
if( vis.offset < offset )
|
|
||||||
{
|
|
||||||
vis.offset = offset;
|
|
||||||
}
|
|
||||||
else if( vis.offset > offset )
|
|
||||||
{
|
|
||||||
const auto diff = vis.offset - offset;
|
|
||||||
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
|
||||||
offset = vis.offset = int( std::max<double>( vis.offset - move, offset ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return offset + wy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void View::AdjustThreadHeight( View::VisData& vis, int oldOffset, int& offset )
|
|
||||||
{
|
|
||||||
const auto h = offset - oldOffset;
|
|
||||||
if( vis.height > h )
|
|
||||||
{
|
|
||||||
vis.height = h;
|
|
||||||
offset = oldOffset + vis.height;
|
|
||||||
}
|
|
||||||
else if( vis.height < h )
|
|
||||||
{
|
|
||||||
if( m_firstFrame )
|
|
||||||
{
|
|
||||||
vis.height = h;
|
|
||||||
offset = oldOffset + h;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto diff = h - vis.height;
|
|
||||||
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
|
||||||
vis.height = int( std::min<double>( vis.height + move, h ) );
|
|
||||||
offset = oldOffset + vis.height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
|
void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns )
|
||||||
{
|
{
|
||||||
assert( timespan > 0 );
|
assert( timespan > 0 );
|
||||||
@ -264,7 +223,7 @@ void View::DrawTimeline()
|
|||||||
auto& frames = m_worker.GetFrames();
|
auto& frames = m_worker.GetFrames();
|
||||||
for( auto fd : frames )
|
for( auto fd : frames )
|
||||||
{
|
{
|
||||||
if( Vis( fd ).visible )
|
if( m_tc.Vis( fd ).visible )
|
||||||
{
|
{
|
||||||
DrawTimelineFrames( *fd );
|
DrawTimelineFrames( *fd );
|
||||||
}
|
}
|
||||||
@ -310,7 +269,7 @@ void View::DrawTimeline()
|
|||||||
for( size_t i=0; i<m_worker.GetGpuData().size(); i++ )
|
for( size_t i=0; i<m_worker.GetGpuData().size(); i++ )
|
||||||
{
|
{
|
||||||
const auto& v = m_worker.GetGpuData()[i];
|
const auto& v = m_worker.GetGpuData()[i];
|
||||||
auto& vis = Vis( v );
|
auto& vis = m_tc.Vis( v );
|
||||||
if( !vis.visible )
|
if( !vis.visible )
|
||||||
{
|
{
|
||||||
vis.height = 0;
|
vis.height = 0;
|
||||||
@ -320,7 +279,7 @@ void View::DrawTimeline()
|
|||||||
bool& showFull = vis.showFull;
|
bool& showFull = vis.showFull;
|
||||||
ImGui::PushID( &vis );
|
ImGui::PushID( &vis );
|
||||||
|
|
||||||
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
const auto yPos = m_tc.AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
const auto oldOffset = offset;
|
const auto oldOffset = offset;
|
||||||
ImGui::PushClipRect( wpos, wpos + ImVec2( w, oldOffset + vis.height ), true );
|
ImGui::PushClipRect( wpos, wpos + ImVec2( w, oldOffset + vis.height ), true );
|
||||||
|
|
||||||
@ -585,7 +544,7 @@ void View::DrawTimeline()
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjustThreadHeight( vis, oldOffset, offset );
|
m_tc.AdjustThreadHeight( vis, oldOffset, offset );
|
||||||
ImGui::PopClipRect();
|
ImGui::PopClipRect();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
@ -611,7 +570,7 @@ void View::DrawTimeline()
|
|||||||
LockHighlight nextLockHighlight { -1 };
|
LockHighlight nextLockHighlight { -1 };
|
||||||
for( const auto& v : m_threadOrder )
|
for( const auto& v : m_threadOrder )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = m_tc.Vis( v );
|
||||||
if( !vis.visible )
|
if( !vis.visible )
|
||||||
{
|
{
|
||||||
vis.height = 0;
|
vis.height = 0;
|
||||||
@ -621,7 +580,7 @@ void View::DrawTimeline()
|
|||||||
bool showFull = vis.showFull;
|
bool showFull = vis.showFull;
|
||||||
ImGui::PushID( &vis );
|
ImGui::PushID( &vis );
|
||||||
|
|
||||||
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
const auto yPos = m_tc.AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
const auto oldOffset = offset;
|
const auto oldOffset = offset;
|
||||||
ImGui::PushClipRect( wpos, wpos + ImVec2( w, offset + vis.height ), true );
|
ImGui::PushClipRect( wpos, wpos + ImVec2( w, offset + vis.height ), true );
|
||||||
|
|
||||||
@ -691,7 +650,7 @@ void View::DrawTimeline()
|
|||||||
|
|
||||||
if( !m_vd.drawEmptyLabels && showFull && depth == 0 && msgit == msgend && crash.thread != v->id )
|
if( !m_vd.drawEmptyLabels && showFull && depth == 0 && msgit == msgend && crash.thread != v->id )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = m_tc.Vis( v );
|
||||||
vis.height = 0;
|
vis.height = 0;
|
||||||
vis.offset = 0;
|
vis.offset = 0;
|
||||||
offset = oldOffset;
|
offset = oldOffset;
|
||||||
@ -831,7 +790,7 @@ void View::DrawTimeline()
|
|||||||
float ghostSz;
|
float ghostSz;
|
||||||
if( hasGhostZones && !v->timeline.empty() )
|
if( hasGhostZones && !v->timeline.empty() )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = m_tc.Vis( v );
|
||||||
const auto color = vis.ghost ? 0xFFAA9999 : 0x88AA7777;
|
const auto color = vis.ghost ? 0xFFAA9999 : 0x88AA7777;
|
||||||
draw->AddText( wpos + ImVec2( 1.5f * ty + txtsz.x, oldOffset ), color, ICON_FA_GHOST );
|
draw->AddText( wpos + ImVec2( 1.5f * ty + txtsz.x, oldOffset ), color, ICON_FA_GHOST );
|
||||||
ghostSz = ImGui::CalcTextSize( ICON_FA_GHOST ).x;
|
ghostSz = ImGui::CalcTextSize( ICON_FA_GHOST ).x;
|
||||||
@ -845,7 +804,7 @@ void View::DrawTimeline()
|
|||||||
{
|
{
|
||||||
if( IsMouseClicked( 0 ) )
|
if( IsMouseClicked( 0 ) )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = m_tc.Vis( v );
|
||||||
vis.ghost = !vis.ghost;
|
vis.ghost = !vis.ghost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -973,7 +932,7 @@ void View::DrawTimeline()
|
|||||||
|
|
||||||
if( IsMouseClicked( 0 ) )
|
if( IsMouseClicked( 0 ) )
|
||||||
{
|
{
|
||||||
Vis( v ).showFull = !showFull;
|
m_tc.Vis( v ).showFull = !showFull;
|
||||||
}
|
}
|
||||||
if( last >= 0 && IsMouseClicked( 2 ) )
|
if( last >= 0 && IsMouseClicked( 2 ) )
|
||||||
{
|
{
|
||||||
@ -997,7 +956,7 @@ void View::DrawTimeline()
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjustThreadHeight( Vis( v ), oldOffset, offset );
|
m_tc.AdjustThreadHeight( m_tc.Vis( v ), oldOffset, offset );
|
||||||
ImGui::PopClipRect();
|
ImGui::PopClipRect();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user