KWin
Loading...
Searching...
No Matches
qpaintersurfacetexture_wayland.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
9
10#include <QPainter>
11
12namespace KWin
13{
14
20
22{
23 const GraphicsBufferView view(m_pixmap->buffer());
24 if (Q_LIKELY(view.image())) {
25 // The buffer data is copied as the buffer interface returns a QImage
26 // which doesn't own the data of the underlying wl_shm_buffer object.
27 m_image = view.image()->copy();
28 }
29 return !m_image.isNull();
30}
31
32void QPainterSurfaceTextureWayland::update(const QRegion &region)
33{
34 const GraphicsBufferView view(m_pixmap->buffer());
35 if (Q_UNLIKELY(!view.image())) {
36 return;
37 }
38
39 QPainter painter(&m_image);
40 painter.setCompositionMode(QPainter::CompositionMode_Source);
41
42 // The buffer data is copied as the buffer interface returns a QImage
43 // which doesn't own the data of the underlying wl_shm_buffer object.
44 for (const QRect &rect : region) {
45 painter.drawImage(rect, *view.image(), rect);
46 }
47}
48
49} // namespace KWin
QPainterSurfaceTextureWayland(QPainterBackend *backend, SurfacePixmap *pixmap)
void update(const QRegion &region) override
GraphicsBuffer * buffer() const