plugins/blur: Move blur window data in a struct

It's going to be useful later to cache the background texture.
This commit is contained in:
Vlad Zahorodnii 2023-08-08 18:44:28 +03:00
parent 5d65b43294
commit 52031f095d
2 changed files with 13 additions and 8 deletions

View file

@ -334,9 +334,9 @@ void BlurEffect::updateBlurRegion(EffectWindow *w)
}
if (valid) {
blurRegions[w] = region;
m_windows[w].region = region;
} else {
blurRegions.remove(w);
m_windows.remove(w);
}
}
@ -361,7 +361,7 @@ void BlurEffect::slotWindowAdded(EffectWindow *w)
void BlurEffect::slotWindowDeleted(EffectWindow *w)
{
blurRegions.remove(w);
m_windows.remove(w);
auto it = windowBlurChangedConnections.find(w);
if (it == windowBlurChangedConnections.end()) {
return;
@ -471,12 +471,12 @@ QRegion BlurEffect::expand(const QRegion &region) const
return expanded;
}
QRegion BlurEffect::blurRegion(const EffectWindow *w) const
QRegion BlurEffect::blurRegion(EffectWindow *w) const
{
QRegion region;
if (auto it = blurRegions.find(w); it != blurRegions.end()) {
const QRegion &appRegion = *it;
if (auto it = m_windows.find(w); it != m_windows.end()) {
const QRegion &appRegion = it->region;
if (!appRegion.isEmpty()) {
if (w->decorationHasAlpha() && decorationSupportsBlurBehind(w)) {
region = decorationBlurRegion(w);

View file

@ -27,6 +27,11 @@ static const int borderSize = 5;
class BlurShader;
struct BlurData
{
QRegion region;
};
class BlurEffect : public KWin::Effect
{
Q_OBJECT
@ -78,7 +83,7 @@ private:
QRegion expand(const QRegion &region) const;
void initBlurStrengthValues();
bool updateTexture(EffectScreen *screen, const RenderTarget &renderTarget);
QRegion blurRegion(const EffectWindow *w) const;
QRegion blurRegion(EffectWindow *w) const;
QRegion decorationBlurRegion(const EffectWindow *w) const;
bool decorationSupportsBlurBehind(const EffectWindow *w) const;
bool shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data) const;
@ -132,7 +137,7 @@ private:
QVector<BlurValuesStruct> blurStrengthValues;
QMap<EffectWindow *, QMetaObject::Connection> windowBlurChangedConnections;
QMap<const EffectWindow *, QRegion> blurRegions;
QHash<EffectWindow *, BlurData> m_windows;
static KWaylandServer::BlurManagerInterface *s_blurManager;
static QTimer *s_blurManagerRemoveTimer;