mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add source location color retriever.
This commit is contained in:
parent
8d7299fe1f
commit
b7cd28ef72
@ -12856,13 +12856,11 @@ uint32_t View::GetZoneColor( const ZoneEvent& ev, uint64_t thread, int depth )
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t View::GetThreadColor( uint64_t thread, int depth )
|
||||
static uint32_t GetHsvColor( uint64_t hue, int value )
|
||||
{
|
||||
if( m_vd.dynamicColors == 0 ) return 0xFFCC5555;
|
||||
|
||||
const uint8_t h = ( thread * 11400714819323198485ull ) & 0xFF;
|
||||
const uint8_t h = ( hue * 11400714819323198485ull ) & 0xFF;
|
||||
const uint8_t s = 96;
|
||||
const uint8_t v = std::max( 96, 170 - depth * 8 );
|
||||
const uint8_t v = std::max( 96, 170 - value * 8 );
|
||||
|
||||
const uint8_t reg = h / 43;
|
||||
const uint8_t rem = ( h - ( reg * 43 ) ) * 6;
|
||||
@ -12886,14 +12884,14 @@ uint32_t View::GetThreadColor( uint64_t thread, int depth )
|
||||
return 0xFF000000 | ( r << 16 ) | ( g << 8 ) | b;
|
||||
}
|
||||
|
||||
uint32_t View::GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth )
|
||||
uint32_t View::GetThreadColor( uint64_t thread, int depth )
|
||||
{
|
||||
if( m_vd.dynamicColors == 0 ) return 0xFFCC5555;
|
||||
return GetHsvColor( thread, depth );
|
||||
}
|
||||
|
||||
uint32_t View::GetRawSrcLocColor( const SourceLocation& srcloc, int depth )
|
||||
{
|
||||
const auto sl = ev.SrcLoc();
|
||||
const auto& srcloc = m_worker.GetSourceLocation( sl );
|
||||
const auto color = srcloc.color;
|
||||
if( color != 0 ) return color | 0xFF000000;
|
||||
if( m_vd.dynamicColors == 2 )
|
||||
{
|
||||
auto namehash = srcloc.namehash;
|
||||
if( namehash == 0 && srcloc.function.active )
|
||||
{
|
||||
@ -12904,16 +12902,39 @@ uint32_t View::GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth
|
||||
}
|
||||
if( namehash == 0 )
|
||||
{
|
||||
return GetThreadColor( sl, depth );
|
||||
return GetHsvColor( uint64_t( &srcloc ), depth );
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetThreadColor( namehash, depth );
|
||||
return GetHsvColor( namehash, depth );
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
uint32_t View::GetSrcLocColor( const SourceLocation& srcloc, int depth )
|
||||
{
|
||||
const auto color = srcloc.color;
|
||||
if( color != 0 ) return color | 0xFF000000;
|
||||
if( m_vd.dynamicColors == 0 ) return 0xFFCC5555;
|
||||
return GetRawSrcLocColor( srcloc, depth );
|
||||
}
|
||||
|
||||
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 ) return color | 0xFF000000;
|
||||
switch( m_vd.dynamicColors )
|
||||
{
|
||||
return GetThreadColor( thread, depth );
|
||||
case 0:
|
||||
return 0xFFCC5555;
|
||||
case 1:
|
||||
return GetHsvColor( thread, depth );
|
||||
case 2:
|
||||
return GetRawSrcLocColor( srcloc, depth );
|
||||
default:
|
||||
assert( false );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,8 @@ private:
|
||||
void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns );
|
||||
|
||||
uint32_t GetThreadColor( uint64_t thread, int depth );
|
||||
uint32_t GetSrcLocColor( const SourceLocation& srcloc, int depth );
|
||||
uint32_t GetRawSrcLocColor( const SourceLocation& srcloc, int depth );
|
||||
uint32_t GetZoneColor( const ZoneEvent& ev, uint64_t thread, int depth );
|
||||
uint32_t GetZoneColor( const GpuEvent& ev );
|
||||
uint32_t GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth );
|
||||
|
Loading…
Reference in New Issue
Block a user