[scene-xrender] Implement support for DecorationShadow

The DecorationShadow on XRender is implemented by creating the
required QPixmaps in ::prepareBackend. That way the rendering
infrastructure can be shared with the window based shadows.

BUG: 342758
REVIEW: 122009
This commit is contained in:
Martin Gräßlin 2015-01-12 10:13:47 +01:00
parent ef3f0f753b
commit 2910645df0
3 changed files with 28 additions and 2 deletions

View file

@ -1234,8 +1234,28 @@ void SceneXRenderShadow::buildQuads()
bool SceneXRenderShadow::prepareBackend()
{
if (hasDecorationShadow()) {
// TODO: implement for XRender
return false;
const QImage shadowImage = decorationShadowImage();
QPainter p;
int x = 0;
int y = 0;
auto drawElement = [this, &x, &y, &p, &shadowImage] (ShadowElements element) {
QPixmap pix(elementSize(element));
pix.fill(Qt::transparent);
p.begin(&pix);
p.drawImage(0, 0, shadowImage, x, y, pix.width(), pix.height());
p.end();
setShadowElement(pix, element);
return pix.size();
};
x += drawElement(ShadowElementTopLeft).width();
x += drawElement(ShadowElementTop).width();
y += drawElement(ShadowElementTopRight).height();
drawElement(ShadowElementRight);
x = 0;
y += drawElement(ShadowElementLeft).height();
x += drawElement(ShadowElementBottomLeft).width();
x += drawElement(ShadowElementBottom).width();
drawElement(ShadowElementBottomRight).width();
}
const uint32_t values[] = {XCB_RENDER_REPEAT_NORMAL};
for (int i=0; i<ShadowElementsCount; ++i) {

View file

@ -356,4 +356,9 @@ QSize Shadow::elementSize(Shadow::ShadowElements element) const
}
}
void Shadow::setShadowElement(const QPixmap &shadow, Shadow::ShadowElements element)
{
m_shadowElements[element] = shadow;
}
} // namespace

View file

@ -155,6 +155,7 @@ protected:
};
virtual bool prepareBackend() = 0;
WindowQuadList m_shadowQuads;
void setShadowElement(const QPixmap &shadow, ShadowElements element);
private:
static Shadow *createShadowFromX11(Toplevel *toplevel);