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) { for (int i = 0; i < 2; ++i) {
#ifdef KWIN_BUILD_COMPOSITE #ifdef KWIN_BUILD_COMPOSITE
if ( effects->compositingType() == XRenderCompositing) { if ( effects->compositingType() == XRenderCompositing) {
QPixmap pixmap(f[i]); QImage image(f[i]);
m_picture[i] = new XRenderPicture(pixmap); m_picture[i] = new XRenderPicture(image);
m_size[i] = pixmap.size(); m_size[i] = image.size();
m_lastRect[i].setSize(pixmap.size()); m_lastRect[i].setSize(image.size());
} }
#endif #endif
} }

View file

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

View file

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

View file

@ -68,8 +68,6 @@ class KWIN_EXPORT XRenderPicture
{ {
public: public:
explicit XRenderPicture(xcb_render_picture_t pic = XCB_RENDER_PICTURE_NONE); 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); explicit XRenderPicture(const QImage &img);
XRenderPicture(xcb_pixmap_t pix, int depth); XRenderPicture(xcb_pixmap_t pix, int depth);
operator xcb_render_picture_t(); 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); QPoint topLeft(m_effectFrame->geometry().x(), m_effectFrame->geometry().center().y() - m_effectFrame->iconSize().height() / 2);
if (!m_iconPicture) // lazy creation 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()); QRect geom = QRect(topLeft, m_effectFrame->iconSize());
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, *m_iconPicture, fill, xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, *m_iconPicture, fill,
effects->xrenderBufferPicture(), effects->xrenderBufferPicture(),
@ -994,15 +994,15 @@ void SceneXrender::EffectFrame::updateTextPicture()
text = metrics.elidedText(text, Qt::ElideRight, rect.width()); text = metrics.elidedText(text, Qt::ElideRight, rect.width());
} }
QPixmap pixmap(m_effectFrame->geometry().size()); QImage image(m_effectFrame->geometry().size(), QImage::Format_ARGB32_Premultiplied);
pixmap.fill(Qt::transparent); image.fill(Qt::transparent);
QPainter p(&pixmap); QPainter p(&image);
p.setFont(m_effectFrame->font()); p.setFont(m_effectFrame->font());
// TODO: What about no frame? Custom color setting required // TODO: What about no frame? Custom color setting required
p.setPen(Qt::white); p.setPen(Qt::white);
p.drawText(rect, m_effectFrame->alignment(), text); p.drawText(rect, m_effectFrame->alignment(), text);
p.end(); p.end();
m_textPicture = new XRenderPicture(pixmap); m_textPicture = new XRenderPicture(image);
} }
SceneXRenderShadow::SceneXRenderShadow(Toplevel *toplevel) SceneXRenderShadow::SceneXRenderShadow(Toplevel *toplevel)
@ -1067,7 +1067,7 @@ bool SceneXRenderShadow::prepareBackend()
const uint32_t values[] = {XCB_RENDER_REPEAT_NORMAL}; const uint32_t values[] = {XCB_RENDER_REPEAT_NORMAL};
for (int i=0; i<ShadowElementsCount; ++i) { for (int i=0; i<ShadowElementsCount; ++i) {
delete m_pictures[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); xcb_render_change_picture(connection(), *m_pictures[i], XCB_RENDER_CP_REPEAT, values);
} }
return true; return true;

View file

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

View file

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