mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 01:25:58 +01:00
animationmanager: optimize avar state
This commit is contained in:
parent
80cd2ef3d7
commit
7091d4e597
2 changed files with 13 additions and 14 deletions
|
@ -148,17 +148,8 @@ class CAnimatedVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if an animation is in progress
|
// checks if an animation is in progress
|
||||||
bool isBeingAnimated() {
|
inline bool isBeingAnimated() {
|
||||||
switch (m_eVarType) {
|
return m_bIsBeingAnimated;
|
||||||
case AVARTYPE_FLOAT: return m_fValue != m_fGoal;
|
|
||||||
case AVARTYPE_VECTOR: return m_vValue != m_vGoal;
|
|
||||||
case AVARTYPE_COLOR: return m_cValue != m_cGoal;
|
|
||||||
default: UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
UNREACHABLE();
|
|
||||||
|
|
||||||
return false; // just so that the warning is suppressed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void warp(bool endCallback = true) {
|
void warp(bool endCallback = true) {
|
||||||
|
@ -178,6 +169,8 @@ class CAnimatedVariable {
|
||||||
default: UNREACHABLE();
|
default: UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_bIsBeingAnimated = false;
|
||||||
|
|
||||||
if (endCallback)
|
if (endCallback)
|
||||||
onAnimationEnd();
|
onAnimationEnd();
|
||||||
}
|
}
|
||||||
|
@ -253,6 +246,7 @@ class CAnimatedVariable {
|
||||||
|
|
||||||
bool m_bDummy = true;
|
bool m_bDummy = true;
|
||||||
bool m_bIsRegistered = false;
|
bool m_bIsRegistered = false;
|
||||||
|
bool m_bIsBeingAnimated = false;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point animationBegin;
|
std::chrono::system_clock::time_point animationBegin;
|
||||||
|
|
||||||
|
@ -267,6 +261,8 @@ class CAnimatedVariable {
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void onAnimationEnd() {
|
void onAnimationEnd() {
|
||||||
|
m_bIsBeingAnimated = false;
|
||||||
|
|
||||||
if (m_fEndCallback) {
|
if (m_fEndCallback) {
|
||||||
// loading m_bRemoveEndAfterRan before calling the callback allows the callback to delete this animation safely if it is false.
|
// loading m_bRemoveEndAfterRan before calling the callback allows the callback to delete this animation safely if it is false.
|
||||||
auto removeEndCallback = m_bRemoveEndAfterRan;
|
auto removeEndCallback = m_bRemoveEndAfterRan;
|
||||||
|
@ -277,6 +273,8 @@ class CAnimatedVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAnimationBegin() {
|
void onAnimationBegin() {
|
||||||
|
m_bIsBeingAnimated = true;
|
||||||
|
|
||||||
if (m_fBeginCallback) {
|
if (m_fBeginCallback) {
|
||||||
m_fBeginCallback(this);
|
m_fBeginCallback(this);
|
||||||
if (m_bRemoveBeginAfterRan)
|
if (m_bRemoveBeginAfterRan)
|
||||||
|
|
|
@ -61,7 +61,8 @@ void CAnimationManager::tick() {
|
||||||
for (auto& av : m_lAnimatedVariables) {
|
for (auto& av : m_lAnimatedVariables) {
|
||||||
|
|
||||||
// first of all, check if we need to update it at all
|
// first of all, check if we need to update it at all
|
||||||
if (!av->isBeingAnimated())
|
// TODO: this has a 100% cache miss rate, maybe move active avars to a separate vec
|
||||||
|
if (!av->m_bIsBeingAnimated)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (av->m_eDamagePolicy == AVARDAMAGE_SHADOW && !*PSHADOWSENABLED) {
|
if (av->m_eDamagePolicy == AVARDAMAGE_SHADOW && !*PSHADOWSENABLED) {
|
||||||
|
|
Loading…
Reference in a new issue