Commit 26950a65 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Have Toplevel::damage emit a QRegion

Instead of looping through the rects in the region, emit the region at
bulk. It reduces the amount of emissions we do and allows us to pack the
response accordingly.
parent fd917b4e
......@@ -590,7 +590,7 @@ void EffectsHandlerImpl::slotTabRemoved(EffectWindow *w, EffectWindow* leaderOfF
emit tabRemoved(w, leaderOfFormerGroup);
}
void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRect& r)
void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRegion& r)
{
if (!t->effectWindow()) {
// can happen during tear down of window
......
......@@ -289,7 +289,7 @@ protected Q_SLOTS:
void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old);
void slotFrameGeometryChanged(Toplevel *toplevel, const QRect &oldGeometry);
void slotPaddingChanged(KWin::Toplevel *t, const QRect &old);
void slotWindowDamaged(KWin::Toplevel *t, const QRect& r);
void slotWindowDamaged(KWin::Toplevel *t, const QRegion& r);
protected:
void connectNotify(const QMetaMethod &signal) override;
......
......@@ -73,7 +73,7 @@ void ThumbnailAsideEffect::paintWindow(EffectWindow *w, int mask, QRegion region
painted |= region;
}
void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, const QRect&)
void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, const QRegion&)
{
foreach (const Data & d, windows) {
if (d.window == w)
......
......@@ -55,7 +55,7 @@ private Q_SLOTS:
void toggleCurrentThumbnail();
void slotWindowClosed(KWin::EffectWindow *w);
void slotWindowFrameGeometryChanged(KWin::EffectWindow *w, const QRect &old);
void slotWindowDamaged(KWin::EffectWindow* w, const QRect& damage);
void slotWindowDamaged(KWin::EffectWindow* w, const QRegion& damage);
bool isActive() const override;
void repaintAll();
private:
......
......@@ -175,7 +175,7 @@ X-KDE-Library=kwin4_effect_cooleffect
#define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
#define KWIN_EFFECT_API_VERSION_MAJOR 0
#define KWIN_EFFECT_API_VERSION_MINOR 231
#define KWIN_EFFECT_API_VERSION_MINOR 232
#define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR )
......@@ -1561,7 +1561,7 @@ Q_SIGNALS:
* @param r Always empty.
* @since 4.7
*/
void windowDamaged(KWin::EffectWindow *w, const QRect &r);
void windowDamaged(KWin::EffectWindow *w, const QRegion &r);
/**
* Signal emitted when a tabbox is added.
* An effect who wants to replace the tabbox with itself should use refTabBox.
......
......@@ -90,7 +90,7 @@ private:
m_toplevel->addRepaintFull();
}
void includeDamage(Toplevel *toplevel, const QRect &damage) {
void includeDamage(Toplevel *toplevel, const QRegion &damage) {
Q_ASSERT(m_toplevel == toplevel);
m_damagedRegion |= damage;
}
......
......@@ -45,7 +45,7 @@ Toplevel::Toplevel()
, m_screen(0)
, m_skipCloseAnimation(false)
{
connect(this, SIGNAL(damaged(KWin::Toplevel*,QRect)), SIGNAL(needsRepaint()));
connect(this, &Toplevel::damaged, this, &Toplevel::needsRepaint);
connect(screens(), SIGNAL(changed()), SLOT(checkScreen()));
connect(screens(), SIGNAL(countChanged(int,int)), SLOT(checkScreen()));
setupCheckScreenConnection();
......@@ -327,10 +327,10 @@ void Toplevel::damageNotifyEvent()
{
m_isDamaged = true;
// Note: The rect is supposed to specify the damage extents,
// Note: The damage is supposed to specify the damage extents,
// but we don't know it at this point. No one who connects
// to this signal uses the rect however.
emit damaged(this, QRect());
emit damaged(this, {});
}
bool Toplevel::compositing() const
......@@ -421,12 +421,12 @@ void Toplevel::addDamageFull()
const int offsetX = bufferRect.x() - frameRect.x();
const int offsetY = bufferRect.y() - frameRect.y();
const QRect damagedRect = QRect(0, 0, bufferRect.width(), bufferRect.height());
const QRect damagedRect(0, 0, bufferRect.width(), bufferRect.height());
damage_region = damagedRect;
repaints_region |= damagedRect.translated(offsetX, offsetY);
emit damaged(this, damagedRect);
emit damaged(this, damage_region);
}
void Toplevel::resetDamage()
......@@ -748,9 +748,7 @@ void Toplevel::addDamage(const QRegion &damage)
{
m_isDamaged = true;
damage_region += damage;
for (const QRect &r : damage) {
emit damaged(this, r);
}
emit damaged(this, damage);
}
QByteArray Toplevel::windowRole() const
......
......@@ -585,7 +585,7 @@ public:
Q_SIGNALS:
void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity);
void damaged(KWin::Toplevel* toplevel, const QRect& damage);
void damaged(KWin::Toplevel* toplevel, const QRegion& damage);
void inputTransformationChanged();
/**
* This signal is emitted when the Toplevel's frame geometry changes.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment