[effects] Properly announce/remove support in blur/contrast if shader fails

Following the approach how it's done for X11: only create the interface
if the shader succeeded to compile and remove support again if it failed
to compile after a reconfigure.

REVIEW: 125444
This commit is contained in:
Martin Gräßlin 2015-09-29 10:21:24 +02:00
parent 0e0c76e080
commit 044e2a05b2
4 changed files with 36 additions and 12 deletions

View file

@ -37,11 +37,6 @@ static const QByteArray s_contrastAtomName = QByteArrayLiteral("_KDE_NET_WM_BACK
ContrastEffect::ContrastEffect()
{
KWayland::Server::Display *display = effects->waylandDisplay();
if (display) {
display->createContrastManager(this)->create();
}
shader = ContrastShader::create();
reconfigure(ReconfigureAll);
@ -50,6 +45,11 @@ ContrastEffect::ContrastEffect()
// Should be included in _NET_SUPPORTED instead.
if (shader && shader->isValid()) {
net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
KWayland::Server::Display *display = effects->waylandDisplay();
if (display) {
m_contrastManager = display->createContrastManager(this);
m_contrastManager->create();
}
} else {
net_wm_contrast_region = 0;
}
@ -81,8 +81,11 @@ void ContrastEffect::reconfigure(ReconfigureFlags flags)
if (shader)
shader->init();
if (!shader || !shader->isValid())
if (!shader || !shader->isValid()) {
effects->removeSupportProperty(s_contrastAtomName, this);
delete m_contrastManager;
m_contrastManager = nullptr;
}
}
void ContrastEffect::updateContrastRegion(EffectWindow *w) const

View file

@ -28,6 +28,14 @@
#include <QVector>
#include <QVector2D>
namespace KWayland
{
namespace Server
{
class ContrastManagerInterface;
}
}
namespace KWin
{
@ -76,6 +84,7 @@ private:
QRegion m_paintedArea; // actually painted area which is greater than m_damagedArea
QRegion m_currentContrast; // keeps track of the currently contrasted area of non-caching windows(from bottom to top)
QHash< const EffectWindow*, QMetaObject::Connection > m_contrastChangedConnections; // used only in Wayland to keep track of effect changed
KWayland::Server::ContrastManagerInterface *m_contrastManager = nullptr;
};
inline

View file

@ -39,11 +39,6 @@ static const QByteArray s_blurAtomName = QByteArrayLiteral("_KDE_NET_WM_BLUR_BEH
BlurEffect::BlurEffect()
{
KWayland::Server::Display *display = effects->waylandDisplay();
if (display) {
display->createBlurManager(this)->create();
}
shader = BlurShader::create();
// Offscreen texture that's used as the target for the horizontal blur pass
@ -60,6 +55,11 @@ BlurEffect::BlurEffect()
// Should be included in _NET_SUPPORTED instead.
if (shader && shader->isValid() && target->valid()) {
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
KWayland::Server::Display *display = effects->waylandDisplay();
if (display) {
m_blurManager = display->createBlurManager(this);
m_blurManager->create();
}
} else {
net_wm_blur_region = 0;
}
@ -100,8 +100,11 @@ void BlurEffect::reconfigure(ReconfigureFlags flags)
windows.clear();
if (!shader || !shader->isValid())
if (!shader || !shader->isValid()) {
effects->removeSupportProperty(s_blurAtomName, this);
delete m_blurManager;
m_blurManager = nullptr;
}
}
void BlurEffect::updateBlurRegion(EffectWindow *w) const

View file

@ -27,6 +27,14 @@
#include <QVector>
#include <QVector2D>
namespace KWayland
{
namespace Server
{
class BlurManagerInterface;
}
}
namespace KWin
{
@ -98,6 +106,7 @@ private:
QHash< const EffectWindow*, BlurWindowInfo > windows;
typedef QHash<const EffectWindow*, BlurWindowInfo>::iterator CacheEntry;
KWayland::Server::BlurManagerInterface *m_blurManager = nullptr;
};
inline