diff --git a/src/scene/decorationitem.cpp b/src/scene/decorationitem.cpp index da28cea937..9ef6510965 100644 --- a/src/scene/decorationitem.cpp +++ b/src/scene/decorationitem.cpp @@ -11,16 +11,12 @@ #include "decorations/decoratedclient.h" #include "deleted.h" #include "scene/workspacescene.h" -#include "utils/common.h" -#include "window.h" #include #include #include -#include - namespace KWin { @@ -87,38 +83,6 @@ void DecorationRenderer::setDevicePixelRatio(qreal dpr) } } -QImage DecorationRenderer::renderToImage(const QRect &geo) -{ - Q_ASSERT(m_client); - - // Guess the pixel format of the X pixmap into which the QImage will be copied. - QImage::Format format; - const int depth = client()->window()->depth(); - switch (depth) { - case 30: - format = QImage::Format_A2RGB30_Premultiplied; - break; - case 24: - case 32: - format = QImage::Format_ARGB32_Premultiplied; - break; - default: - qCCritical(KWIN_CORE) << "Unsupported client depth" << depth; - format = QImage::Format_ARGB32_Premultiplied; - break; - }; - - QImage image(geo.width() * m_devicePixelRatio, geo.height() * m_devicePixelRatio, format); - image.setDevicePixelRatio(m_devicePixelRatio); - image.fill(Qt::transparent); - QPainter p(&image); - p.setRenderHint(QPainter::Antialiasing); - p.setWindow(QRect(geo.topLeft(), geo.size() * effectiveDevicePixelRatio())); - p.setClipRect(geo); - renderToPainter(&p, geo); - return image; -} - void DecorationRenderer::renderToPainter(QPainter *painter, const QRect &rect) { client()->decoration()->paint(painter, rect); diff --git a/src/scene/decorationitem.h b/src/scene/decorationitem.h index 64a6fb6778..af743e5156 100644 --- a/src/scene/decorationitem.h +++ b/src/scene/decorationitem.h @@ -61,7 +61,6 @@ protected: { m_imageSizesDirty = false; } - QImage renderToImage(const QRect &geo); void renderToPainter(QPainter *painter, const QRect &rect); private: diff --git a/src/x11window.cpp b/src/x11window.cpp index 5a38b1961e..e917fc9648 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include // xcb #include @@ -194,7 +195,32 @@ void X11DecorationRenderer::render(const QRegion ®ion) if (!geo.isValid()) { return; } - QImage image = renderToImage(geo); + + // Guess the pixel format of the X pixmap into which the QImage will be copied. + QImage::Format format; + const int depth = client()->window()->depth(); + switch (depth) { + case 30: + format = QImage::Format_A2RGB30_Premultiplied; + break; + case 24: + case 32: + format = QImage::Format_ARGB32_Premultiplied; + break; + default: + qCCritical(KWIN_CORE) << "Unsupported client depth" << depth; + format = QImage::Format_ARGB32_Premultiplied; + break; + }; + + QImage image(geo.width(), geo.height(), format); + image.fill(Qt::transparent); + QPainter p(&image); + p.setRenderHint(QPainter::Antialiasing); + p.setWindow(geo); + p.setClipRect(geo); + renderToPainter(&p, geo); + xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, client()->window()->frameId(), m_gc, image.width(), image.height(), geo.x(), geo.y(), 0, client()->window()->depth(), image.sizeInBytes(), image.constBits());