From 063587db99f29cca78d50f7283719f5112e6c9f9 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 15 Mar 2017 12:02:22 +0100 Subject: [PATCH] store contrast matrix per-window Summary: as different windows can have different contrast region parameters, store color matrices per window BUG:339237 Test Plan: logout window doesn't break panel anymore Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: broulik, plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D5048 --- effects/backgroundcontrast/contrast.cpp | 12 +++++++----- effects/backgroundcontrast/contrast.h | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp index 65528f91f2..51308166cd 100644 --- a/effects/backgroundcontrast/contrast.cpp +++ b/effects/backgroundcontrast/contrast.cpp @@ -88,7 +88,7 @@ void ContrastEffect::reconfigure(ReconfigureFlags flags) } } -void ContrastEffect::updateContrastRegion(EffectWindow *w) const +void ContrastEffect::updateContrastRegion(EffectWindow *w) { QRegion region; float colorTransform[16]; @@ -112,14 +112,14 @@ void ContrastEffect::updateContrastRegion(EffectWindow *w) const } QMatrix4x4 colorMatrix(colorTransform); - shader->setColorMatrix(colorMatrix); + m_colorMatrices[w] = colorMatrix; } KWayland::Server::SurfaceInterface *surf = w->surface(); if (surf && surf->contrast()) { region = surf->contrast()->region(); - shader->setColorMatrix(colorMatrix(surf->contrast()->contrast(), surf->contrast()->intensity(), surf->contrast()->saturation())); + m_colorMatrices[w] = colorMatrix(surf->contrast()->contrast(), surf->contrast()->intensity(), surf->contrast()->saturation()); } //!value.isNull() full window in X11 case, surf->contrast() @@ -153,6 +153,7 @@ void ContrastEffect::slotWindowDeleted(EffectWindow *w) if (m_contrastChangedConnections.contains(w)) { disconnect(m_contrastChangedConnections[w]); m_contrastChangedConnections.remove(w); + m_colorMatrices.remove(w); } } @@ -397,7 +398,7 @@ void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, Windo } if (!shape.isEmpty()) { - doContrast(shape, screen, data.opacity(), data.screenProjectionMatrix()); + doContrast(w, shape, screen, data.opacity(), data.screenProjectionMatrix()); } } @@ -411,7 +412,7 @@ void ContrastEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double effects->paintEffectFrame(frame, region, opacity, frameOpacity); } -void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection) +void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection) { const QRegion actualShape = shape & screen; const QRect r = actualShape.boundingRect(); @@ -434,6 +435,7 @@ void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const // Draw the texture on the offscreen framebuffer object, while blurring it horizontally + shader->setColorMatrix(m_colorMatrices.value(w)); shader->bind(); diff --git a/effects/backgroundcontrast/contrast.h b/effects/backgroundcontrast/contrast.h index 20bf8bf605..cdf060901a 100644 --- a/effects/backgroundcontrast/contrast.h +++ b/effects/backgroundcontrast/contrast.h @@ -73,8 +73,8 @@ public Q_SLOTS: private: QRegion contrastRegion(const EffectWindow *w) const; bool shouldContrast(const EffectWindow *w, int mask, const WindowPaintData &data) const; - void updateContrastRegion(EffectWindow *w) const; - void doContrast(const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection); + void updateContrastRegion(EffectWindow *w); + void doContrast(EffectWindow *w, const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection); void uploadRegion(QVector2D *&map, const QRegion ®ion); void uploadGeometry(GLVertexBuffer *vbo, const QRegion ®ion); @@ -83,6 +83,7 @@ private: long net_wm_contrast_region; 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*, QMatrix4x4> m_colorMatrices; QHash< const EffectWindow*, QMetaObject::Connection > m_contrastChangedConnections; // used only in Wayland to keep track of effect changed KWayland::Server::ContrastManagerInterface *m_contrastManager = nullptr; };