Changeset View
Changeset View
Standalone View
Standalone View
effects/wobblywindows/wobblywindows.cpp
1 | /***************************************************************** | 1 | /***************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.com> | 5 | Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.com> | ||
6 | 6 | | |||
7 | You can Freely distribute this program under the GNU General Public | 7 | You can Freely distribute this program under the GNU General Public | ||
8 | License. See the file "COPYING" for the exact licensing terms. | 8 | License. See the file "COPYING" for the exact licensing terms. | ||
9 | ******************************************************************/ | 9 | ******************************************************************/ | ||
10 | 10 | | |||
11 | 11 | | |||
12 | #include "wobblywindows.h" | 12 | #include "wobblywindows.h" | ||
13 | #include "wobblywindowsconfig.h" | 13 | #include "wobblywindowsconfig.h" | ||
14 | 14 | | |||
15 | #include <math.h> | 15 | #include <math.h> | ||
16 | 16 | | |||
17 | #define USE_ASSERT | | |||
18 | #ifdef USE_ASSERT | | |||
19 | #define ASSERT1 assert | | |||
20 | #else | | |||
21 | #define ASSERT1 | | |||
22 | #endif | | |||
23 | | ||||
24 | //#define COMPUTE_STATS | 17 | //#define COMPUTE_STATS | ||
25 | 18 | | |||
26 | // if you enable it and run kwin in a terminal from the session it manages, | 19 | // if you enable it and run kwin in a terminal from the session it manages, | ||
27 | // be sure to redirect the output of kwin in a file or | 20 | // be sure to redirect the output of kwin in a file or | ||
28 | // you'll propably get deadlocks. | 21 | // you'll propably get deadlocks. | ||
29 | //#define VERBOSE_MODE | 22 | //#define VERBOSE_MODE | ||
30 | 23 | | |||
31 | #if defined COMPUTE_STATS && !defined VERBOSE_MODE | 24 | #if defined COMPUTE_STATS && !defined VERBOSE_MODE | ||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Line(s) | |||||
621 | } | 614 | } | ||
622 | 615 | | |||
623 | WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const | 616 | WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const | ||
624 | { | 617 | { | ||
625 | // compute the input value | 618 | // compute the input value | ||
626 | Pair topleft = wwi.origin[0]; | 619 | Pair topleft = wwi.origin[0]; | ||
627 | Pair bottomright = wwi.origin[wwi.count-1]; | 620 | Pair bottomright = wwi.origin[wwi.count-1]; | ||
628 | 621 | | |||
629 | // ASSERT1(point.x >= topleft.x); | | |||
630 | // ASSERT1(point.y >= topleft.y); | | |||
631 | // ASSERT1(point.x <= bottomright.x); | | |||
632 | // ASSERT1(point.y <= bottomright.y); | | |||
633 | | ||||
634 | qreal tx = (point.x - topleft.x) / (bottomright.x - topleft.x); | 622 | qreal tx = (point.x - topleft.x) / (bottomright.x - topleft.x); | ||
635 | qreal ty = (point.y - topleft.y) / (bottomright.y - topleft.y); | 623 | qreal ty = (point.y - topleft.y) / (bottomright.y - topleft.y); | ||
636 | 624 | | |||
637 | // ASSERT1(tx >= 0); | | |||
638 | // ASSERT1(tx <= 1); | | |||
639 | // ASSERT1(ty >= 0); | | |||
640 | // ASSERT1(ty <= 1); | | |||
641 | | ||||
642 | // compute polynomial coeff | 625 | // compute polynomial coeff | ||
643 | 626 | | |||
644 | qreal px[4]; | 627 | qreal px[4]; | ||
645 | px[0] = (1 - tx) * (1 - tx) * (1 - tx); | 628 | px[0] = (1 - tx) * (1 - tx) * (1 - tx); | ||
646 | px[1] = 3 * (1 - tx) * (1 - tx) * tx; | 629 | px[1] = 3 * (1 - tx) * (1 - tx) * tx; | ||
647 | px[2] = 3 * (1 - tx) * tx * tx; | 630 | px[2] = 3 * (1 - tx) * tx * tx; | ||
648 | px[3] = tx * tx * tx; | 631 | px[3] = tx * tx * tx; | ||
649 | 632 | | |||
▲ Show 20 Lines • Show All 596 Lines • Show Last 20 Lines |