scene: Move OffscreenQuickView painting to EffectsHandlerImpl
There's no any way to integrate OffscreenQuickView into the scene graph. So make the EffectsHandlerImpl responsible for drawing quick views until the corresponding item is introduced (requires a lot and a lot of refactoring in effects) or the design of kwin changes so much that we don't need this special code path.
This commit is contained in:
parent
4ded856fbf
commit
1ca263d588
6 changed files with 43 additions and 58 deletions
|
@ -56,6 +56,7 @@
|
|||
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickWindow>
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "scene_opengl.h"
|
||||
|
||||
#include <kwinglplatform.h>
|
||||
#include <kwinoffscreenquickview.h>
|
||||
|
||||
#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();
|
||||
|
|
|
@ -48,9 +48,6 @@ public:
|
|||
QVector<QByteArray> openGLPlatformInterfaceExtensions() const override;
|
||||
std::shared_ptr<GLTexture> textureForOutput(Output *output) const override;
|
||||
|
||||
protected:
|
||||
void paintOffscreenQuickView(OffscreenQuickView *w) override;
|
||||
|
||||
private:
|
||||
OpenGLBackend *m_backend;
|
||||
GLuint vao = 0;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "scene/surfaceitem.h"
|
||||
#include "window.h"
|
||||
|
||||
#include <kwinoffscreenquickview.h>
|
||||
// Qt
|
||||
#include <KDecoration2/Decoration>
|
||||
#include <QDebug>
|
||||
|
@ -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);
|
||||
|
|
|
@ -40,9 +40,6 @@ public:
|
|||
return m_backend;
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintOffscreenQuickView(OffscreenQuickView *w) override;
|
||||
|
||||
private:
|
||||
QPainterBackend *m_backend;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue