kwin/libkwineffects
Vlad Zagorodniy ee88951b17 [libkwineffects] Add TimeLine helper
Summary:
Most effects use QTimeLine in the following manner

```lang=cpp
if (...) {
    m_timeline->setCurrentTime(m_timeline->currentTime() + time);
} else {
    m_timeline->setCurrentTime(m_timeline->currentTime() - time);
}
```

Because effects do not rely on a timer that QTimeLine has, they can't
toggle direction of the QTimeLine, which makes somewhat harder to write
effects. In some cases that's obvious what condition to use to figure
out whether to add or subtract `time`, but there are cases when it's
not. In addition to that, setCurrentTime allows to have negative
currentTime, which in some cases causes bugs.

And overall, the way effects use QTimeLine is really hack-ish. It makes
more sense just to use an integer accumulator(like the Fall Apart
effect is doing) than to use QTimeLine.

Another problem with QTimeLine is that it's a QObject and some effects
do

```lang=cpp
class WindowInfo
{
public:
    ~WindowInfo();

    QTimeLine *timeLine;
};

WindowInfo::~WindowInfo()
{
    delete timeLine;
}

// ...

QHash<EffectWindow*, WindowInfo> m_windows;
```

which is unsafe.

This change adds the TimeLine class. The TimeLine class is a timeline
helper that designed specifically for needs of effects.

Demo

```lang=cpp
TimeLine timeLine(1000, TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);

timeLine.value(); // 0.0
timeLine.running(); // false
timeLine.done(); // false

timeLine.update(420);
timeLine.value(); // 0.42
timeLine.running(); // true
timeLine.done(); // false

timeLine.toggleDirection();
timeLine.value(); // 0.42
timeLine.running(); // true
timeLine.done(); // false

timeLine.update(100);
timeLine.value(); // 0.32
timeLine.running(); // true
timeLine.done(); // false

timeLine.update(1000);
timeLine.value(); // 0.0
timeLine.running(); // false
timeLine.done(); // true
```

Test Plan: Ran tests.

Reviewers: #kwin, davidedmundson, graesslin

Reviewed By: #kwin, davidedmundson, graesslin

Subscribers: romangg, graesslin, anthonyfieroni, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13740
2018-06-30 09:58:11 +03:00
..
anidata.cpp
anidata_p.h use a global static for animation ids 2016-03-23 12:03:31 +01:00
CMakeLists.txt [effects] Use arg="true" in the kcfg files 2017-04-15 10:03:34 +02:00
kwinanimationeffect.cpp use a global static for animation ids 2016-03-23 12:03:31 +01:00
kwinanimationeffect.h
kwinconfig.h.cmake Move linking to DL_LIBRARY to x11standalone platform 2016-11-22 14:22:06 +01:00
kwineffects.cpp [libkwineffects] Add TimeLine helper 2018-06-30 09:58:11 +03:00
kwineffects.h [libkwineffects] Add TimeLine helper 2018-06-30 09:58:11 +03:00
kwinglobals.h Deprecate global KWin::displayWidth and KWin::displayHeight 2017-09-01 21:37:42 +02:00
kwinglplatform.cpp Fix the build on armhf/aarch64 2018-03-06 09:25:33 +05:30
kwinglplatform.h [libkwineffects] Add detection code for Qualcomm Adreno to GLPlatform 2016-08-12 09:59:38 +02:00
kwingltexture.cpp don't override m_canUseMipmaps 2018-03-14 04:37:44 +02:00
kwingltexture.h Remove Qt module declarations in includes 2018-06-05 18:07:23 +01:00
kwingltexture_p.h [libkwineffects] Try fixing compile error with clang 2017-10-01 09:54:12 +02:00
kwinglutils.cpp [libkwineffects/kwinglutils] Calculate correct srcY0 and srcY1 in GLRenderTarget::blitFromFramebuffer 2018-05-29 15:27:02 +02:00
kwinglutils.h Updated the blur method to use the more efficient dual kawase blur algorithm. 2018-01-26 02:31:45 +09:00
kwinglutils_funcs.cpp [kwinglutils] Drop eglResolveFunctions 2016-11-17 12:59:48 +01:00
kwinglutils_funcs.h Remove epoxy/egl.h from kwinglutils_func.h 2016-11-22 14:21:40 +01:00
kwinxrenderutils.cpp [libkwinxrenderutils] Clean up static blend picture before going down 2016-06-13 15:29:07 +02:00
kwinxrenderutils.h [libkwinxrenderutils] Clean up static blend picture before going down 2016-06-13 15:29:07 +02:00
logging.cpp pedantic fixes 2016-07-16 13:14:44 -04:00
logging_p.h pedantic fixes 2016-07-16 13:14:44 -04:00
Mainpage.dox
Messages.sh