diff --git a/src/effects.cpp b/src/effects.cpp index 0d77419760..ad6d21691b 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -1763,7 +1764,48 @@ void EffectsHandlerImpl::renderOffscreenQuickView(OffscreenQuickView *w) const if (!w->isVisible()) { return; } - scene()->paintOffscreenQuickView(w); + if (compositingType() == OpenGLCompositing) { + GLTexture *t = w->bufferAsTexture(); + if (!t) { + return; + } + + ShaderTraits traits = ShaderTrait::MapTexture; + const qreal a = w->opacity(); + if (a != 1.0) { + traits |= ShaderTrait::Modulate; + } + + GLShader *shader = ShaderManager::instance()->pushShader(traits); + const QRectF rect = scaledRect(w->geometry(), m_scene->renderer()->renderTargetScale()); + + QMatrix4x4 mvp(m_scene->renderer()->renderTargetProjectionMatrix()); + mvp.translate(rect.x(), rect.y()); + shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); + + if (a != 1.0) { + shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); + } + + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + t->bind(); + t->render(w->geometry(), m_scene->renderer()->renderTargetScale()); + t->unbind(); + glDisable(GL_BLEND); + + ShaderManager::instance()->popShader(); + } else if (compositingType() == QPainterCompositing) { + QPainter *painter = effects->scenePainter(); + const QImage buffer = w->bufferAsImage(); + if (buffer.isNull()) { + return; + } + painter->save(); + painter->setOpacity(w->opacity()); + painter->drawImage(w->geometry(), buffer); + painter->restore(); + } } SessionState EffectsHandlerImpl::sessionState() const diff --git a/src/scene/scene.h b/src/scene/scene.h index 18a91c5e77..618a5cb43c 100644 --- a/src/scene/scene.h +++ b/src/scene/scene.h @@ -184,8 +184,6 @@ protected: // called after all effects had their drawWindow() called void finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data); - virtual void paintOffscreenQuickView(OffscreenQuickView *w) = 0; - // saved data for 2nd pass of optimized screen painting struct Phase2Data { diff --git a/src/scene/scene_opengl.cpp b/src/scene/scene_opengl.cpp index 9c9f65bc6d..9daa0db64a 100644 --- a/src/scene/scene_opengl.cpp +++ b/src/scene/scene_opengl.cpp @@ -14,7 +14,6 @@ #include "scene_opengl.h" #include -#include #include "composite.h" #include "core/output.h" @@ -56,40 +55,6 @@ SceneOpenGL::~SceneOpenGL() makeOpenGLContextCurrent(); } -void SceneOpenGL::paintOffscreenQuickView(OffscreenQuickView *w) -{ - GLTexture *t = w->bufferAsTexture(); - if (!t) { - return; - } - - ShaderTraits traits = ShaderTrait::MapTexture; - const qreal a = w->opacity(); - if (a != 1.0) { - traits |= ShaderTrait::Modulate; - } - - GLShader *shader = ShaderManager::instance()->pushShader(traits); - const QRectF rect = scaledRect(w->geometry(), renderer()->renderTargetScale()); - - QMatrix4x4 mvp(renderer()->renderTargetProjectionMatrix()); - mvp.translate(rect.x(), rect.y()); - shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - - if (a != 1.0) { - shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a)); - } - - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - t->bind(); - t->render(w->geometry(), renderer()->renderTargetScale()); - t->unbind(); - glDisable(GL_BLEND); - - ShaderManager::instance()->popShader(); -} - bool SceneOpenGL::makeOpenGLContextCurrent() { return m_backend->makeCurrent(); diff --git a/src/scene/scene_opengl.h b/src/scene/scene_opengl.h index 318c565b44..c6111c61f6 100644 --- a/src/scene/scene_opengl.h +++ b/src/scene/scene_opengl.h @@ -48,9 +48,6 @@ public: QVector openGLPlatformInterfaceExtensions() const override; std::shared_ptr textureForOutput(Output *output) const override; -protected: - void paintOffscreenQuickView(OffscreenQuickView *w) override; - private: OpenGLBackend *m_backend; GLuint vao = 0; diff --git a/src/scene/scene_qpainter.cpp b/src/scene/scene_qpainter.cpp index b7384bcdba..c7b5473c62 100644 --- a/src/scene/scene_qpainter.cpp +++ b/src/scene/scene_qpainter.cpp @@ -13,7 +13,6 @@ #include "scene/surfaceitem.h" #include "window.h" -#include // Qt #include #include @@ -38,19 +37,6 @@ SceneQPainter::~SceneQPainter() { } -void SceneQPainter::paintOffscreenQuickView(OffscreenQuickView *w) -{ - QPainter *painter = effects->scenePainter(); - const QImage buffer = w->bufferAsImage(); - if (buffer.isNull()) { - return; - } - painter->save(); - painter->setOpacity(w->opacity()); - painter->drawImage(w->geometry(), buffer); - painter->restore(); -} - Shadow *SceneQPainter::createShadow(Window *window) { return new SceneQPainterShadow(window); diff --git a/src/scene/scene_qpainter.h b/src/scene/scene_qpainter.h index e5723c42b2..f7ab1fc0f0 100644 --- a/src/scene/scene_qpainter.h +++ b/src/scene/scene_qpainter.h @@ -40,9 +40,6 @@ public: return m_backend; } -protected: - void paintOffscreenQuickView(OffscreenQuickView *w) override; - private: QPainterBackend *m_backend; };