1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 04:43:53 +00:00

Add source location color retriever.

This commit is contained in:
Bartosz Taudul 2019-11-02 22:45:11 +01:00
parent 8d7299fe1f
commit b7cd28ef72
2 changed files with 49 additions and 26 deletions

View File

@ -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 = ( hue * 11400714819323198485ull ) & 0xFF;
const uint8_t h = ( thread * 11400714819323198485ull ) & 0xFF;
const uint8_t s = 96; 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 reg = h / 43;
const uint8_t rem = ( h - ( reg * 43 ) ) * 6; 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; 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; auto namehash = srcloc.namehash;
if( namehash == 0 && srcloc.function.active ) 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 ) if( namehash == 0 )
{ {
return GetThreadColor( sl, depth ); return GetHsvColor( uint64_t( &srcloc ), depth );
} }
else 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;
} }
} }

View File

@ -165,6 +165,8 @@ private:
void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns ); void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns );
uint32_t GetThreadColor( uint64_t thread, int depth ); 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 ZoneEvent& ev, uint64_t thread, int depth );
uint32_t GetZoneColor( const GpuEvent& ev ); uint32_t GetZoneColor( const GpuEvent& ev );
uint32_t GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth ); uint32_t GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth );