From 3ee51e3f21e8994ad962caa6c9f0f561950f42df Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 12 Jan 2023 14:12:31 +0100 Subject: [PATCH] Allow overriding the vertex snapping mode for OffscreenEffect Certain effects need vertices that aren't being rounded to device coordinates. So allow those to explicitly request that. --- src/libkwineffects/kwinoffscreeneffect.cpp | 18 ++++++++++++++++++ src/libkwineffects/kwinoffscreeneffect.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/src/libkwineffects/kwinoffscreeneffect.cpp b/src/libkwineffects/kwinoffscreeneffect.cpp index 376361eec3..f7257d2ef5 100644 --- a/src/libkwineffects/kwinoffscreeneffect.cpp +++ b/src/libkwineffects/kwinoffscreeneffect.cpp @@ -17,6 +17,7 @@ public: virtual ~OffscreenData(); void setDirty(); void setShader(GLShader *newShader); + void setVertexSnappingMode(RenderGeometry::VertexSnappingMode mode); void paint(EffectWindow *window, const QRegion ®ion, const WindowPaintData &data, const WindowQuadList &quads); @@ -28,6 +29,7 @@ private: std::unique_ptr m_fbo; bool m_isDirty = true; GLShader *m_shader = nullptr; + RenderGeometry::VertexSnappingMode m_vertexSnappingMode = RenderGeometry::VertexSnappingMode::Round; }; class OffscreenEffectPrivate @@ -36,6 +38,7 @@ public: std::map> windows; QMetaObject::Connection windowDamagedConnection; QMetaObject::Connection windowDeletedConnection; + RenderGeometry::VertexSnappingMode vertexSnappingMode = RenderGeometry::VertexSnappingMode::Round; }; OffscreenEffect::OffscreenEffect(QObject *parent) @@ -58,6 +61,7 @@ void OffscreenEffect::redirect(EffectWindow *window) return; } offscreenData = std::make_unique(); + offscreenData->setVertexSnappingMode(d->vertexSnappingMode); if (d->windows.size() == 1) { setupConnections(); @@ -134,6 +138,11 @@ void OffscreenData::setShader(GLShader *newShader) m_shader = newShader; } +void OffscreenData::setVertexSnappingMode(RenderGeometry::VertexSnappingMode mode) +{ + m_vertexSnappingMode = mode; +} + void OffscreenData::paint(EffectWindow *window, const QRegion ®ion, const WindowPaintData &data, const WindowQuadList &quads) { @@ -147,6 +156,7 @@ void OffscreenData::paint(EffectWindow *window, const QRegion ®ion, vbo->setAttribLayout(GLVertexBuffer::GLVertex2DLayout, 2, sizeof(GLVertex2D)); RenderGeometry geometry; + geometry.setVertexSnappingMode(m_vertexSnappingMode); for (auto &quad : quads) { geometry.appendWindowQuad(quad, scale); } @@ -249,6 +259,14 @@ void OffscreenEffect::destroyConnections() d->windowDeletedConnection = {}; } +void OffscreenEffect::setVertexSnappingMode(RenderGeometry::VertexSnappingMode mode) +{ + d->vertexSnappingMode = mode; + for (auto &window : std::as_const(d->windows)) { + window.second->setVertexSnappingMode(mode); + } +} + class CrossFadeWindowData : public OffscreenData { public: diff --git a/src/libkwineffects/kwinoffscreeneffect.h b/src/libkwineffects/kwinoffscreeneffect.h index f5c502aeb6..47431519b1 100644 --- a/src/libkwineffects/kwinoffscreeneffect.h +++ b/src/libkwineffects/kwinoffscreeneffect.h @@ -64,6 +64,13 @@ protected: **/ void setShader(EffectWindow *window, GLShader *shader); + /** + * Set what mode to use to snap the vertices of this effect. + * + * @see RenderGeometry::VertexSnappingMode + */ + void setVertexSnappingMode(RenderGeometry::VertexSnappingMode mode); + private Q_SLOTS: void handleWindowDamaged(EffectWindow *window); void handleWindowDeleted(EffectWindow *window);