Remove binding of selection to styled EffectFrame

This allows to just set the selection on a None EffectFrame so
that only the selection is rendered without blurring the background
and so on.
This commit is contained in:
Martin Gräßlin 2011-04-28 13:41:11 +02:00
parent ff3900d825
commit 022d7a32a0
4 changed files with 30 additions and 23 deletions

View file

@ -1651,12 +1651,12 @@ EffectFrameImpl::EffectFrameImpl(EffectFrameStyle style, bool staticSize, QPoint
if (m_style == EffectFrameStyled) {
m_frame.setImagePath("widgets/background");
m_frame.setCacheAllRenderedFrames(true);
m_selection.setImagePath("widgets/viewitem");
m_selection.setElementPrefix("hover");
m_selection.setCacheAllRenderedFrames(true);
m_selection.setEnabledBorders(Plasma::FrameSvg::AllBorders);
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(plasmaThemeChanged()));
}
m_selection.setImagePath("widgets/viewitem");
m_selection.setElementPrefix("hover");
m_selection.setCacheAllRenderedFrames(true);
m_selection.setEnabledBorders(Plasma::FrameSvg::AllBorders);
if (effects->compositingType() == OpenGLCompositing) {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING

View file

@ -1778,7 +1778,6 @@ public:
/**
* Sets the geometry of a selection.
* To remove the selection set a null rect.
* This is only available if the an styled EffectFrame is used.
* @param selection The geometry of the selection in screen coordinates.
**/
virtual void setSelection(const QRect& selection) = 0;

View file

@ -1333,18 +1333,26 @@ void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double fra
m_texture->render(region, m_effectFrame->geometry().adjusted(-left, -top, right, bottom));
m_texture->unbind();
if (!m_effectFrame->selection().isNull()) {
if (!m_selectionTexture) { // Lazy creation
QPixmap pixmap = m_effectFrame->selectionFrame().framePixmap();
m_selectionTexture = new Texture(pixmap.handle(), pixmap.size(), pixmap.depth());
m_selectionTexture->setYInverted(true);
}
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
m_selectionTexture->bind();
m_selectionTexture->render(region, m_effectFrame->selection());
m_selectionTexture->unbind();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (!m_effectFrame->selection().isNull()) {
if (!m_selectionTexture) { // Lazy creation
QPixmap pixmap = m_effectFrame->selectionFrame().framePixmap();
m_selectionTexture = new Texture(pixmap.handle(), pixmap.size(), pixmap.depth());
m_selectionTexture->setYInverted(true);
}
if (shader) {
const float a = opacity * frameOpacity;
shader->setUniform(GLShader::ModulationConstant, QVector4D(a, a, a, a));
}
#ifndef KWIN_HAVE_OPENGLES
else
glColor4f(1.0, 1.0, 1.0, opacity * frameOpacity);
#endif
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
m_selectionTexture->bind();
m_selectionTexture->render(region, m_effectFrame->selection());
m_selectionTexture->unbind();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
// Render icon

View file

@ -904,14 +904,14 @@ void SceneXrender::EffectFrame::render(QRegion region, double opacity, double fr
XRenderComposite(display(), PictOpOver, *m_picture, None, effects->xrenderBufferPicture(),
0, 0, 0, 0, geom.x(), geom.y(), geom.width(), geom.height());
if (!m_effectFrame->selection().isNull()) {
if (!m_selectionPicture) { // Lazy creation
m_selectionPicture = new XRenderPicture(m_effectFrame->selectionFrame().framePixmap());
}
geom = m_effectFrame->selection();
XRenderComposite(display(), PictOpOver, *m_selectionPicture, None, effects->xrenderBufferPicture(),
0, 0, 0, 0, geom.x(), geom.y(), geom.width(), geom.height());
}
if (!m_effectFrame->selection().isNull()) {
if (!m_selectionPicture) { // Lazy creation
m_selectionPicture = new XRenderPicture(m_effectFrame->selectionFrame().framePixmap());
}
const QRect geom = m_effectFrame->selection();
XRenderComposite(display(), PictOpOver, *m_selectionPicture, None, effects->xrenderBufferPicture(),
0, 0, 0, 0, geom.x(), geom.y(), geom.width(), geom.height());
}
XRenderPicture fill = xRenderBlendPicture(opacity);