[wayland] Set depth in ShellClient depending on whether the Buffer has alpha

We need to set the depth in order to properly determine whether the
Surface has an alpha channel and whether blending needs to be enabled
for rendering.

For this a new method is introduced in Toplevel to set the depth. If
the depth changed in a way that the Toplevel gained or lost the alpha
channel a signal is emitted which implies that the hasAlpha property of
Toplevel is no longer constant.
icc-effect-5.14.5
Martin Gräßlin 2015-06-01 16:25:21 +02:00
parent 99237c9b3f
commit 5a98d8bbbd
3 changed files with 20 additions and 1 deletions

View File

@ -165,6 +165,7 @@ void ShellClient::addDamage(const QRegion &damage)
}
setGeometry(QRect(position, m_clientSize));
}
setDepth(m_shellSurface->surface()->buffer()->hasAlphaChannel() ? 32 : 24);
setReadyForPainting();
Toplevel::addDamage(damage);
}

View File

@ -42,6 +42,7 @@ namespace KWin
Toplevel::Toplevel()
: m_visual(XCB_NONE)
, bit_depth(24)
, info(NULL)
, ready_for_painting(true)
, m_isDamaged(false)
@ -475,6 +476,18 @@ QByteArray Toplevel::windowRole() const
return QByteArray(info->windowRole());
}
void Toplevel::setDepth(int depth)
{
if (bit_depth == depth) {
return;
}
const bool oldAlpha = hasAlpha();
bit_depth = depth;
if (oldAlpha != hasAlpha()) {
emit hasAlphaChanged();
}
}
} // namespace
#include "toplevel.moc"

View File

@ -71,7 +71,7 @@ class Toplevel
: public QObject
{
Q_OBJECT
Q_PROPERTY(bool alpha READ hasAlpha CONSTANT)
Q_PROPERTY(bool alpha READ hasAlpha NOTIFY hasAlphaChanged)
Q_PROPERTY(qulonglong frameId READ frameId)
Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
Q_PROPERTY(QRect visibleRect READ visibleRect)
@ -414,6 +414,10 @@ Q_SIGNALS:
* @since 5.3
**/
void surfaceIdChanged(quint32);
/**
* @since 5.4
**/
void hasAlphaChanged();
protected Q_SLOTS:
/**
@ -460,6 +464,7 @@ protected:
friend QDebug& operator<<(QDebug& stream, const Toplevel*);
void deleteEffectWindow();
virtual bool shouldUnredirect() const = 0;
void setDepth(int depth);
QRect geom;
xcb_visualid_t m_visual;
int bit_depth;