mirror of
https://github.com/wolfpld/tracy
synced 2025-05-02 13:43:52 +00:00
View::Draw() is no longer static.
This commit is contained in:
parent
c89c4f46ea
commit
0a7ae94fcb
@ -44,8 +44,6 @@ namespace tracy
|
|||||||
|
|
||||||
double s_time = 0;
|
double s_time = 0;
|
||||||
|
|
||||||
static View* s_instance = nullptr;
|
|
||||||
|
|
||||||
View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb )
|
View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb )
|
||||||
: m_worker( addr, port )
|
: m_worker( addr, port )
|
||||||
, m_staticView( false )
|
, m_staticView( false )
|
||||||
@ -66,9 +64,6 @@ View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr,
|
|||||||
, m_userData()
|
, m_userData()
|
||||||
, m_cbMainThread( cbMainThread )
|
, m_cbMainThread( cbMainThread )
|
||||||
{
|
{
|
||||||
assert( s_instance == nullptr );
|
|
||||||
s_instance = this;
|
|
||||||
|
|
||||||
InitMemory();
|
InitMemory();
|
||||||
InitTextEditor( fixedWidth );
|
InitTextEditor( fixedWidth );
|
||||||
}
|
}
|
||||||
@ -90,9 +85,6 @@ View::View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFon
|
|||||||
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
||||||
, m_cbMainThread( cbMainThread )
|
, m_cbMainThread( cbMainThread )
|
||||||
{
|
{
|
||||||
assert( s_instance == nullptr );
|
|
||||||
s_instance = this;
|
|
||||||
|
|
||||||
m_notificationTime = 4;
|
m_notificationTime = 4;
|
||||||
m_notificationText = std::string( "Trace loaded in " ) + TimeToString( m_worker.GetLoadTime() );
|
m_notificationText = std::string( "Trace loaded in " ) + TimeToString( m_worker.GetLoadTime() );
|
||||||
|
|
||||||
@ -122,9 +114,6 @@ View::~View()
|
|||||||
|
|
||||||
if( m_frameTexture ) FreeTexture( m_frameTexture, m_cbMainThread );
|
if( m_frameTexture ) FreeTexture( m_frameTexture, m_cbMainThread );
|
||||||
if( m_playback.texture ) FreeTexture( m_playback.texture, m_cbMainThread );
|
if( m_playback.texture ) FreeTexture( m_playback.texture, m_cbMainThread );
|
||||||
|
|
||||||
assert( s_instance != nullptr );
|
|
||||||
s_instance = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::InitMemory()
|
void View::InitMemory()
|
||||||
@ -240,7 +229,7 @@ static_assert( sizeof( CompressionName ) == sizeof( CompressionDesc ), "Unmatche
|
|||||||
|
|
||||||
bool View::Draw()
|
bool View::Draw()
|
||||||
{
|
{
|
||||||
HandshakeStatus status = (HandshakeStatus)s_instance->m_worker.GetHandshakeStatus();
|
HandshakeStatus status = (HandshakeStatus)m_worker.GetHandshakeStatus();
|
||||||
switch( status )
|
switch( status )
|
||||||
{
|
{
|
||||||
case HandshakeProtocolMismatch:
|
case HandshakeProtocolMismatch:
|
||||||
@ -256,7 +245,7 @@ bool View::Draw()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& failure = s_instance->m_worker.GetFailureType();
|
const auto& failure = m_worker.GetFailureType();
|
||||||
if( failure != Worker::Failure::None )
|
if( failure != Worker::Failure::None )
|
||||||
{
|
{
|
||||||
ImGui::OpenPopup( "Instrumentation failure" );
|
ImGui::OpenPopup( "Instrumentation failure" );
|
||||||
@ -264,7 +253,7 @@ bool View::Draw()
|
|||||||
|
|
||||||
if( ImGui::BeginPopupModal( "Protocol mismatch", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Protocol mismatch", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
ImGui::PushFont( s_instance->m_bigFont );
|
ImGui::PushFont( m_bigFont );
|
||||||
TextCentered( ICON_FA_TRIANGLE_EXCLAMATION );
|
TextCentered( ICON_FA_TRIANGLE_EXCLAMATION );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::TextUnformatted( "The client you are trying to connect to uses incompatible protocol version.\nMake sure you are using the same Tracy version on both client and server." );
|
ImGui::TextUnformatted( "The client you are trying to connect to uses incompatible protocol version.\nMake sure you are using the same Tracy version on both client and server." );
|
||||||
@ -280,7 +269,7 @@ bool View::Draw()
|
|||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
s_instance->m_reconnectRequested = true;
|
m_reconnectRequested = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
@ -288,7 +277,7 @@ bool View::Draw()
|
|||||||
|
|
||||||
if( ImGui::BeginPopupModal( "Client not ready", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Client not ready", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
ImGui::PushFont( s_instance->m_bigFont );
|
ImGui::PushFont( m_bigFont );
|
||||||
TextCentered( ICON_FA_LIGHTBULB );
|
TextCentered( ICON_FA_LIGHTBULB );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::TextUnformatted( "The client you are trying to connect to is no longer able to sent profiling data,\nbecause another server was already connected to it.\nYou can do the following:\n\n 1. Restart the client application.\n 2. Rebuild the client application with on-demand mode enabled." );
|
ImGui::TextUnformatted( "The client you are trying to connect to is no longer able to sent profiling data,\nbecause another server was already connected to it.\nYou can do the following:\n\n 1. Restart the client application.\n 2. Rebuild the client application with on-demand mode enabled." );
|
||||||
@ -304,7 +293,7 @@ bool View::Draw()
|
|||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
s_instance->m_reconnectRequested = true;
|
m_reconnectRequested = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
@ -312,7 +301,7 @@ bool View::Draw()
|
|||||||
|
|
||||||
if( ImGui::BeginPopupModal( "Client disconnected", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Client disconnected", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
ImGui::PushFont( s_instance->m_bigFont );
|
ImGui::PushFont( m_bigFont );
|
||||||
TextCentered( ICON_FA_HANDSHAKE );
|
TextCentered( ICON_FA_HANDSHAKE );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::TextUnformatted( "The client you are trying to connect to has disconnected during the initial\nconnection handshake. Please check your network configuration." );
|
ImGui::TextUnformatted( "The client you are trying to connect to has disconnected during the initial\nconnection handshake. Please check your network configuration." );
|
||||||
@ -328,7 +317,7 @@ bool View::Draw()
|
|||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
s_instance->m_reconnectRequested = true;
|
m_reconnectRequested = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
@ -336,8 +325,8 @@ bool View::Draw()
|
|||||||
|
|
||||||
if( ImGui::BeginPopupModal( "Instrumentation failure", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Instrumentation failure", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
const auto& data = s_instance->m_worker.GetFailureData();
|
const auto& data = m_worker.GetFailureData();
|
||||||
ImGui::PushFont( s_instance->m_bigFont );
|
ImGui::PushFont( m_bigFont );
|
||||||
TextCentered( ICON_FA_SKULL );
|
TextCentered( ICON_FA_SKULL );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::TextUnformatted( "Profiling session terminated due to improper instrumentation.\nPlease correct your program and try again." );
|
ImGui::TextUnformatted( "Profiling session terminated due to improper instrumentation.\nPlease correct your program and try again." );
|
||||||
@ -347,22 +336,22 @@ bool View::Draw()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if( data.srcloc != 0 )
|
if( data.srcloc != 0 )
|
||||||
{
|
{
|
||||||
const auto& srcloc = s_instance->m_worker.GetSourceLocation( data.srcloc );
|
const auto& srcloc = m_worker.GetSourceLocation( data.srcloc );
|
||||||
if( srcloc.name.active )
|
if( srcloc.name.active )
|
||||||
{
|
{
|
||||||
TextFocused( "Zone name:", s_instance->m_worker.GetString( srcloc.name ) );
|
TextFocused( "Zone name:", m_worker.GetString( srcloc.name ) );
|
||||||
}
|
}
|
||||||
TextFocused( "Function:", s_instance->m_worker.GetString( srcloc.function ) );
|
TextFocused( "Function:", m_worker.GetString( srcloc.function ) );
|
||||||
TextDisabledUnformatted( "Location:" );
|
TextDisabledUnformatted( "Location:" );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextUnformatted( LocationToString( s_instance->m_worker.GetString( srcloc.file ), srcloc.line ) );
|
ImGui::TextUnformatted( LocationToString( m_worker.GetString( srcloc.file ), srcloc.line ) );
|
||||||
}
|
}
|
||||||
if( data.thread != 0 )
|
if( data.thread != 0 )
|
||||||
{
|
{
|
||||||
TextFocused( "Thread:", s_instance->m_worker.GetThreadName( data.thread ) );
|
TextFocused( "Thread:", m_worker.GetThreadName( data.thread ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "(%s)", RealToString( data.thread ) );
|
ImGui::TextDisabled( "(%s)", RealToString( data.thread ) );
|
||||||
if( s_instance->m_worker.IsThreadFiber( data.thread ) )
|
if( m_worker.IsThreadFiber( data.thread ) )
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" );
|
TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" );
|
||||||
@ -385,11 +374,11 @@ bool View::Draw()
|
|||||||
ImGui::TableSetupColumn( "Image" );
|
ImGui::TableSetupColumn( "Image" );
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
auto& cs = s_instance->m_worker.GetCallstack( data.callstack );
|
auto& cs = m_worker.GetCallstack( data.callstack );
|
||||||
int fidx = 0;
|
int fidx = 0;
|
||||||
for( auto& entry : cs )
|
for( auto& entry : cs )
|
||||||
{
|
{
|
||||||
auto frameData = s_instance->m_worker.GetCallstackFrame( entry );
|
auto frameData = m_worker.GetCallstackFrame( entry );
|
||||||
if( !frameData )
|
if( !frameData )
|
||||||
{
|
{
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
@ -397,7 +386,7 @@ bool View::Draw()
|
|||||||
ImGui::Text( "%i", fidx++ );
|
ImGui::Text( "%i", fidx++ );
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf( buf, "%p", (void*)s_instance->m_worker.GetCanonicalPointer( entry ) );
|
sprintf( buf, "%p", (void*)m_worker.GetCanonicalPointer( entry ) );
|
||||||
ImGui::TextUnformatted( buf );
|
ImGui::TextUnformatted( buf );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
@ -416,7 +405,7 @@ bool View::Draw()
|
|||||||
for( uint8_t f=0; f<fsz; f++ )
|
for( uint8_t f=0; f<fsz; f++ )
|
||||||
{
|
{
|
||||||
const auto& frame = frameData->data[f];
|
const auto& frame = frameData->data[f];
|
||||||
auto txt = s_instance->m_worker.GetString( frame.name );
|
auto txt = m_worker.GetString( frame.name );
|
||||||
|
|
||||||
if( fidx == 0 && f != fsz-1 )
|
if( fidx == 0 && f != fsz-1 )
|
||||||
{
|
{
|
||||||
@ -469,7 +458,7 @@ bool View::Draw()
|
|||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::PushTextWrapPos( 0.0f );
|
ImGui::PushTextWrapPos( 0.0f );
|
||||||
txt = s_instance->m_worker.GetString( frame.file );
|
txt = m_worker.GetString( frame.file );
|
||||||
TextDisabledUnformatted( LocationToString( txt, frame.line ) );
|
TextDisabledUnformatted( LocationToString( txt, frame.line ) );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
@ -485,7 +474,7 @@ bool View::Draw()
|
|||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if( frameData->imageName.Active() )
|
if( frameData->imageName.Active() )
|
||||||
{
|
{
|
||||||
TextDisabledUnformatted( s_instance->m_worker.GetString( frameData->imageName ) );
|
TextDisabledUnformatted( m_worker.GetString( frameData->imageName ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,21 +489,21 @@ bool View::Draw()
|
|||||||
if( ImGui::Button( "I understand" ) )
|
if( ImGui::Button( "I understand" ) )
|
||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
s_instance->m_worker.ClearFailure();
|
m_worker.ClearFailure();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool saveFailed = false;
|
bool saveFailed = false;
|
||||||
if( !s_instance->m_filenameStaging.empty() )
|
if( !m_filenameStaging.empty() )
|
||||||
{
|
{
|
||||||
ImGui::OpenPopup( "Save trace" );
|
ImGui::OpenPopup( "Save trace" );
|
||||||
}
|
}
|
||||||
if( ImGui::BeginPopupModal( "Save trace", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Save trace", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
assert( !s_instance->m_filenameStaging.empty() );
|
assert( !m_filenameStaging.empty() );
|
||||||
auto fn = s_instance->m_filenameStaging.c_str();
|
auto fn = m_filenameStaging.c_str();
|
||||||
ImGui::PushFont( s_instance->m_bigFont );
|
ImGui::PushFont( m_bigFont );
|
||||||
TextFocused( "Path:", fn );
|
TextFocused( "Path:", fn );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -545,7 +534,7 @@ bool View::Draw()
|
|||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
|
|
||||||
static bool buildDict = false;
|
static bool buildDict = false;
|
||||||
if( s_instance->m_worker.GetFrameImageCount() != 0 )
|
if( m_worker.GetFrameImageCount() != 0 )
|
||||||
{
|
{
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Checkbox( "Build frame images dictionary", &buildDict );
|
ImGui::Checkbox( "Build frame images dictionary", &buildDict );
|
||||||
@ -556,14 +545,14 @@ bool View::Draw()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if( ImGui::Button( ICON_FA_FLOPPY_DISK " Save trace" ) )
|
if( ImGui::Button( ICON_FA_FLOPPY_DISK " Save trace" ) )
|
||||||
{
|
{
|
||||||
saveFailed = !s_instance->Save( fn, comp, zlvl, buildDict );
|
saveFailed = !Save( fn, comp, zlvl, buildDict );
|
||||||
s_instance->m_filenameStaging.clear();
|
m_filenameStaging.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if( ImGui::Button( "Cancel" ) )
|
if( ImGui::Button( "Cancel" ) )
|
||||||
{
|
{
|
||||||
s_instance->m_filenameStaging.clear();
|
m_filenameStaging.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
@ -572,7 +561,7 @@ bool View::Draw()
|
|||||||
if( saveFailed ) ImGui::OpenPopup( "Save failed" );
|
if( saveFailed ) ImGui::OpenPopup( "Save failed" );
|
||||||
if( ImGui::BeginPopupModal( "Save failed", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
if( ImGui::BeginPopupModal( "Save failed", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
|
||||||
{
|
{
|
||||||
ImGui::PushFont( s_instance->m_bigFont );
|
ImGui::PushFont( m_bigFont );
|
||||||
TextCentered( ICON_FA_TRIANGLE_EXCLAMATION );
|
TextCentered( ICON_FA_TRIANGLE_EXCLAMATION );
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::TextUnformatted( "Could not save trace at the specified location. Try again somewhere else." );
|
ImGui::TextUnformatted( "Could not save trace at the specified location. Try again somewhere else." );
|
||||||
@ -582,7 +571,7 @@ bool View::Draw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
s_time += ImGui::GetIO().DeltaTime;
|
s_time += ImGui::GetIO().DeltaTime;
|
||||||
return s_instance->DrawImpl();
|
return DrawImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* MainWindowButtons[] = {
|
static const char* MainWindowButtons[] = {
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb );
|
View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb );
|
||||||
~View();
|
~View();
|
||||||
|
|
||||||
static bool Draw();
|
bool Draw();
|
||||||
bool WasActive() const;
|
bool WasActive() const;
|
||||||
|
|
||||||
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
|
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user