mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Pass function objects through const references.
This commit is contained in:
parent
778d0cb3fb
commit
a0221c8660
@ -11,7 +11,7 @@ class RunQueue;
|
||||
class Backend
|
||||
{
|
||||
public:
|
||||
Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks );
|
||||
Backend( const char* title, const std::function<void()>& redraw, RunQueue* mainThreadTasks );
|
||||
~Backend();
|
||||
|
||||
void Show();
|
||||
|
@ -60,7 +60,7 @@ static void glfw_window_iconify_callback( GLFWwindow*, int iconified )
|
||||
}
|
||||
|
||||
|
||||
Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks )
|
||||
Backend::Backend( const char* title, const std::function<void()>& redraw, RunQueue* mainThreadTasks )
|
||||
{
|
||||
glfwSetErrorCallback( glfw_error_callback );
|
||||
if( !glfwInit() ) exit( 1 );
|
||||
|
@ -630,7 +630,7 @@ static void SetupCursor()
|
||||
s_cursorY = cursor->images[0]->hotspot_y / s_maxScale;
|
||||
}
|
||||
|
||||
Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks )
|
||||
Backend::Backend( const char* title, const std::function<void()>& redraw, RunQueue* mainThreadTasks )
|
||||
{
|
||||
s_redraw = redraw;
|
||||
s_mainThreadTasks = mainThreadTasks;
|
||||
|
@ -72,7 +72,7 @@ static const char* GetOsInfo()
|
||||
return buf;
|
||||
}
|
||||
|
||||
void HttpRequest( const char* server, const char* resource, int port, std::function<void(int, char*)> cb )
|
||||
void HttpRequest( const char* server, const char* resource, int port, const std::function<void(int, char*)>& cb )
|
||||
{
|
||||
tracy::Socket sock;
|
||||
if( !sock.ConnectBlocking( server, port ) ) return;
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
void HttpRequest( const char* server, const char* resource, int port, std::function<void(int, char*)> cb );
|
||||
void HttpRequest( const char* server, const char* resource, int port, const std::function<void(int, char*)>& cb );
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@ RunQueue::RunQueue()
|
||||
{
|
||||
}
|
||||
|
||||
void RunQueue::Queue( std::function<void()> cb, bool forceDelay )
|
||||
void RunQueue::Queue( const std::function<void()>& cb, bool forceDelay )
|
||||
{
|
||||
if( !forceDelay && std::this_thread::get_id() == m_mainThread )
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ class RunQueue
|
||||
public:
|
||||
RunQueue();
|
||||
|
||||
void Queue( std::function<void()> cb, bool forceDelay = false );
|
||||
void Queue( const std::function<void()>& cb, bool forceDelay = false );
|
||||
void Run();
|
||||
|
||||
private:
|
||||
|
@ -114,7 +114,7 @@ static void AttentionCallback()
|
||||
|
||||
static void DrawContents();
|
||||
|
||||
void RunOnMainThread( std::function<void()> cb, bool forceDelay = false )
|
||||
static void RunOnMainThread( const std::function<void()>& cb, bool forceDelay = false )
|
||||
{
|
||||
mainThreadTasks.Queue( cb, forceDelay );
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ extern "C" int nativeOpenFile()
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool OpenFileImpl( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
static bool OpenFileImpl( const char* ext, const char* desc, const std::function<void(const char*)>& callback )
|
||||
{
|
||||
#ifndef TRACY_NO_FILESELECTOR
|
||||
# ifdef __EMSCRIPTEN__
|
||||
@ -93,7 +93,7 @@ static bool OpenFileImpl( const char* ext, const char* desc, std::function<void(
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool SaveFileImpl( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
static bool SaveFileImpl( const char* ext, const char* desc, const std::function<void(const char*)>& callback )
|
||||
{
|
||||
#if !defined TRACY_NO_FILESELECTOR && !defined __EMSCRIPTEN__
|
||||
nfdu8filteritem_t filter = { desc, ext };
|
||||
@ -113,12 +113,12 @@ static bool SaveFileImpl( const char* ext, const char* desc, std::function<void(
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
void OpenFile( const char* ext, const char* desc, const std::function<void(const char*)>& callback )
|
||||
{
|
||||
if( !OpenFileImpl( ext, desc, callback ) ) s_hasFailed = true;
|
||||
}
|
||||
|
||||
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
|
||||
void SaveFile( const char* ext, const char* desc, const std::function<void(const char*)>& callback )
|
||||
{
|
||||
if( !SaveFileImpl( ext, desc, callback ) ) s_hasFailed = true;
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ void Init();
|
||||
void Shutdown();
|
||||
bool HasFailed();
|
||||
|
||||
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
|
||||
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
|
||||
void OpenFile( const char* ext, const char* desc, const std::function<void(const char*)>& callback );
|
||||
void SaveFile( const char* ext, const char* desc, const std::function<void(const char*)>& callback );
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
m_pending.erase( pit );
|
||||
}
|
||||
|
||||
tracy_force_inline T Retrieve( uint64_t name, std::function<T(uint64_t)> Create, std::function<void(uint64_t)> Query )
|
||||
tracy_force_inline T Retrieve( uint64_t name, const std::function<T(uint64_t)>& Create, const std::function<void(uint64_t)>& Query )
|
||||
{
|
||||
auto it = m_map.find( name );
|
||||
if( it == m_map.end() )
|
||||
|
@ -51,7 +51,7 @@ void* MakeTexture()
|
||||
return (void*)(intptr_t)tex;
|
||||
}
|
||||
|
||||
void FreeTexture( void* _tex, void(*runOnMainThread)(std::function<void()>, bool) )
|
||||
void FreeTexture( void* _tex, void(*runOnMainThread)(const std::function<void()>&, bool) )
|
||||
{
|
||||
auto tex = (GLuint)(intptr_t)_tex;
|
||||
runOnMainThread( [tex] { glDeleteTextures( 1, &tex ); }, false );
|
||||
|
@ -8,7 +8,7 @@ namespace tracy
|
||||
|
||||
void InitTexture();
|
||||
void* MakeTexture();
|
||||
void FreeTexture( void* tex, void(*runOnMainThread)(std::function<void()>, bool) );
|
||||
void FreeTexture( void* tex, void(*runOnMainThread)(const std::function<void()>&, bool) );
|
||||
void UpdateTexture( void* tex, const char* data, int w, int h );
|
||||
void UpdateTextureRGBA( void* tex, void* data, int w, int h );
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace tracy
|
||||
|
||||
double s_time = 0;
|
||||
|
||||
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)(const 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_staticView( false )
|
||||
, m_viewMode( ViewMode::LastFrames )
|
||||
@ -68,7 +68,7 @@ View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr,
|
||||
InitTextEditor( fixedWidth );
|
||||
}
|
||||
|
||||
View::View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb )
|
||||
View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb )
|
||||
: m_worker( f )
|
||||
, m_filename( f.GetFilename() )
|
||||
, m_staticView( true )
|
||||
|
@ -99,8 +99,8 @@ public:
|
||||
using SetScaleCallback = void(*)( float, ImFont*&, ImFont*&, ImFont*& );
|
||||
using AttentionCallback = void(*)();
|
||||
|
||||
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( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb );
|
||||
View( void(*cbMainThread)(const std::function<void()>&, 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<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb );
|
||||
~View();
|
||||
|
||||
bool Draw();
|
||||
@ -259,7 +259,7 @@ private:
|
||||
void DrawSourceTooltip( const char* filename, uint32_t line, int before = 3, int after = 3, bool separateTooltip = true );
|
||||
void DrawWaitStacks();
|
||||
|
||||
void ListMemData( std::vector<const MemEvent*>& vec, std::function<void(const MemEvent*)> DrawAddress, const char* id = nullptr, int64_t startTime = -1, uint64_t pool = 0 );
|
||||
void ListMemData( std::vector<const MemEvent*>& vec, const std::function<void(const MemEvent*)>& DrawAddress, const char* id = nullptr, int64_t startTime = -1, uint64_t pool = 0 );
|
||||
|
||||
unordered_flat_map<uint32_t, MemPathData> GetCallstackPaths( const MemData& mem, MemRange memRange ) const;
|
||||
unordered_flat_map<uint64_t, MemCallstackFrameTree> GetCallstackFrameTreeBottomUp( const MemData& mem ) const;
|
||||
@ -578,7 +578,7 @@ private:
|
||||
|
||||
unordered_flat_map<const void*, bool> m_visMap;
|
||||
|
||||
void(*m_cbMainThread)(std::function<void()>, bool);
|
||||
void(*m_cbMainThread)(const std::function<void()>&, bool);
|
||||
|
||||
int m_gpuIdx = 0;
|
||||
|
||||
|
@ -650,7 +650,7 @@ void View::DrawMemoryAllocWindow()
|
||||
if( !show ) m_memoryAllocInfoWindow = -1;
|
||||
}
|
||||
|
||||
void View::ListMemData( std::vector<const MemEvent*>& vec, std::function<void(const MemEvent*)> DrawAddress, const char* id, int64_t startTime, uint64_t pool )
|
||||
void View::ListMemData( std::vector<const MemEvent*>& vec, const std::function<void(const MemEvent*)>& DrawAddress, const char* id, int64_t startTime, uint64_t pool )
|
||||
{
|
||||
if( startTime == -1 ) startTime = 0;
|
||||
if( ImGui::BeginTable( "##mem", 8, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_ScrollY, ImVec2( 0, ImGui::GetTextLineHeightWithSpacing() * std::min<int64_t>( 1+vec.size(), 15 ) ) ) )
|
||||
|
Loading…
Reference in New Issue
Block a user