mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Optional namespace shortening.
This commit is contained in:
parent
caec31731f
commit
5b20f0008f
@ -72,6 +72,7 @@ View::View( const char* addr )
|
|||||||
, m_drawLocks( true )
|
, m_drawLocks( true )
|
||||||
, m_drawPlots( true )
|
, m_drawPlots( true )
|
||||||
, m_onlyContendedLocks( false )
|
, m_onlyContendedLocks( false )
|
||||||
|
, m_namespace( Namespace::Full )
|
||||||
, m_terminate( false )
|
, m_terminate( false )
|
||||||
{
|
{
|
||||||
assert( s_instance == nullptr );
|
assert( s_instance == nullptr );
|
||||||
@ -107,6 +108,7 @@ View::View( FileRead& f )
|
|||||||
, m_drawLocks( true )
|
, m_drawLocks( true )
|
||||||
, m_drawPlots( true )
|
, m_drawPlots( true )
|
||||||
, m_onlyContendedLocks( false )
|
, m_onlyContendedLocks( false )
|
||||||
|
, m_namespace( Namespace::Full )
|
||||||
, m_terminate( false )
|
, m_terminate( false )
|
||||||
{
|
{
|
||||||
assert( s_instance == nullptr );
|
assert( s_instance == nullptr );
|
||||||
@ -1301,6 +1303,36 @@ const QueueSourceLocation& View::GetSourceLocation( uint64_t srcloc ) const
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* View::ShortenNamespace( const char* name ) const
|
||||||
|
{
|
||||||
|
if( m_namespace == Namespace::Full ) return name;
|
||||||
|
if( m_namespace == Namespace::Short )
|
||||||
|
{
|
||||||
|
auto ptr = name;
|
||||||
|
while( *ptr != '\0' ) ptr++;
|
||||||
|
while( ptr > name && *ptr != ':' ) ptr--;
|
||||||
|
if( *ptr == ':' ) ptr++;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char buf[1024];
|
||||||
|
auto dst = buf;
|
||||||
|
auto ptr = name;
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
auto start = ptr;
|
||||||
|
while( *ptr != '\0' && *ptr != ':' ) ptr++;
|
||||||
|
if( *ptr == '\0' )
|
||||||
|
{
|
||||||
|
memcpy( dst, start, ptr - start + 1 );
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
*dst++ = *start;
|
||||||
|
*dst++ = ':';
|
||||||
|
while( *ptr == ':' ) ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void View::Draw()
|
void View::Draw()
|
||||||
{
|
{
|
||||||
s_instance->DrawImpl();
|
s_instance->DrawImpl();
|
||||||
@ -2035,7 +2067,13 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
migration = true;
|
migration = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto tsz = ImGui::CalcTextSize( zoneName );
|
auto tsz = ImGui::CalcTextSize( zoneName );
|
||||||
|
if( tsz.x > zsz )
|
||||||
|
{
|
||||||
|
zoneName = ShortenNamespace( zoneName );
|
||||||
|
tsz = ImGui::CalcTextSize( zoneName );
|
||||||
|
}
|
||||||
|
|
||||||
const auto pr0 = ( ev.start - m_zvStart ) * pxns;
|
const auto pr0 = ( ev.start - m_zvStart ) * pxns;
|
||||||
const auto pr1 = ( end - m_zvStart ) * pxns;
|
const auto pr1 = ( end - m_zvStart ) * pxns;
|
||||||
const auto px0 = std::max( pr0, -10.0 );
|
const auto px0 = std::max( pr0, -10.0 );
|
||||||
@ -2751,6 +2789,9 @@ void View::DrawOptions()
|
|||||||
const auto tw = ImGui::GetFontSize();
|
const auto tw = ImGui::GetFontSize();
|
||||||
ImGui::Begin( "Options", &m_showOptions, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders );
|
ImGui::Begin( "Options", &m_showOptions, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders );
|
||||||
ImGui::Checkbox( "Draw zones", &m_drawZones );
|
ImGui::Checkbox( "Draw zones", &m_drawZones );
|
||||||
|
int ns = (int)m_namespace;
|
||||||
|
ImGui::Combo( "Namespaces", &ns, "Full\0Shortened\0None" );
|
||||||
|
m_namespace = (Namespace)ns;
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Checkbox( "Draw locks", &m_drawLocks );
|
ImGui::Checkbox( "Draw locks", &m_drawLocks );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
@ -38,6 +38,13 @@ public:
|
|||||||
static void Draw();
|
static void Draw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum class Namespace : uint8_t
|
||||||
|
{
|
||||||
|
Full,
|
||||||
|
Mid,
|
||||||
|
Short
|
||||||
|
};
|
||||||
|
|
||||||
struct MessagePending
|
struct MessagePending
|
||||||
{
|
{
|
||||||
int64_t time;
|
int64_t time;
|
||||||
@ -168,6 +175,8 @@ private:
|
|||||||
const char* GetThreadString( uint64_t id ) const;
|
const char* GetThreadString( uint64_t id ) const;
|
||||||
const QueueSourceLocation& GetSourceLocation( uint64_t srcloc ) const;
|
const QueueSourceLocation& GetSourceLocation( uint64_t srcloc ) const;
|
||||||
|
|
||||||
|
const char* ShortenNamespace( const char* name ) const;
|
||||||
|
|
||||||
void DrawImpl();
|
void DrawImpl();
|
||||||
void DrawConnection();
|
void DrawConnection();
|
||||||
void DrawFrames();
|
void DrawFrames();
|
||||||
@ -276,6 +285,8 @@ private:
|
|||||||
bool m_drawPlots;
|
bool m_drawPlots;
|
||||||
bool m_onlyContendedLocks;
|
bool m_onlyContendedLocks;
|
||||||
|
|
||||||
|
Namespace m_namespace;
|
||||||
|
|
||||||
bool m_terminate;
|
bool m_terminate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user