1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 04:43:53 +00:00

Allow disabling CPU usage graph.

This commit is contained in:
Bartosz Taudul 2019-10-15 21:37:16 +02:00
parent c28bab59b5
commit 4372ad1bc3
3 changed files with 41 additions and 26 deletions

View File

@ -20,7 +20,7 @@ constexpr auto FileOptions = "options";
constexpr auto FileAnnotations = "annotations"; constexpr auto FileAnnotations = "annotations";
enum : uint32_t { VersionTimeline = 0 }; enum : uint32_t { VersionTimeline = 0 };
enum : uint32_t { VersionOptions = 2 }; enum : uint32_t { VersionOptions = 3 };
enum : uint32_t { VersionAnnotations = 0 }; enum : uint32_t { VersionAnnotations = 0 };
UserData::UserData() UserData::UserData()
@ -103,6 +103,7 @@ void UserData::LoadState( ViewData& data )
fread( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f ); fread( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
fread( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f ); fread( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
fread( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f ); fread( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
fread( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f );
fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f ); fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
} }
fclose( f ); fclose( f );
@ -141,6 +142,7 @@ void UserData::SaveState( const ViewData& data )
fwrite( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f ); fwrite( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
fwrite( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f ); fwrite( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
fwrite( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f ); fwrite( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
fwrite( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f );
fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f ); fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
fclose( f ); fclose( f );
} }

View File

@ -4408,6 +4408,8 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
const auto cpuCnt = m_worker.GetCpuDataCpuCount(); const auto cpuCnt = m_worker.GetCpuDataCpuCount();
assert( cpuCnt != 0 ); assert( cpuCnt != 0 );
if( m_vd.drawCpuUsageGraph )
{
const auto cpuUsageHeight = floor( 40.f * ImGui::GetTextLineHeight() / 15.f ); const auto cpuUsageHeight = floor( 40.f * ImGui::GetTextLineHeight() / 15.f );
if( wpos.y + offset + cpuUsageHeight + 3 >= yMin && wpos.y + offset <= yMax ) if( wpos.y + offset + cpuUsageHeight + 3 >= yMin && wpos.y + offset <= yMax )
{ {
@ -4437,6 +4439,7 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
draw->AddLine( wpos + ImVec2( 0, offset+cpuUsageHeight+2 ), wpos + ImVec2( w, offset+cpuUsageHeight+2 ), 0x22DD88DD ); draw->AddLine( wpos + ImVec2( 0, offset+cpuUsageHeight+2 ), wpos + ImVec2( w, offset+cpuUsageHeight+2 ), 0x22DD88DD );
} }
offset += cpuUsageHeight + 3; offset += cpuUsageHeight + 3;
}
const auto origOffset = offset; const auto origOffset = offset;
for( int i=0; i<cpuCnt; i++ ) for( int i=0; i<cpuCnt; i++ )
@ -6789,15 +6792,15 @@ void View::DrawOptions()
ImGui::Checkbox( "Draw context switches", &val ); ImGui::Checkbox( "Draw context switches", &val );
#endif #endif
m_vd.drawContextSwitches = val; m_vd.drawContextSwitches = val;
val = m_vd.darkenContextSwitches;
ImGui::Indent(); ImGui::Indent();
val = m_vd.darkenContextSwitches;
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_MOON " Darken inactive threads", &val ); ImGui::Checkbox( ICON_FA_MOON " Darken inactive threads", &val );
#else #else
ImGui::Checkbox( "Darken inactive threads", &val ); ImGui::Checkbox( "Darken inactive threads", &val );
#endif #endif
ImGui::Unindent();
m_vd.darkenContextSwitches = val; m_vd.darkenContextSwitches = val;
ImGui::Unindent();
val = m_vd.drawCpuData; val = m_vd.drawCpuData;
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_SLIDERS_H " Draw CPU data", &val ); ImGui::Checkbox( ICON_FA_SLIDERS_H " Draw CPU data", &val );
@ -6805,6 +6808,15 @@ void View::DrawOptions()
ImGui::Checkbox( "Draw CPU data", &val ); ImGui::Checkbox( "Draw CPU data", &val );
#endif #endif
m_vd.drawCpuData = val; m_vd.drawCpuData = val;
ImGui::Indent();
val = m_vd.drawCpuUsageGraph;
#ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_SIGNATURE " Draw CPU usage graph", &val );
#else
ImGui::Checkbox( "Draw CPU usage graph", &val );
#endif
m_vd.drawCpuUsageGraph = val;
ImGui::Unindent();
} }
ImGui::Separator(); ImGui::Separator();

View File

@ -24,6 +24,7 @@ struct ViewData
uint8_t drawContextSwitches = true; uint8_t drawContextSwitches = true;
uint8_t darkenContextSwitches = true; uint8_t darkenContextSwitches = true;
uint8_t drawCpuData = true; uint8_t drawCpuData = true;
uint8_t drawCpuUsageGraph = true;
uint8_t dynamicColors = true; uint8_t dynamicColors = true;
}; };