Extract UpdateZoomAnimation.

This will allow for it to be used in the flame graph.
This commit is contained in:
rmarker
2026-05-28 22:01:03 +09:30
parent 30fd92de0f
commit 17f6be4ad4
3 changed files with 27 additions and 18 deletions

View File

@@ -8,7 +8,6 @@
#include <algorithm>
#include <assert.h>
#include <inttypes.h>
#include <math.h>
#include <mutex>
#include "imgui.h"
@@ -29,10 +28,6 @@
#include "imgui_internal.h"
#include "IconsFontAwesome6.h"
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
namespace tracy
{
@@ -1251,19 +1246,7 @@ bool View::DrawImpl()
m_zoomAnim.end1 += delta;
}
}
m_zoomAnim.progress += io.DeltaTime * 3.33f;
if( m_zoomAnim.progress >= 1.f )
{
m_zoomAnim.active = false;
m_vd.zvStart = m_zoomAnim.start1;
m_vd.zvEnd = m_zoomAnim.end1;
}
else
{
const auto v = sqrt( sin( M_PI_2 * m_zoomAnim.progress ) );
m_vd.zvStart = int64_t( m_zoomAnim.start0 + ( m_zoomAnim.start1 - m_zoomAnim.start0 ) * v );
m_vd.zvEnd = int64_t( m_zoomAnim.end0 + ( m_zoomAnim.end1 - m_zoomAnim.end0 ) * v );
}
UpdateZoomAnimation( m_zoomAnim, m_vd.zvStart, m_vd.zvEnd, io.DeltaTime );
}
bool active = m_wasActive.load( std::memory_order_acquire );

View File

@@ -372,6 +372,7 @@ private:
void ZoomToPrevFrame();
void ZoomToNextFrame();
void CenterAtTime( int64_t t );
void UpdateZoomAnimation( Animation& anim, int64_t& start, int64_t& end, float deltaTime );
void ShowZoneInfo( const ZoneEvent& ev );
void ShowZoneInfo( const GpuEvent& ev, uint64_t thread );

View File

@@ -1,5 +1,11 @@
#include <math.h>
#include "TracyView.hpp"
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
namespace tracy
{
@@ -72,6 +78,25 @@ void View::ZoomToRange( int64_t start, int64_t end, bool pause )
m_zoomAnim.progress = 0;
}
void View::UpdateZoomAnimation( Animation& anim, int64_t& start, int64_t& end, float deltaTime )
{
if( !anim.active ) return;
anim.progress += deltaTime * 3.33f;
if( anim.progress >= 1.f )
{
anim.active = false;
start = anim.start1;
end = anim.end1;
}
else
{
const auto v = sqrt( sin( M_PI_2 * anim.progress ) );
start = int64_t( anim.start0 + ( anim.start1 - anim.start0 ) * v );
end = int64_t( anim.end0 + ( anim.end1 - anim.end0 ) * v );
}
}
void View::ZoomToPrevFrame()
{
if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )