From 6e18cae42aca48bd353c152db5e4a5571a8c0f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 21 Mar 2016 17:11:35 +0100 Subject: [PATCH] Drop xcb-shm usage from QPainterWindowPixmap Summary: Before we were able to render Xwayland windows through the Wayland buffer we used a xcb-shm to map the window data in the QPainter compositor. As we don't use that any more and QPainter is not available for X11 anyway we can just drop the code. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1193 --- scene_qpainter.cpp | 48 +++++++++++----------------------------------- scene_qpainter.h | 5 ----- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/scene_qpainter.cpp b/scene_qpainter.cpp index 06603cbf13..cdaede1429 100644 --- a/scene_qpainter.cpp +++ b/scene_qpainter.cpp @@ -31,7 +31,6 @@ along with this program. If not, see . #include "wayland_server.h" #include #include -#include "xcbutils.h" #include "decorations/decoratedclient.h" // Qt #include @@ -404,7 +403,6 @@ Decoration::Renderer *SceneQPainter::createDecorationRenderer(Decoration::Decora //**************************************** QPainterWindowPixmap::QPainterWindowPixmap(Scene::Window *window) : WindowPixmap(window) - , m_shm(kwinApp()->shouldUseWaylandForCompositing() ? nullptr : new Xcb::Shm) { } @@ -417,51 +415,27 @@ void QPainterWindowPixmap::create() if (isValid()) { return; } - if (!kwinApp()->shouldUseWaylandForCompositing() && !m_shm->isValid()) { - return; - } KWin::WindowPixmap::create(); if (!isValid()) { return; } - if (kwinApp()->shouldUseWaylandForCompositing()) { - // performing deep copy, this could probably be improved - m_image = buffer()->data().copy(); - return; - } - m_image = QImage((uchar*)m_shm->buffer(), size().width(), size().height(), QImage::Format_ARGB32_Premultiplied); + // performing deep copy, this could probably be improved + m_image = buffer()->data().copy(); } bool QPainterWindowPixmap::update(const QRegion &damage) { - if (kwinApp()->shouldUseWaylandForCompositing()) { - const auto oldBuffer = buffer(); - updateBuffer(); - const auto &b = buffer(); - if (b == oldBuffer || b.isNull()) { - return false; - } - QPainter p(&m_image); - const QImage &data = b->data(); - p.setCompositionMode(QPainter::CompositionMode_Source); - for (const QRect &rect : damage.rects()) { - p.drawImage(rect, data, rect); - } - return true; - } - - if (!m_shm->isValid()) { + const auto oldBuffer = buffer(); + updateBuffer(); + const auto &b = buffer(); + if (b == oldBuffer || b.isNull()) { return false; } - - // TODO: optimize by only updating the damaged areas - xcb_shm_get_image_cookie_t cookie = xcb_shm_get_image_unchecked(connection(), pixmap(), - 0, 0, size().width(), size().height(), - ~0, XCB_IMAGE_FORMAT_Z_PIXMAP, m_shm->segment(), 0); - - ScopedCPointer image(xcb_shm_get_image_reply(connection(), cookie, NULL)); - if (image.isNull()) { - return false; + QPainter p(&m_image); + const QImage &data = b->data(); + p.setCompositionMode(QPainter::CompositionMode_Source); + for (const QRect &rect : damage.rects()) { + p.drawImage(rect, data, rect); } return true; } diff --git a/scene_qpainter.h b/scene_qpainter.h index a9c97a2ec9..8a9cfa16e2 100644 --- a/scene_qpainter.h +++ b/scene_qpainter.h @@ -27,10 +27,6 @@ along with this program. If not, see . namespace KWin { -namespace Xcb { - class Shm; -} - class KWIN_EXPORT QPainterBackend { public: @@ -163,7 +159,6 @@ public: bool update(const QRegion &damage); const QImage &image(); private: - QScopedPointer m_shm; QImage m_image; };