Commit 33e3b929 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

effects/wobblywindows: Allow model geometry and real geometry get out of sync

Currently, the wobbly windows effect assumes that the window data will
be updated on every repaint. However, there are legit cases when the
time diff between frames can be 0, for example when per screen rendering
is on.

If we are unlucky enough and the geometry of the window changes in that
very short moment, the mapping between window quads and the bezier
patch will be wrong. The window will most likely bounce back and forth.

In order to improve handling of that tricky case, this change makes the
computeBezierPoint() function take the "uv" coordinates rather than the
absolute "xy" coordinates of window vertices. This loosens the
connection between the real geometry of the window and the cached bezier
patch, and overall makes the effect's timing code more robust.

This can be also useful if the wobbly windows effect starts accumulating
time diffs and performing the integration step every N msecs with the
purpose of maintaining uniform "wobbliness" across different refresh rates.

BUG: 433187
parent 823692ab
......@@ -272,6 +272,8 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
WindowWobblyInfos& wwi = windows[w];
int tx = w->geometry().x();
int ty = w->geometry().y();
int width = w->geometry().width();
int height = w->geometry().height();
double left = 0.0;
double top = 0.0;
double right = w->width();
......@@ -279,8 +281,8 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
for (int i = 0; i < data.quads.count(); ++i) {
for (int j = 0; j < 4; ++j) {
WindowVertex& v = data.quads[i][j];
Pair oldPos = {tx + v.x(), ty + v.y()};
Pair newPos = computeBezierPoint(wwi, oldPos);
Pair uv = {v.x() / width, v.y() / height};
Pair newPos = computeBezierPoint(wwi, uv);
v.move(newPos.x - tx, newPos.y - ty);
left = qMin(left, data.quads[i].left());
......@@ -514,12 +516,8 @@ void WobblyWindowsEffect::freeWobblyInfo(WindowWobblyInfos& wwi) const
WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const
// compute the input value
Pair topleft = wwi.origin[0];
Pair bottomright = wwi.origin[wwi.count-1];
qreal tx = (point.x - topleft.x) / (bottomright.x - topleft.x);
qreal ty = (point.y - topleft.y) / (bottomright.y - topleft.y);
const qreal tx = point.x;
const qreal ty = point.y;
// compute polynomial coeff
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