kwin: deal with TODO related to XRenderPicture

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-11-08 18:14:39 +02:00
parent 1d42a30de7
commit ec794a537f
7 changed files with 14 additions and 26 deletions

View file

@ -210,10 +210,10 @@ void TrackMouseEffect::loadTexture()
for (int i = 0; i < 2; ++i) {
#ifdef KWIN_BUILD_COMPOSITE
if ( effects->compositingType() == XRenderCompositing) {
QPixmap pixmap(f[i]);
m_picture[i] = new XRenderPicture(pixmap);
m_size[i] = pixmap.size();
m_lastRect[i].setSize(pixmap.size());
QImage image(f[i]);
m_picture[i] = new XRenderPicture(image);
m_size[i] = image.size();
m_lastRect[i].setSize(image.size());
}
#endif
}

View file

@ -173,7 +173,7 @@ void ZoomEffect::recreateTexture()
QImage img((uchar*)ximg->pixels, imageWidth, imageHeight, QImage::Format_ARGB32_Premultiplied);
#ifdef KWIN_BUILD_COMPOSITE
if (effects->compositingType() == XRenderCompositing)
xrenderPicture.reset(new XRenderPicture(QPixmap::fromImage(img)));
xrenderPicture.reset(new XRenderPicture(img));
#endif
XcursorImageDestroy(ximg);
}

View file

@ -107,17 +107,7 @@ static xcb_render_picture_t createPicture(xcb_pixmap_t pix, int depth)
return pic;
}
XRenderPicture::XRenderPicture(const QPixmap &pix)
{
fromImage(pix.toImage());
}
XRenderPicture::XRenderPicture(const QImage &img)
{
fromImage(img);
}
void XRenderPicture::fromImage(const QImage &img)
{
const int depth = img.depth();
xcb_pixmap_t xpix = xcb_generate_id(connection());

View file

@ -68,8 +68,6 @@ class KWIN_EXPORT XRenderPicture
{
public:
explicit XRenderPicture(xcb_render_picture_t pic = XCB_RENDER_PICTURE_NONE);
// TODO: Qt5 - replace QPixmap by QImage to make it more obvious that it uses PutImage
explicit XRenderPicture(const QPixmap &pix);
explicit XRenderPicture(const QImage &img);
XRenderPicture(xcb_pixmap_t pix, int depth);
operator xcb_render_picture_t();

View file

@ -860,7 +860,7 @@ void SceneXrender::EffectFrame::render(QRegion region, double opacity, double fr
QPoint topLeft(m_effectFrame->geometry().x(), m_effectFrame->geometry().center().y() - m_effectFrame->iconSize().height() / 2);
if (!m_iconPicture) // lazy creation
m_iconPicture = new XRenderPicture(m_effectFrame->icon());
m_iconPicture = new XRenderPicture(m_effectFrame->icon().toImage());
QRect geom = QRect(topLeft, m_effectFrame->iconSize());
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, *m_iconPicture, fill,
effects->xrenderBufferPicture(),
@ -994,15 +994,15 @@ void SceneXrender::EffectFrame::updateTextPicture()
text = metrics.elidedText(text, Qt::ElideRight, rect.width());
}
QPixmap pixmap(m_effectFrame->geometry().size());
pixmap.fill(Qt::transparent);
QPainter p(&pixmap);
QImage image(m_effectFrame->geometry().size(), QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
QPainter p(&image);
p.setFont(m_effectFrame->font());
// TODO: What about no frame? Custom color setting required
p.setPen(Qt::white);
p.drawText(rect, m_effectFrame->alignment(), text);
p.end();
m_textPicture = new XRenderPicture(pixmap);
m_textPicture = new XRenderPicture(image);
}
SceneXRenderShadow::SceneXRenderShadow(Toplevel *toplevel)
@ -1067,7 +1067,7 @@ bool SceneXRenderShadow::prepareBackend()
const uint32_t values[] = {XCB_RENDER_REPEAT_NORMAL};
for (int i=0; i<ShadowElementsCount; ++i) {
delete m_pictures[i];
m_pictures[i] = new XRenderPicture(shadowPixmap(ShadowElements(i)));
m_pictures[i] = new XRenderPicture(shadowImage(ShadowElements(i)));
xcb_render_change_picture(connection(), *m_pictures[i], XCB_RENDER_CP_REPEAT, values);
}
return true;

View file

@ -181,7 +181,7 @@ public:
using Shadow::ShadowElementLeft;
using Shadow::ShadowElementTopLeft;
using Shadow::ShadowElementsCount;
using Shadow::shadowPixmap;
using Shadow::shadowImage;
virtual ~SceneXRenderShadow();
void layoutShadowRects(QRect& top, QRect& topRight,

View file

@ -113,8 +113,8 @@ protected:
ShadowElementsCount
};
inline const QPixmap &shadowPixmap(ShadowElements element) const {
return m_shadowElements[element];
inline QImage shadowImage(ShadowElements element) const {
return m_shadowElements[element].toImage();
};
int topOffset() const {