mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Adding ZoneColor to set a dynamic color override to an existing zone.
This commit is contained in:
committed by
Bartosz Taudul
parent
dfdf70aea3
commit
7dfdad2e02
@@ -207,6 +207,7 @@ struct ZoneExtra
|
||||
Int24 callstack;
|
||||
StringIdx text;
|
||||
StringIdx name;
|
||||
Int24 color;
|
||||
};
|
||||
|
||||
enum { ZoneExtraSize = sizeof( ZoneExtra ) };
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Version
|
||||
{
|
||||
enum { Major = 0 };
|
||||
enum { Minor = 7 };
|
||||
enum { Patch = 4 };
|
||||
enum { Patch = 5 };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -16561,8 +16561,16 @@ uint32_t View::GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth
|
||||
{
|
||||
const auto sl = ev.SrcLoc();
|
||||
const auto& srcloc = m_worker.GetSourceLocation( sl );
|
||||
const auto color = srcloc.color;
|
||||
if( color != 0 && !m_vd.forceColors ) return color | 0xFF000000;
|
||||
if( !m_vd.forceColors )
|
||||
{
|
||||
if( m_worker.HasZoneExtra( ev ) )
|
||||
{
|
||||
const auto custom_color = m_worker.GetZoneExtra( ev ).color.Val();
|
||||
if( custom_color != 0 ) return custom_color | 0xFF000000;
|
||||
}
|
||||
const auto color = srcloc.color;
|
||||
if( color != 0 ) return color | 0xFF000000;
|
||||
}
|
||||
switch( m_vd.dynamicColors )
|
||||
{
|
||||
case 0:
|
||||
|
||||
+40
-1
@@ -822,13 +822,25 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
||||
f.Skip( sz * ( sizeof( uint64_t ) + sizeof( MessageData::time ) + sizeof( MessageData::ref ) + sizeof( MessageData::color ) + sizeof( MessageData::callstack ) ) );
|
||||
}
|
||||
|
||||
if( fileVer >= FileVersion( 0, 6, 3 ) )
|
||||
if( fileVer >= FileVersion( 0, 7, 5 ) )
|
||||
{
|
||||
f.Read( sz );
|
||||
assert( sz != 0 );
|
||||
m_data.zoneExtra.reserve_exact( sz, m_slab );
|
||||
f.Read( m_data.zoneExtra.data(), sz * sizeof( ZoneExtra ) );
|
||||
}
|
||||
else if( fileVer >= FileVersion( 0, 6, 3 ) )
|
||||
{
|
||||
f.Read( sz );
|
||||
assert( sz != 0 );
|
||||
m_data.zoneExtra.reserve_exact( sz, m_slab );
|
||||
for( uint64_t i=0; i<sz; i++ )
|
||||
{
|
||||
auto* zoneExtra = &m_data.zoneExtra[i];
|
||||
f.Read3( zoneExtra->callstack, zoneExtra->text, zoneExtra->name );
|
||||
zoneExtra->color = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.zoneExtra.push_back( ZoneExtra {} );
|
||||
@@ -4116,6 +4128,9 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::ZoneName:
|
||||
ProcessZoneName();
|
||||
break;
|
||||
case QueueType::ZoneColor:
|
||||
ProcessZoneColor( ev.zoneColor );
|
||||
break;
|
||||
case QueueType::ZoneValue:
|
||||
ProcessZoneValue( ev.zoneValue );
|
||||
break;
|
||||
@@ -4506,6 +4521,12 @@ void Worker::ZoneTextFailure( uint64_t thread )
|
||||
m_failureData.thread = thread;
|
||||
}
|
||||
|
||||
void Worker::ZoneColorFailure( uint64_t thread )
|
||||
{
|
||||
m_failure = Failure::ZoneColor;
|
||||
m_failureData.thread = thread;
|
||||
}
|
||||
|
||||
void Worker::ZoneNameFailure( uint64_t thread )
|
||||
{
|
||||
m_failure = Failure::ZoneName;
|
||||
@@ -4738,6 +4759,23 @@ void Worker::ProcessZoneName()
|
||||
extra.name = StringIdx( GetSingleStringIdx() );
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneColor( const QueueZoneColor& ev )
|
||||
{
|
||||
auto td = RetrieveThread( m_threadCtx );
|
||||
if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() )
|
||||
{
|
||||
ZoneColorFailure( m_threadCtx );
|
||||
return;
|
||||
}
|
||||
|
||||
td->nextZoneId = 0;
|
||||
auto& stack = td->stack;
|
||||
auto zone = stack.back();
|
||||
auto& extra = RequestZoneExtra( *zone );
|
||||
const uint32_t color = ( ev.b << 16 ) | ( ev.g << 8 ) | ev.r;
|
||||
extra.color = color;
|
||||
}
|
||||
|
||||
void Worker::ProcessZoneValue( const QueueZoneValue& ev )
|
||||
{
|
||||
char tmp[32];
|
||||
@@ -7221,6 +7259,7 @@ static const char* s_failureReasons[] = {
|
||||
"Invalid order of zone begin and end events.",
|
||||
"Zone is ended twice.",
|
||||
"Zone text transfer destination doesn't match active zone.",
|
||||
"Zone color transfer destination doesn't match active zone.",
|
||||
"Zone name transfer destination doesn't match active zone.",
|
||||
"Memory free event without a matching allocation.",
|
||||
"Discontinuous frame begin/end mismatch.",
|
||||
|
||||
@@ -383,6 +383,7 @@ public:
|
||||
ZoneStack,
|
||||
ZoneDoubleEnd,
|
||||
ZoneText,
|
||||
ZoneColor,
|
||||
ZoneName,
|
||||
MemFree,
|
||||
FrameEnd,
|
||||
@@ -608,6 +609,7 @@ private:
|
||||
tracy_force_inline void ProcessFrameImage( const QueueFrameImage& ev );
|
||||
tracy_force_inline void ProcessZoneText();
|
||||
tracy_force_inline void ProcessZoneName();
|
||||
tracy_force_inline void ProcessZoneColor( const QueueZoneColor& ev );
|
||||
tracy_force_inline void ProcessZoneValue( const QueueZoneValue& ev );
|
||||
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
|
||||
tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev );
|
||||
@@ -670,6 +672,7 @@ private:
|
||||
void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev );
|
||||
void ZoneDoubleEndFailure( uint64_t thread, const ZoneEvent* ev );
|
||||
void ZoneTextFailure( uint64_t thread );
|
||||
void ZoneColorFailure( uint64_t thread );
|
||||
void ZoneNameFailure( uint64_t thread );
|
||||
void MemFreeFailure( uint64_t thread );
|
||||
void FrameEndFailure();
|
||||
|
||||
Reference in New Issue
Block a user