Skip to content

Commit

Permalink
Merge pull request #886 from mcourteaux/master
Browse files Browse the repository at this point in the history
Fix inheriting color bug.
  • Loading branch information
wolfpld authored Sep 14, 2024
2 parents 44d1502 + 0f60028 commit 758080e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions profiler/src/profiler/TracyTimelineItemThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ int TimelineItemThread::PreprocessGhostLevel( const TimelineContext& ctx, const
}
#endif

int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible, uint32_t inheritedColor )
int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible, const uint32_t inheritedColor )
{
if( vec.is_magic() )
{
Expand All @@ -413,7 +413,7 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V
}

template<typename Adapter, typename V>
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 } );
Expand Down
4 changes: 2 additions & 2 deletions profiler/src/profiler/TracyTimelineItemThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class TimelineItemThread final : public TimelineItem
#ifndef TRACY_NO_STATISTICS
int PreprocessGhostLevel( const TimelineContext& ctx, const Vector<GhostZone>& vec, int depth, bool visible );
#endif
int PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible, uint32_t inheritedColor );
int PreprocessZoneLevel( const TimelineContext& ctx, const Vector<short_ptr<ZoneEvent>>& vec, int depth, bool visible, const uint32_t inheritedColor );

template<typename Adapter, typename V>
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<SampleData>& vec, bool visible, int yPos );
Expand Down

0 comments on commit 758080e

Please sign in to comment.