2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "fallapart.h"
|
2016-11-16 07:13:38 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "fallapartconfig.h"
|
2019-07-09 19:19:26 +00:00
|
|
|
|
|
|
|
#include <cmath>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-06-22 14:09:14 +00:00
|
|
|
bool FallApartEffect::supported()
|
|
|
|
{
|
2016-08-10 07:24:53 +00:00
|
|
|
return effects->isOpenGLCompositing() && effects->animationsSupported();
|
2013-06-22 14:09:14 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-09-07 21:52:51 +00:00
|
|
|
FallApartEffect::FallApartEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2016-12-02 19:27:43 +00:00
|
|
|
initConfig<FallApartConfig>();
|
2011-01-30 14:34:42 +00:00
|
|
|
reconfigure(ReconfigureAll);
|
2019-01-01 20:48:53 +00:00
|
|
|
connect(effects, &EffectsHandler::windowClosed, this, &FallApartEffect::slotWindowClosed);
|
|
|
|
connect(effects, &EffectsHandler::windowDeleted, this, &FallApartEffect::slotWindowDeleted);
|
|
|
|
connect(effects, &EffectsHandler::windowDataChanged, this, &FallApartEffect::slotWindowDataChanged);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-09-07 21:52:51 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void FallApartEffect::reconfigure(ReconfigureFlags)
|
|
|
|
{
|
2016-11-16 07:13:38 +00:00
|
|
|
FallApartConfig::self()->read();
|
|
|
|
blockSize = FallApartConfig::blockSize();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-09-07 21:52:51 +00:00
|
|
|
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
void FallApartEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!windows.isEmpty())
|
2007-07-07 14:01:32 +00:00
|
|
|
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
effects->prePaintScreen(data, presentTime);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
void FallApartEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
auto animationIt = windows.find(w);
|
|
|
|
if (animationIt != windows.end() && isRealWindow(w)) {
|
|
|
|
if (animationIt->progress < 1) {
|
|
|
|
int time = 0;
|
|
|
|
if (animationIt->lastPresentTime.count()) {
|
|
|
|
time = (presentTime - animationIt->lastPresentTime).count();
|
|
|
|
}
|
|
|
|
animationIt->lastPresentTime = presentTime;
|
|
|
|
|
|
|
|
animationIt->progress += time / animationTime(1000.);
|
2007-07-19 14:05:59 +00:00
|
|
|
data.setTransformed();
|
2011-01-30 14:34:42 +00:00
|
|
|
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
2007-04-29 17:35:43 +00:00
|
|
|
// Request the window to be divided into cells
|
2011-01-30 14:34:42 +00:00
|
|
|
data.quads = data.quads.makeGrid(blockSize);
|
|
|
|
} else {
|
|
|
|
windows.remove(w);
|
2007-04-29 17:35:43 +00:00
|
|
|
w->unrefWindow();
|
|
|
|
}
|
|
|
|
}
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
effects->prePaintWindow(w, data, presentTime);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
auto animationIt = windows.constFind(w);
|
|
|
|
if (animationIt != windows.constEnd() && isRealWindow(w)) {
|
|
|
|
const qreal t = animationIt->progress;
|
2007-07-07 14:01:32 +00:00
|
|
|
WindowQuadList new_quads;
|
|
|
|
int cnt = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (WindowQuad quad, data.quads) { // krazy:exclude=foreach
|
2007-04-29 17:35:43 +00:00
|
|
|
// make fragments move in various directions, based on where
|
|
|
|
// they are (left pieces generally move to the left, etc.)
|
2011-01-30 14:34:42 +00:00
|
|
|
QPointF p1(quad[ 0 ].x(), quad[ 0 ].y());
|
2007-09-03 15:00:43 +00:00
|
|
|
double xdiff = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (p1.x() < w->width() / 2)
|
|
|
|
xdiff = -(w->width() / 2 - p1.x()) / w->width() * 100;
|
|
|
|
if (p1.x() > w->width() / 2)
|
|
|
|
xdiff = (p1.x() - w->width() / 2) / w->width() * 100;
|
2007-09-03 15:00:43 +00:00
|
|
|
double ydiff = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (p1.y() < w->height() / 2)
|
|
|
|
ydiff = -(w->height() / 2 - p1.y()) / w->height() * 100;
|
|
|
|
if (p1.y() > w->height() / 2)
|
|
|
|
ydiff = (p1.y() - w->height() / 2) / w->height() * 100;
|
2018-06-14 10:30:52 +00:00
|
|
|
double modif = t * t * 64;
|
2011-01-30 14:34:42 +00:00
|
|
|
srandom(cnt); // change direction randomly but consistently
|
|
|
|
xdiff += (rand() % 21 - 10);
|
|
|
|
ydiff += (rand() % 21 - 10);
|
|
|
|
for (int j = 0;
|
|
|
|
j < 4;
|
|
|
|
++j) {
|
|
|
|
quad[ j ].move(quad[ j ].x() + xdiff * modif, quad[ j ].y() + ydiff * modif);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// also make the fragments rotate around their center
|
2011-01-30 14:34:42 +00:00
|
|
|
QPointF center((quad[ 0 ].x() + quad[ 1 ].x() + quad[ 2 ].x() + quad[ 3 ].x()) / 4,
|
|
|
|
(quad[ 0 ].y() + quad[ 1 ].y() + quad[ 2 ].y() + quad[ 3 ].y()) / 4);
|
|
|
|
double adiff = (rand() % 720 - 360) / 360. * 2 * M_PI; // spin randomly
|
|
|
|
for (int j = 0;
|
|
|
|
j < 4;
|
|
|
|
++j) {
|
2007-09-03 15:00:43 +00:00
|
|
|
double x = quad[ j ].x() - center.x();
|
|
|
|
double y = quad[ j ].y() - center.y();
|
2011-01-30 14:34:42 +00:00
|
|
|
double angle = atan2(y, x);
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
angle += animationIt->progress * adiff;
|
2011-01-30 14:34:42 +00:00
|
|
|
double dist = sqrt(x * x + y * y);
|
|
|
|
x = dist * cos(angle);
|
|
|
|
y = dist * sin(angle);
|
|
|
|
quad[ j ].move(center.x() + x, center.y() + y);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
new_quads.append(quad);
|
|
|
|
++cnt;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
data.quads = new_quads;
|
2018-06-14 10:30:52 +00:00
|
|
|
data.multiplyOpacity(interpolate(1.0, 0.0, t));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void FallApartEffect::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!windows.isEmpty())
|
2007-04-29 17:35:43 +00:00
|
|
|
effects->addRepaintFull();
|
|
|
|
effects->postPaintScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool FallApartEffect::isRealWindow(EffectWindow* w)
|
|
|
|
{
|
2008-06-30 12:52:06 +00:00
|
|
|
// TODO: isSpecialWindow is rather generic, maybe tell windowtypes separately?
|
|
|
|
/*
|
2013-11-29 05:18:28 +00:00
|
|
|
qCDebug(KWINEFFECTS) << "--" << w->caption() << "--------------------------------";
|
|
|
|
qCDebug(KWINEFFECTS) << "Tooltip:" << w->isTooltip();
|
|
|
|
qCDebug(KWINEFFECTS) << "Toolbar:" << w->isToolbar();
|
|
|
|
qCDebug(KWINEFFECTS) << "Desktop:" << w->isDesktop();
|
|
|
|
qCDebug(KWINEFFECTS) << "Special:" << w->isSpecialWindow();
|
|
|
|
qCDebug(KWINEFFECTS) << "TopMenu:" << w->isTopMenu();
|
|
|
|
qCDebug(KWINEFFECTS) << "Notific:" << w->isNotification();
|
|
|
|
qCDebug(KWINEFFECTS) << "Splash:" << w->isSplash();
|
|
|
|
qCDebug(KWINEFFECTS) << "Normal:" << w->isNormalWindow();
|
2008-06-30 12:52:06 +00:00
|
|
|
*/
|
2019-04-15 07:59:51 +00:00
|
|
|
if (w->isPopupWindow()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (w->isX11Client() && !w->isManaged()) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!w->isNormalWindow())
|
2008-06-30 12:52:06 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-06-30 12:52:06 +00:00
|
|
|
|
2011-02-27 08:25:45 +00:00
|
|
|
void FallApartEffect::slotWindowClosed(EffectWindow* c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!isRealWindow(c))
|
2008-06-30 12:52:06 +00:00
|
|
|
return;
|
2013-01-11 09:06:14 +00:00
|
|
|
if (!c->isVisible())
|
2012-11-24 14:42:35 +00:00
|
|
|
return;
|
2019-12-12 13:31:56 +00:00
|
|
|
const void* e = c->data(WindowClosedGrabRole).value<void*>();
|
|
|
|
if (e && e != this)
|
|
|
|
return;
|
2018-06-14 09:04:35 +00:00
|
|
|
c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
windows[ c ].progress = 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
c->refWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-02-27 09:47:42 +00:00
|
|
|
void FallApartEffect::slotWindowDeleted(EffectWindow* c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
windows.remove(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2018-06-14 09:04:35 +00:00
|
|
|
void FallApartEffect::slotWindowDataChanged(EffectWindow* w, int role)
|
|
|
|
{
|
|
|
|
if (role != WindowClosedGrabRole) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w->data(role).value<void*>() == this) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto it = windows.find(w);
|
|
|
|
if (it == windows.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
it.key()->unrefWindow();
|
|
|
|
windows.erase(it);
|
|
|
|
}
|
|
|
|
|
2011-08-27 09:21:31 +00:00
|
|
|
bool FallApartEffect::isActive() const
|
|
|
|
{
|
|
|
|
return !windows.isEmpty();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|