mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Fix unstable zone grouping
The zone grouping was only taking into account the first zone for both its duration and width, which was wrong and could cause zones to "disappear" if the first zone of the group was really small. Grouping now works by taking into account the size of the zone and not the clipped to screen size for grouping decisions, to avoid having zone groups popping at the beginning and end of the window. In order to have consistent results and avoid popping, we're using the start of the last zone in a group as reference instead of its end. This means that it now includes the zone width, so that we make the same decisions wether we are in considering new zones in the loop or to start grouping zones. Altogether, this seems to have fixed any zone popping when panning, at the cost of not grouping the first/last zone if it is clipped, which seems to be less of an issue to me.
This commit is contained in:
parent
897aec5b06
commit
42ded3204b
@ -636,16 +636,15 @@ int View::DrawZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, co
|
|||||||
{
|
{
|
||||||
auto& ev = a(*it);
|
auto& ev = a(*it);
|
||||||
const auto end = m_worker.GetZoneEnd( ev );
|
const auto end = m_worker.GetZoneEnd( ev );
|
||||||
const auto zsz = std::max( ( std::min( m_vd.zvEnd, end ) - std::max( m_vd.zvStart, ev.Start() ) ) * pxns, pxns * 0.5 );
|
const auto zsz = std::max( (end - ev.Start()) * pxns, pxns * 0.5 );
|
||||||
if( zsz < MinVisSize )
|
if( zsz < MinVisSize )
|
||||||
{
|
{
|
||||||
const auto MinVisNs = MinVisSize * nspx;
|
const auto MinVisNs = MinVisSize * nspx;
|
||||||
const auto color = GetThreadColor( tid, depth );
|
const auto color = GetThreadColor( tid, depth );
|
||||||
int num = 0;
|
int num = 0;
|
||||||
const auto px0 = ( ev.Start() - m_vd.zvStart ) * pxns;
|
const auto px0 = ( ev.Start() - m_vd.zvStart ) * pxns;
|
||||||
auto px1ns = end - m_vd.zvStart;
|
|
||||||
auto rend = end;
|
|
||||||
auto nextTime = end + MinVisNs;
|
auto nextTime = end + MinVisNs;
|
||||||
|
auto lastZoneInGroupStart = ev.Start();
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
const auto prevIt = it;
|
const auto prevIt = it;
|
||||||
@ -654,12 +653,15 @@ int View::DrawZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, co
|
|||||||
num += std::distance( prevIt, it );
|
num += std::distance( prevIt, it );
|
||||||
if( it == zitend ) break;
|
if( it == zitend ) break;
|
||||||
const auto nend = m_worker.GetZoneEnd( a(*it) );
|
const auto nend = m_worker.GetZoneEnd( a(*it) );
|
||||||
const auto nsnext = nend - m_vd.zvStart;
|
if(nend - lastZoneInGroupStart >= MinVisNs * 2 ) break;
|
||||||
if( nsnext - px1ns >= MinVisNs * 2 ) break;
|
lastZoneInGroupStart = a(*it).Start();
|
||||||
px1ns = nsnext;
|
|
||||||
rend = nend;
|
|
||||||
nextTime = nend + nspx;
|
nextTime = nend + nspx;
|
||||||
}
|
}
|
||||||
|
auto lastZoneInGroupIt = it;
|
||||||
|
lastZoneInGroupIt--;
|
||||||
|
auto rend = m_worker.GetZoneEnd(a(*lastZoneInGroupIt));
|
||||||
|
auto px1ns = rend - m_vd.zvStart;
|
||||||
|
|
||||||
const auto px1 = px1ns * pxns;
|
const auto px1 = px1ns * pxns;
|
||||||
draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ), color );
|
draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), offset + ty ), color );
|
||||||
DrawZigZag( draw, wpos + ImVec2( 0, offset + ty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), ty/4, DarkenColor( color ) );
|
DrawZigZag( draw, wpos + ImVec2( 0, offset + ty/2 ), std::max( px0, -10.0 ), std::min( std::max( px1, px0+MinVisSize ), double( w + 10 ) ), ty/4, DarkenColor( color ) );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user