Commit 170a436a authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Nate Graham
Browse files

effects: Properly reset present times in coverswitch and flipswitch effects

The last presentation timestamps should be reset when all animations
finish rather than when the effect finishes. Otherwise, the calculated
time diff for the first animation frame will be too big.

BUG: 433471


(cherry picked from commit 5839e59e)
parent 3a51749f
......@@ -106,15 +106,14 @@ void CoverSwitchEffect::reconfigure(ReconfigureFlags)
void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime)
{
std::chrono::milliseconds delta = std::chrono::milliseconds::zero();
if (lastPresentTime.count()) {
delta = presentTime - lastPresentTime;
}
lastPresentTime = presentTime;
if (mActivated || stop || stopRequested) {
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
if (animation || start || stop) {
std::chrono::milliseconds delta = std::chrono::milliseconds::zero();
if (lastPresentTime.count()) {
delta = presentTime - lastPresentTime;
}
lastPresentTime = presentTime;
timeLine.update(delta);
}
if (selected_window == nullptr)
......@@ -284,6 +283,7 @@ void CoverSwitchEffect::postPaintScreen()
if ((mActivated && (animation || start)) || stop || stopRequested) {
if (timeLine.done()) {
timeLine.reset();
lastPresentTime = std::chrono::milliseconds::zero();
if (stop) {
stop = false;
effects->setActiveFullScreenEffect(nullptr);
......@@ -292,7 +292,6 @@ void CoverSwitchEffect::postPaintScreen()
}
referrencedWindows.clear();
currentWindowList.clear();
lastPresentTime = std::chrono::milliseconds::zero();
if (startRequested) {
startRequested = false;
mActivated = true;
......
......@@ -97,20 +97,21 @@ void FlipSwitchEffect::reconfigure(ReconfigureFlags)
void FlipSwitchEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime)
{
int time = 0;
if (m_lastPresentTime.count()) {
time = (presentTime - m_lastPresentTime).count();
if (m_animation || m_start || m_stop) {
if (m_lastPresentTime.count()) {
time = (presentTime - m_lastPresentTime).count();
}
m_lastPresentTime = presentTime;
}
m_lastPresentTime = presentTime;
if (m_active) {
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
if (m_start)
m_startStopTimeLine.setCurrentTime(m_startStopTimeLine.currentTime() + time);
if (m_stop && m_scheduledDirections.isEmpty())
m_startStopTimeLine.setCurrentTime(m_startStopTimeLine.currentTime() - time);
if (m_animation)
m_timeLine.setCurrentTime(m_timeLine.currentTime() + time);
}
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
if (m_start)
m_startStopTimeLine.setCurrentTime(m_startStopTimeLine.currentTime() + time);
if (m_stop && m_scheduledDirections.isEmpty())
m_startStopTimeLine.setCurrentTime(m_startStopTimeLine.currentTime() - time);
if (m_animation)
m_timeLine.setCurrentTime(m_timeLine.currentTime() + time);
effects->prePaintScreen(data, presentTime);
}
......@@ -325,7 +326,6 @@ void FlipSwitchEffect::postPaintScreen()
m_stop = false;
m_active = false;
m_captionFrame->free();
m_lastPresentTime = std::chrono::milliseconds::zero();
effects->setActiveFullScreenEffect(nullptr);
effects->addRepaintFull();
qDeleteAll(m_windows);
......@@ -351,6 +351,8 @@ void FlipSwitchEffect::postPaintScreen()
}
if (m_start || m_stop || m_animation)
effects->addRepaintFull();
else
m_lastPresentTime = std::chrono::milliseconds::zero();
}
effects->postPaintScreen();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment