1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Store zone text data in a separate structure.

This commit is contained in:
Bartosz Taudul 2017-09-28 19:06:39 +02:00
parent 7f865f3517
commit 91e6210e34
2 changed files with 16 additions and 5 deletions

View File

@ -6,13 +6,18 @@
namespace tracy namespace tracy
{ {
struct TextData
{
const char* userText;
};
struct Event struct Event
{ {
int64_t start; int64_t start;
int64_t end; int64_t end;
uint64_t srcloc; uint64_t srcloc;
const char* text; TextData* text;
Event* parent; Event* parent;
Vector<Event*> child; Vector<Event*> child;
}; };

View File

@ -19,6 +19,12 @@
namespace tracy namespace tracy
{ {
static TextData* GetTextData( Event& zone )
{
if( !zone.text ) zone.text = new TextData {};
return zone.text;
}
static View* s_instance = nullptr; static View* s_instance = nullptr;
View::View( const char* addr ) View::View( const char* addr )
@ -393,12 +399,12 @@ void View::AddCustomString( uint64_t ptr, std::string&& str )
auto ptr = new char[sz+1]; auto ptr = new char[sz+1];
memcpy( ptr, str.c_str(), sz ); memcpy( ptr, str.c_str(), sz );
ptr[sz] = '\0'; ptr[sz] = '\0';
pit->second->text = ptr; GetTextData( *pit->second )->userText = ptr;
m_customStrings.emplace( ptr ); m_customStrings.emplace( ptr );
} }
else else
{ {
pit->second->text = *sit; GetTextData( *pit->second )->userText = *sit;
} }
m_pendingCustomStrings.erase( pit ); m_pendingCustomStrings.erase( pit );
} }
@ -1175,10 +1181,10 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
ImGui::Text( "%s:%i", filename, line ); ImGui::Text( "%s:%i", filename, line );
ImGui::Text( "Execution time: %s", TimeToString( end - ev.start ) ); ImGui::Text( "Execution time: %s", TimeToString( end - ev.start ) );
ImGui::Text( "Without profiling: %s", TimeToString( end - ev.start - m_delay ) ); ImGui::Text( "Without profiling: %s", TimeToString( end - ev.start - m_delay ) );
if( ev.text ) if( ev.text && ev.text->userText )
{ {
ImGui::Text( "" ); ImGui::Text( "" );
ImGui::TextColored( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), "%s", ev.text ); ImGui::TextColored( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), "%s", ev.text->userText );
} }
ImGui::EndTooltip(); ImGui::EndTooltip();