From 3065e6afce06e096ce6110157defe9d29c3f3ffa Mon Sep 17 00:00:00 2001 From: Philipp Knechtges Date: Sat, 10 Dec 2011 17:31:18 +0100 Subject: [PATCH] kwin/blur: add a proper initialization of the texture cache This fixes graphical glitches that appear next to the borders of plasma tooltips. Additionally I added a variable that forces the effect to drop the cache, which might be useful in the future to fix bugs. --- effects/blur/blur.cpp | 10 +++++++++- effects/blur/blur.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 17218f97ee..e050beb62e 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -279,7 +279,12 @@ void BlurEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int t // if a window underneath the blurred area is damaged we have to // update the cached texture - const QRegion damagedCache = expand(expandedBlur & m_damagedArea) & expandedBlur; + QRegion damagedCache; + if (windows.contains(w) && !windows[w].dropCache) { + damagedCache = expand(expandedBlur & m_damagedArea) & expandedBlur; + } else { + damagedCache = expandedBlur; + } if (!damagedCache.isEmpty()) { // This is the area of the blurry window which really can change. const QRegion damagedArea = damagedCache & blurArea; @@ -289,6 +294,7 @@ void BlurEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int t if (windows.contains(w)) { // In case we already have a texture cache mark the dirty regions invalid. windows[w].damagedRegion |= damagedCache; + windows[w].dropCache = false; } // we keep track of the "damage propagation" m_damagedArea |= damagedArea; @@ -480,12 +486,14 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa BlurWindowInfo bwi; bwi.blurredBackground = GLTexture(r.width(),r.height()); bwi.damagedRegion = expanded; + bwi.dropCache = false; windows[w] = bwi; } if (windows[w].blurredBackground.size() != r.size()) { windows[w].blurredBackground = GLTexture(r.width(),r.height()); windows[w].damagedRegion = expanded; + windows[w].dropCache = false; } GLTexture targetTexture = windows[w].blurredBackground; diff --git a/effects/blur/blur.h b/effects/blur/blur.h index 313f311357..ea5f01daba 100644 --- a/effects/blur/blur.h +++ b/effects/blur/blur.h @@ -77,6 +77,7 @@ private: struct BlurWindowInfo { GLTexture blurredBackground; // keeps the horizontally blurred background QRegion damagedRegion; + bool dropCache; }; QHash< const EffectWindow*, BlurWindowInfo > windows;