From a2d470690fe342045a765fbe51df05c3c3caf16d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 1 May 2023 14:41:38 +0200 Subject: [PATCH] Pass global config to View. --- profiler/src/main.cpp | 16 +++++++++------- server/TracyView.cpp | 4 ++-- server/TracyView.hpp | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 7a26ae3a..1b43fcf7 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -30,6 +30,7 @@ #include "../../server/tracy_pdqsort.h" #include "../../server/tracy_robin_hood.h" #include "../../server/TracyBadVersion.hpp" +#include "../../server/TracyConfig.hpp" #include "../../server/TracyFileHeader.hpp" #include "../../server/TracyFileRead.hpp" #include "../../server/TracyFileselector.hpp" @@ -107,6 +108,7 @@ void* zigzagTex; static Backend* bptr; static bool s_customTitle = false; static bool s_isElevated = false; +static tracy::Config s_config; static void SetWindowTitleCallback( const char* title ) { @@ -260,12 +262,12 @@ int main( int argc, char** argv ) if( initFileOpen ) { - view = std::make_unique( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); initFileOpen.reset(); } else if( connectTo ) { - view = std::make_unique( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); } tracy::Fileselector::Init(); @@ -663,11 +665,11 @@ static void DrawContents() { std::string addrPart = std::string( addr, ptr ); uint16_t portPart = (uint16_t)atoi( ptr+1 ); - view = std::make_unique( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); } else { - view = std::make_unique( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); } } ImGui::SameLine( 0, ImGui::GetTextLineHeight() * 2 ); @@ -684,7 +686,7 @@ static void DrawContents() loadThread = std::thread( [f] { try { - view = std::make_unique( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); } catch( const tracy::UnsupportedVersion& e ) { @@ -812,7 +814,7 @@ static void DrawContents() } if( selected && !loadThread.joinable() ) { - view = std::make_unique( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); } ImGui::NextColumn(); const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll; @@ -981,7 +983,7 @@ static void DrawContents() viewShutdown.store( ViewShutdown::False, std::memory_order_relaxed ); if( reconnect ) { - view = std::make_unique( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback ); + view = std::make_unique( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config ); } break; default: diff --git a/server/TracyView.cpp b/server/TracyView.cpp index e93b94a3..70376ce0 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -44,7 +44,7 @@ namespace tracy double s_time = 0; -View::View( void(*cbMainThread)(const std::function&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb ) +View::View( void(*cbMainThread)(const std::function&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config ) : m_worker( addr, port ) , m_staticView( false ) , m_viewMode( ViewMode::LastFrames ) @@ -68,7 +68,7 @@ View::View( void(*cbMainThread)(const std::function&, bool), const char* InitTextEditor(); } -View::View( void(*cbMainThread)(const std::function&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb ) +View::View( void(*cbMainThread)(const std::function&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config ) : m_worker( f ) , m_filename( f.GetFilename() ) , m_staticView( true ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index f27bf654..f8f8d0f1 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -13,6 +13,7 @@ #include "TracyBadVersion.hpp" #include "TracyBuzzAnim.hpp" +#include "TracyConfig.hpp" #include "TracyDecayValue.hpp" #include "TracyFileWrite.hpp" #include "TracyShortPtr.hpp" @@ -101,8 +102,8 @@ public: using SetScaleCallback = void(*)( float, ImFont*&, ImFont*&, ImFont*& ); using AttentionCallback = void(*)(); - View( void(*cbMainThread)(const std::function&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb ); - View( void(*cbMainThread)(const std::function&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb ); + View( void(*cbMainThread)(const std::function&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config ); + View( void(*cbMainThread)(const std::function&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config ); ~View(); bool Draw();