hiding internal class in an anonymous namespace

This commit is contained in:
Uwe Rathmann 2021-12-09 17:32:22 +01:00
parent b0cbb4f9e4
commit 2b9eef700c
1 changed files with 47 additions and 45 deletions

View File

@ -68,17 +68,19 @@ namespace
}; };
} }
/* namespace
{
/*
We need to have at least one QObject to connect to QQuickWindow We need to have at least one QObject to connect to QQuickWindow
updates - but then we can advance the animators manually without updates - but then we can advance the animators manually without
making them heavy QObjects too. making them heavy QObjects too.
*/ */
class QskAnimatorDriver final : public QObject class AnimatorDriver final : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QskAnimatorDriver(); AnimatorDriver();
void registerAnimator( QskAnimator* ); void registerAnimator( QskAnimator* );
void unregisterAnimator( QskAnimator* ); void unregisterAnimator( QskAnimator* );
@ -105,21 +107,21 @@ class QskAnimatorDriver final : public QObject
creates more overhead than being good for something. creates more overhead than being good for something.
*/ */
QVector< QQuickWindow* > m_windows; QVector< QQuickWindow* > m_windows;
mutable int m_index; // current value, when iterating mutable int m_index = -1; // current value, when iterating
}; };
}
QskAnimatorDriver::QskAnimatorDriver() AnimatorDriver::AnimatorDriver()
: m_index( -1 )
{ {
m_referenceTime.start(); m_referenceTime.start();
} }
inline qint64 QskAnimatorDriver::referenceTime() const inline qint64 AnimatorDriver::referenceTime() const
{ {
return m_referenceTime.elapsed(); return m_referenceTime.elapsed();
} }
void QskAnimatorDriver::registerAnimator( QskAnimator* animator ) void AnimatorDriver::registerAnimator( QskAnimator* animator )
{ {
Q_ASSERT( animator->window() ); Q_ASSERT( animator->window() );
@ -160,13 +162,13 @@ void QskAnimatorDriver::registerAnimator( QskAnimator* animator )
} }
} }
void QskAnimatorDriver::scheduleUpdate( QQuickWindow* window ) void AnimatorDriver::scheduleUpdate( QQuickWindow* window )
{ {
if ( m_windows.contains( window ) ) if ( m_windows.contains( window ) )
window->update(); window->update();
} }
void QskAnimatorDriver::removeWindow( QQuickWindow* window ) void AnimatorDriver::removeWindow( QQuickWindow* window )
{ {
window->disconnect( this ); window->disconnect( this );
m_windows.removeOne( window ); m_windows.removeOne( window );
@ -180,7 +182,7 @@ void QskAnimatorDriver::removeWindow( QQuickWindow* window )
} }
} }
void QskAnimatorDriver::unregisterAnimator( QskAnimator* animator ) void AnimatorDriver::unregisterAnimator( QskAnimator* animator )
{ {
auto it = std::find( m_animators.begin(), m_animators.end(), animator ); auto it = std::find( m_animators.begin(), m_animators.end(), animator );
if ( it != m_animators.end() ) if ( it != m_animators.end() )
@ -192,7 +194,7 @@ void QskAnimatorDriver::unregisterAnimator( QskAnimator* animator )
} }
} }
void QskAnimatorDriver::advanceAnimators( QQuickWindow* window ) void AnimatorDriver::advanceAnimators( QQuickWindow* window )
{ {
bool hasAnimators = false; bool hasAnimators = false;
bool hasTerminations = false; bool hasTerminations = false;
@ -231,7 +233,7 @@ void QskAnimatorDriver::advanceAnimators( QQuickWindow* window )
Q_EMIT terminated( window ); Q_EMIT terminated( window );
} }
Q_GLOBAL_STATIC( QskAnimatorDriver, qskAnimatorDriver ) Q_GLOBAL_STATIC( AnimatorDriver, qskAnimatorDriver )
Q_GLOBAL_STATIC( Statistics, qskStatistics ) Q_GLOBAL_STATIC( Statistics, qskStatistics )
QskAnimator::QskAnimator() QskAnimator::QskAnimator()