From 7dbfed9aeaa5a706f15fa5b74b5dbb509ce74b26 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 12 Aug 2022 21:44:24 +0200 Subject: [PATCH] Drop access to native window. The new NFD library is not using this information, and the old one was using it only on Windows. Oh well. Removal of this functionality also removes some build-time decisions. --- profiler/build/unix/build.mk | 9 --------- profiler/src/Backend.hpp | 1 - profiler/src/BackendGlfw.cpp | 29 ----------------------------- profiler/src/main.cpp | 19 +++++++------------ server/TracySourceView.cpp | 3 +-- server/TracySourceView.hpp | 5 +---- server/TracyView.cpp | 8 +++----- server/TracyView.hpp | 8 +++----- 8 files changed, 15 insertions(+), 67 deletions(-) diff --git a/profiler/build/unix/build.mk b/profiler/build/unix/build.mk index 11bf2751..24765f1a 100644 --- a/profiler/build/unix/build.mk +++ b/profiler/build/unix/build.mk @@ -4,15 +4,6 @@ DEFINES += -DIMGUI_ENABLE_FREETYPE INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../imgui LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl -DISPLAY_SERVER := X11 - -ifdef TRACY_USE_WAYLAND - DISPLAY_SERVER := WAYLAND - LIBS += $(shell pkg-config --libs wayland-client) -endif - -CXXFLAGS += -D"DISPLAY_SERVER_$(DISPLAY_SERVER)" - PROJECT := Tracy IMAGE := $(PROJECT)-$(BUILD) diff --git a/profiler/src/Backend.hpp b/profiler/src/Backend.hpp index 5c1df8c1..ebd2839f 100644 --- a/profiler/src/Backend.hpp +++ b/profiler/src/Backend.hpp @@ -24,7 +24,6 @@ public: void SetTitle( const char* title ); float GetDpiScale(); - void* GetNativeWindow(); private: WindowPosition m_winPos; diff --git a/profiler/src/BackendGlfw.cpp b/profiler/src/BackendGlfw.cpp index 6a5afdef..36fbae30 100644 --- a/profiler/src/BackendGlfw.cpp +++ b/profiler/src/BackendGlfw.cpp @@ -8,20 +8,6 @@ #include #include -#ifdef _WIN32 -# define GLFW_EXPOSE_NATIVE_WIN32 -# include -#elif defined __linux__ -# ifdef DISPLAY_SERVER_X11 -# define GLFW_EXPOSE_NATIVE_X11 -# elif defined DISPLAY_SERVER_WAYLAND -# define GLFW_EXPOSE_NATIVE_WAYLAND -# else -# error "unsupported linux display server" -# endif -# include -#endif - #include "Backend.hpp" #include "RunQueue.hpp" @@ -195,18 +181,3 @@ float Backend::GetDpiScale() #endif return 1; } - -void* Backend::GetNativeWindow() -{ -#ifdef _WIN32 - return (void*)glfwGetWin32Window( s_window ); -#elif defined __linux__ -# ifdef DISPLAY_SERVER_X11 - return (void*)glfwGetX11Window( s_window ); -# elif defined DISPLAY_SERVER_WAYLAND - return (void*)glfwGetWaylandWindow( s_window ); -# endif -#else - return nullptr; -#endif -} diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 218f5a25..30c5ac84 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -108,11 +108,6 @@ static void SetWindowTitleCallback( const char* title ) s_customTitle = true; } -static void* GetMainWindowNative() -{ - return bptr->GetNativeWindow(); -} - static void DrawContents(); void RunOnMainThread( std::function cb, bool forceDelay = false ) @@ -236,12 +231,12 @@ int main( int argc, char** argv ) if( initFileOpen ) { - view = std::make_unique( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); initFileOpen.reset(); } else if( connectTo ) { - view = std::make_unique( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); } #ifndef TRACY_NO_FILESELECTOR @@ -522,11 +517,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, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); } else { - view = std::make_unique( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); } } ImGui::SameLine( 0, ImGui::GetTextLineHeight() * 2 ); @@ -547,7 +542,7 @@ static void DrawContents() loadThread = std::thread( [f] { try { - view = std::make_unique( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); } catch( const tracy::UnsupportedVersion& e ) { @@ -671,7 +666,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, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); } ImGui::NextColumn(); const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll; @@ -840,7 +835,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, GetMainWindowNative, SetupScaleCallback ); + view = std::make_unique( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback ); } break; default: diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 1cf4cf22..ddb3c855 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -222,7 +222,7 @@ static void PrintSourceFragment( const SourceContents& src, uint32_t srcline, in enum { JumpSeparationBase = 6 }; enum { JumpArrowBase = 9 }; -SourceView::SourceView( GetWindowCallback gwcb ) +SourceView::SourceView() : m_font( nullptr ) , m_smallFont( nullptr ) , m_symAddr( 0 ) @@ -248,7 +248,6 @@ SourceView::SourceView( GetWindowCallback gwcb ) , m_showJumps( true ) , m_cpuArch( CpuArchUnknown ) , m_showLatency( false ) - , m_gwcb( gwcb ) { m_microArchOpMap.reserve( OpsNum ); for( int i=0; i, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, GetWindowCallback gwcb, SetScaleCallback sscb ) +View::View( void(*cbMainThread)(std::function, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb ) : m_worker( addr, port ) , m_staticView( false ) , m_viewMode( ViewMode::LastFrames ) @@ -60,7 +60,6 @@ View::View( void(*cbMainThread)(std::function, bool), const char* addr, , m_bigFont( bigFont ) , m_fixedFont( fixedWidth ) , m_stcb( stcb ) - , m_gwcb( gwcb ) , m_sscb( sscb ) , m_userData() , m_cbMainThread( cbMainThread ) @@ -72,7 +71,7 @@ View::View( void(*cbMainThread)(std::function, bool), const char* addr, InitTextEditor( fixedWidth ); } -View::View( void(*cbMainThread)(std::function, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, GetWindowCallback gwcb, SetScaleCallback sscb ) +View::View( void(*cbMainThread)(std::function, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb ) : m_worker( f ) , m_filename( f.GetFilename() ) , m_staticView( true ) @@ -83,7 +82,6 @@ View::View( void(*cbMainThread)(std::function, bool), FileRead& f, ImFon , m_bigFont( bigFont ) , m_fixedFont( fixedWidth ) , m_stcb( stcb ) - , m_gwcb( gwcb ) , m_sscb( sscb ) , m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() ) , m_cbMainThread( cbMainThread ) @@ -152,7 +150,7 @@ void View::InitMemory() void View::InitTextEditor( ImFont* font ) { - m_sourceView = std::make_unique( m_gwcb ); + m_sourceView = std::make_unique(); m_sourceViewFile = nullptr; } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 08222bd5..3604786b 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -94,12 +94,11 @@ public: }; using SetTitleCallback = void(*)( const char* ); - using GetWindowCallback = void*(*)(); using SetScaleCallback = void(*)( float, ImFont*&, ImFont*&, ImFont*& ); - View( void(*cbMainThread)(std::function, bool), ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, GetWindowCallback gwcb = nullptr, SetScaleCallback sscb = nullptr ) : View( cbMainThread, "127.0.0.1", 8086, fixedWidth, smallFont, bigFont, stcb, gwcb, sscb ) {} - View( void(*cbMainThread)(std::function, bool), const char* addr, uint16_t port, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, GetWindowCallback gwcb = nullptr, SetScaleCallback sscb = nullptr ); - View( void(*cbMainThread)(std::function, bool), FileRead& f, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, GetWindowCallback gwcb = nullptr, SetScaleCallback sscb = nullptr ); + View( void(*cbMainThread)(std::function, bool), ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, SetScaleCallback sscb = nullptr ) : View( cbMainThread, "127.0.0.1", 8086, fixedWidth, smallFont, bigFont, stcb, sscb ) {} + View( void(*cbMainThread)(std::function, bool), const char* addr, uint16_t port, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, SetScaleCallback sscb = nullptr ); + View( void(*cbMainThread)(std::function, bool), FileRead& f, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, SetScaleCallback sscb = nullptr ); ~View(); static bool Draw(); @@ -508,7 +507,6 @@ private: float m_rootWidth, m_rootHeight; SetTitleCallback m_stcb; bool m_titleSet = false; - GetWindowCallback m_gwcb; SetScaleCallback m_sscb; float m_notificationTime = 0;