kwineffects: Support setting opacity on OffscreenQuickView
Signed-off-by: Eike Hein <eike.hein@mbition.io>
This commit is contained in:
parent
c2e3496888
commit
2d56154fe8
4 changed files with 29 additions and 3 deletions
|
@ -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 ®ion, 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)
|
||||
|
|
Loading…
Reference in a new issue