Commit 2d56154f authored by Kai Uwe Broulik's avatar Kai Uwe Broulik Committed by Kai Uwe Broulik
Browse files

kwineffects: Support setting opacity on OffscreenQuickView



Signed-off-by: default avatarEike Hein <eike.hein@mbition.io>
parent c2e34968
Pipeline #138504 passed with stage
in 35 minutes and 15 seconds
......@@ -383,6 +383,16 @@ QRect OffscreenQuickView::geometry() const
return d->m_view->geometry();
}
void OffscreenQuickView::setOpacity(qreal opacity)
{
d->m_view->setOpacity(opacity);
}
qreal OffscreenQuickView::opacity() const
{
return d->m_view->opacity();
}
QQuickItem *OffscreenQuickView::contentItem() const
{
return d->m_view->contentItem();
......
......@@ -94,6 +94,9 @@ public:
void setGeometry(const QRect &rect);
QRect geometry() const;
void setOpacity(qreal opacity);
qreal opacity() const;
/**
* Render the current scene graph into the FBO.
* This is typically done automatically when the scene changes
......
......@@ -337,18 +337,28 @@ void SceneOpenGL::paintDesktop(int desktop, int mask, const QRegion &region, Scr
void SceneOpenGL::paintOffscreenQuickView(OffscreenQuickView *w)
{
GLShader *shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture);
const QRect rect = w->geometry();
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 QRect rect = w->geometry();
QMatrix4x4 mvp(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();
......
......@@ -130,7 +130,10 @@ void SceneQPainter::paintOffscreenQuickView(OffscreenQuickView *w)
if (buffer.isNull()) {
return;
}
painter->save();
painter->setOpacity(w->opacity());
painter->drawImage(w->geometry(), buffer);
painter->restore();
}
Scene::Window *SceneQPainter::createWindow(Toplevel *toplevel)
......
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