Darkening of inactive thread regions.

This commit is contained in:
Bartosz Taudul 2019-09-30 23:37:36 +02:00
parent e758e98ca4
commit 0e56682964
4 changed files with 31 additions and 12 deletions

View File

@ -13,7 +13,7 @@ constexpr auto FileTimeline = "timeline";
constexpr auto FileOptions = "options";
enum : uint32_t { VersionTimeline = 0 };
enum : uint32_t { VersionOptions = 1 };
enum : uint32_t { VersionOptions = 2 };
UserData::UserData()
: m_preserveState( false )
@ -93,6 +93,7 @@ void UserData::LoadState( ViewData& data )
fread( &data.onlyContendedLocks, 1, sizeof( data.onlyContendedLocks ), f );
fread( &data.drawEmptyLabels, 1, sizeof( data.drawEmptyLabels ), f );
fread( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
fread( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
fread( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
}
@ -130,6 +131,7 @@ void UserData::SaveState( const ViewData& data )
fwrite( &data.onlyContendedLocks, 1, sizeof( data.onlyContendedLocks ), f );
fwrite( &data.drawEmptyLabels, 1, sizeof( data.drawEmptyLabels ), f );
fwrite( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
fwrite( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
fwrite( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
fclose( f );

View File

@ -2242,14 +2242,10 @@ void View::DrawZones()
offset += ostep;
if( showFull )
{
const auto ctxOffset = offset;
if( m_vd.drawContextSwitches )
{
auto ctxSwitch = m_worker.GetContextSwitchData( v->id );
if( ctxSwitch )
{
DrawContextSwitches( ctxSwitch, hover, pxns, int64_t( nspx ), wpos, offset );
offset += round( ostep * 0.75f );
}
offset += round( ostep * 0.75f );
}
if( m_vd.drawZones )
@ -2258,6 +2254,15 @@ void View::DrawZones()
offset += ostep * depth;
}
if( m_vd.drawContextSwitches )
{
auto ctxSwitch = m_worker.GetContextSwitchData( v->id );
if( ctxSwitch )
{
DrawContextSwitches( ctxSwitch, hover, pxns, int64_t( nspx ), wpos, ctxOffset, offset );
}
}
if( m_vd.drawLocks )
{
const auto lockDepth = DrawLocks( v->id, hover, pxns, wpos, offset, nextLockHighlight, yMin, yMax );
@ -2704,7 +2709,7 @@ static const char* DecodeContextSwitchState( uint8_t state )
}
}
void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset )
void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset )
{
auto& vec = ctx->v;
auto it = std::lower_bound( vec.begin(), vec.end(), std::max<int64_t>( 0, m_vd.zvStart ), [] ( const auto& l, const auto& r ) { return (uint64_t)l.End() < (uint64_t)r; } );
@ -2732,6 +2737,10 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
const auto pxw = ( ev.wakeup - m_vd.zvStart ) * pxns;
const auto px1 = std::min( ( ev.Start() - m_vd.zvStart ) * pxns, w + 10.0 );
const auto color = migration ? 0xFFEE7711 : 0xFF2222AA;
if( m_vd.darkenContextSwitches )
{
draw->AddRectFilled( wpos + ImVec2( px0, round( offset + ty * 0.5 ) ), wpos + ImVec2( px1, endOffset ), 0x44000000 );
}
draw->AddLine( wpos + ImVec2( px0, round( offset + ty * 0.5 ) - 0.5 ), wpos + ImVec2( std::min( pxw, w+10.0 ), round( offset + ty * 0.5 ) - 0.5 ), color, 2 );
if( ev.wakeup != ev.Start() )
{
@ -2749,11 +2758,11 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
{
TextFocused( "CPU:", RealToString( pit->Cpu(), true ) );
ImGui::SameLine();
#ifdef TRACY_EXTENDED_FONT
#ifdef TRACY_EXTENDED_FONT
TextFocused( ICON_FA_LONG_ARROW_ALT_RIGHT, RealToString( ev.Cpu(), true ) );
#else
#else
TextFocused( "->", RealToString( ev.Cpu(), true ) );
#endif
#endif
}
else
{
@ -6476,6 +6485,13 @@ void View::DrawOptions()
ImGui::Checkbox( "Draw context switches", &val );
#endif
m_vd.drawContextSwitches = val;
val = m_vd.darkenContextSwitches;
#ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_MOON " Darken inactive threads", &val );
#else
ImGui::Checkbox( "Darken inactive threads", &val );
#endif
m_vd.darkenContextSwitches = val;
val = m_vd.drawCpuData;
#ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_SLIDERS_H " Draw CPU data", &val );

View File

@ -110,7 +110,7 @@ private:
bool DrawZoneFramesHeader();
bool DrawZoneFrames( const FrameData& frames );
void DrawZones();
void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset );
void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset );
int DispatchZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );
int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );
int SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );

View File

@ -22,6 +22,7 @@ struct ViewData
uint8_t onlyContendedLocks = true;
uint8_t drawEmptyLabels = false;
uint8_t drawContextSwitches = true;
uint8_t darkenContextSwitches = true;
uint8_t drawCpuData = true;
uint8_t dynamicColors = true;
};