From 0f6002822cf7253026e6b408b14b202f55dc8994 Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Sat, 14 Sep 2024 14:10:55 +0200 Subject: [PATCH] Fix inheriting color bug. --- profiler/src/profiler/TracyTimelineItemThread.cpp | 9 +++++---- profiler/src/profiler/TracyTimelineItemThread.hpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/profiler/src/profiler/TracyTimelineItemThread.cpp b/profiler/src/profiler/TracyTimelineItemThread.cpp index 60b11037d6..1831a1aac6 100644 --- a/profiler/src/profiler/TracyTimelineItemThread.cpp +++ b/profiler/src/profiler/TracyTimelineItemThread.cpp @@ -400,7 +400,7 @@ int TimelineItemThread::PreprocessGhostLevel( const TimelineContext& ctx, const } #endif -int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const Vector>& vec, int depth, bool visible, uint32_t inheritedColor ) +int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const Vector>& vec, int depth, bool visible, const uint32_t inheritedColor ) { if( vec.is_magic() ) { @@ -413,7 +413,7 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V } template -int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, uint32_t inheritedColor ) +int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, const uint32_t inheritedColor ) { const auto vStart = ctx.vStart; const auto vEnd = ctx.vEnd; @@ -458,6 +458,7 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V { const auto hasChildren = ev.HasChildren(); auto currentInherited = inheritedColor; + auto childrenInherited = inheritedColor; if( m_view.GetViewData().inheritParentColors ) { uint32_t color = 0; @@ -474,12 +475,12 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V if( color != 0 ) { currentInherited = color | 0xFF000000; - if( hasChildren ) inheritedColor = DarkenColorSlightly( color ); + if( hasChildren ) childrenInherited = DarkenColorSlightly( color ); } } if( hasChildren ) { - const auto d = PreprocessZoneLevel( ctx, m_worker.GetZoneChildren( ev.Child() ), depth + 1, visible, inheritedColor ); + const auto d = PreprocessZoneLevel( ctx, m_worker.GetZoneChildren( ev.Child() ), depth + 1, visible, childrenInherited ); if( d > maxdepth ) maxdepth = d; } if( visible ) m_draw.emplace_back( TimelineDraw { TimelineDrawType::Zone, uint16_t( depth ), (void**)&ev, 0, 0, currentInherited } ); diff --git a/profiler/src/profiler/TracyTimelineItemThread.hpp b/profiler/src/profiler/TracyTimelineItemThread.hpp index 61e41d34ed..db93801c1e 100644 --- a/profiler/src/profiler/TracyTimelineItemThread.hpp +++ b/profiler/src/profiler/TracyTimelineItemThread.hpp @@ -37,10 +37,10 @@ class TimelineItemThread final : public TimelineItem #ifndef TRACY_NO_STATISTICS int PreprocessGhostLevel( const TimelineContext& ctx, const Vector& vec, int depth, bool visible ); #endif - int PreprocessZoneLevel( const TimelineContext& ctx, const Vector>& vec, int depth, bool visible, uint32_t inheritedColor ); + int PreprocessZoneLevel( const TimelineContext& ctx, const Vector>& vec, int depth, bool visible, const uint32_t inheritedColor ); template - int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, uint32_t inheritedColor ); + int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, const uint32_t inheritedColor ); void PreprocessContextSwitches( const TimelineContext& ctx, const ContextSwitch& ctxSwitch, bool visible ); void PreprocessSamples( const TimelineContext& ctx, const Vector& vec, bool visible, int yPos );