From 36440a9d91915a8885a8bbcc1b2dcf39428f07ed Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 12 Oct 2022 11:28:25 +0000 Subject: [PATCH] Fix scripted shader effect animations AnimationEffect inherits from CrossfadeEffect as it may do a crossfade, but it also has to perform non-crossfading activities with a custom shader. For crossfades we want to draw the old and new window, but this isn't needed where the crossFadeProgress remains at 0. BUG: 460277 --- src/libkwineffects/kwineffects.cpp | 2 +- src/libkwineffects/kwinoffscreeneffect.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index 56299aea9a..825e127afb 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -251,7 +251,7 @@ WindowPaintData::WindowPaintData(const QMatrix4x4 &screenProjectionMatrix) setSaturation(1.0); setBrightness(1.0); setScreen(0); - setCrossFadeProgress(1.0); + setCrossFadeProgress(0.0); } WindowPaintData::WindowPaintData(const WindowPaintData &other) diff --git a/src/libkwineffects/kwinoffscreeneffect.cpp b/src/libkwineffects/kwinoffscreeneffect.cpp index 6ee3092dc0..5353f73d18 100644 --- a/src/libkwineffects/kwinoffscreeneffect.cpp +++ b/src/libkwineffects/kwinoffscreeneffect.cpp @@ -280,16 +280,21 @@ void CrossFadeEffect::drawWindow(EffectWindow *window, int mask, const QRegion & { Q_UNUSED(mask) + CrossFadeWindowData *offscreenData = d->windows.value(window); + // paint the new window (if applicable) underneath - Effect::drawWindow(window, mask, region, data); + if (data.crossFadeProgress() > 0 || !offscreenData) { + Effect::drawWindow(window, mask, region, data); + } + + if (!offscreenData) { + return; + } // paint old snapshot on top WindowPaintData previousWindowData = data; previousWindowData.setOpacity((1.0 - data.crossFadeProgress()) * data.opacity()); - CrossFadeWindowData *offscreenData = d->windows[window]; - if (!offscreenData) { - return; - } + const QRectF expandedGeometry = window->expandedGeometry(); const QRectF frameGeometry = window->frameGeometry();