Commit 5e448f06 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

effects/contrast: Remove paint area tracking

Unlike the blur effect, neighbor pixels don't affect the results of the
contrast effect so it doesn't have to extend the painted area.


(cherry picked from commit c2e34968)
parent 29bc1173
Pipeline #140475 passed with stage
in 12 minutes and 3 seconds
......@@ -347,61 +347,6 @@ void ContrastEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &region)
vbo->setAttribLayout(layout, 2, sizeof(QVector2D));
}
void ContrastEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
{
m_paintedArea = QRegion();
m_currentContrast = QRegion();
effects->prePaintScreen(data, presentTime);
}
void ContrastEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime)
{
// this effect relies on prePaintWindow being called in the bottom to top order
effects->prePaintWindow(w, data, presentTime);
if (!w->isPaintingEnabled()) {
return;
}
if (!shader || !shader->isValid()) {
return;
}
// we don't have to blur a region we don't see
m_currentContrast -= data.clip;
// if we have to paint a non-opaque part of this window that intersects with the
// currently blurred region (which is not cached) we have to redraw the whole region
if ((data.paint-data.clip).intersects(m_currentContrast)) {
data.paint |= m_currentContrast;
}
// in case this window has regions to be blurred
const QRect screen = effects->virtualScreenGeometry();
const QRegion contrastArea = contrastRegion(w).translated(w->pos()) & screen;
// we are not caching the window
// if this window or an window underneath the modified area is painted again we have to
// do everything
if (m_paintedArea.intersects(contrastArea) || data.paint.intersects(contrastArea)) {
data.paint |= contrastArea;
// we have to check again whether we do not damage a blurred area
// of a window we do not cache
if (contrastArea.intersects(m_currentContrast)) {
data.paint |= m_currentContrast;
}
}
m_currentContrast |= contrastArea;
// m_paintedArea keep track of all repainted areas
m_paintedArea -= data.clip;
m_paintedArea |= data.paint;
}
bool ContrastEffect::shouldContrast(const EffectWindow *w, int mask, const WindowPaintData &data) const
{
if (!shader || !shader->isValid())
......
......@@ -33,8 +33,6 @@ public:
static bool enabledByDefault();
static QMatrix4x4 colorMatrix(qreal contrast, qreal intensity, qreal saturation);
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override;
void drawWindow(EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data) override;
void paintEffectFrame(EffectFrame *frame, const QRegion &region, double opacity, double frameOpacity) override;
......@@ -66,8 +64,6 @@ private:
private:
ContrastShader *shader;
long net_wm_contrast_region = 0;
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
static KWaylandServer::ContrastManagerInterface *s_contrastManager;
......
Supports Markdown
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