From f01b906c52b0e0aea0021909b2d2755ff66e2acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 4 Aug 2010 18:19:01 +0000 Subject: [PATCH] Wobbly only repaints changed regions instead of full repaints all the time. This has artefact potential. So if someone sees artefacts after this commit, please let me know. svn path=/trunk/KDE/kdebase/workspace/; revision=1159203 --- effects/wobblywindows/wobblywindows.cpp | 48 +++++++------------------ effects/wobblywindows/wobblywindows.h | 2 +- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index e6fb9e2c1d..6730ff4314 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -299,11 +299,10 @@ void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, int time) // Could we just set a subset of the screen to be repainted ? if (windows.count() != 0) { - data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; - } + data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS; - // this set the QRect invalid. - m_updateRegion.setWidth(0); + m_updateRegion = QRegion(); + } effects->prePaintScreen(data, time); } @@ -341,6 +340,10 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowWobblyInfos& wwi = windows[w]; int tx = w->geometry().x(); int ty = w->geometry().y(); + double left = 0.0; + double top = 0.0; + double right = w->width(); + double bottom = w->height(); for (int i = 0; i < data.quads.count(); ++i) { for(int j = 0; j < 4; ++j) @@ -350,7 +353,13 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Pair newPos = computeBezierPoint(wwi, oldPos); v.move(newPos.x - tx, newPos.y - ty); } + left = qMin(left, data.quads[i].left()); + top = qMin(top, data.quads[i].top()); + right = qMax(right, data.quads[i].right()); + bottom = qMax(bottom, data.quads[i].bottom()); } + m_updateRegion = m_updateRegion.united(QRect(w->x() + left, w->y() + top, + right - left, bottom-top)); } // Call the next effect. @@ -1098,9 +1107,6 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) heightRingLinearMean(&wwi.velocity, wwi); - Pair topLeftCorner = {-10000.0, -10000.0}; - Pair bottomRightCorner = {10000.0, 10000.0}; - // compute the new pos of each vertex. for (unsigned int i = 0; i < wwi.count; ++i) { @@ -1115,23 +1121,6 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) pos.x += vel.x*time*m_move_factor; pos.y += vel.y*time*m_move_factor; - if (pos.x < topLeftCorner.x) - { - topLeftCorner.x = pos.x; - } - if (pos.x > bottomRightCorner.x) - { - bottomRightCorner.x = pos.x; - } - if (pos.y < topLeftCorner.y) - { - topLeftCorner.y = pos.y; - } - if (pos.y > bottomRightCorner.y) - { - bottomRightCorner.y = pos.y; - } - vel_sum += fabs(vel.x) + fabs(vel.y); #if defined VERBOSE_MODE @@ -1188,17 +1177,6 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) return false; } - QRect windowRect(topLeftCorner.x, topLeftCorner.y, - bottomRightCorner.x - topLeftCorner.x, bottomRightCorner.y - topLeftCorner.y); - if (m_updateRegion.isValid()) - { - m_updateRegion = m_updateRegion.united(windowRect); - } - else - { - m_updateRegion = windowRect; - } - return true; } diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index 64c18580f7..7ae980d542 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -99,7 +99,7 @@ class WobblyWindowsEffect : public Effect QHash< const EffectWindow*, WindowWobblyInfos > windows; - QRect m_updateRegion; + QRegion m_updateRegion; qreal m_stiffness; qreal m_drag;