1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#pragma once
5
6#include <qpa/qplatformbackingstore.h>
7#include <QtCore/QStack>
8
9#include <xcb/xcb.h>
10
11#include "qxcbobject.h"
12
13QT_BEGIN_NAMESPACE
14
15class QXcbBackingStoreImage;
16
17class QXcbBackingStore : public QXcbObject, public QPlatformBackingStore
18{
19public:
20 QXcbBackingStore(QWindow *window);
21 ~QXcbBackingStore();
22
23 QPaintDevice *paintDevice() override;
24 void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;
25 FlushResult rhiFlush(QWindow *window,
26 qreal sourceDevicePixelRatio,
27 const QRegion &region,
28 const QPoint &offset,
29 QPlatformTextureList *textures,
30 bool translucentBackground) override;
31 QImage toImage() const override;
32
33 QPlatformGraphicsBuffer *graphicsBuffer() const override;
34
35 void resize(const QSize &size, const QRegion &staticContents) override;
36 bool scroll(const QRegion &area, int dx, int dy) override;
37
38 void beginPaint(const QRegion &) override;
39 void endPaint() override;
40
41 static bool createSystemVShmSegment(xcb_connection_t *c, size_t segmentSize = 1,
42 void *shmInfo = nullptr);
43
44protected:
45 virtual void render(xcb_window_t window, const QRegion &region, const QPoint &offset);
46 virtual void recreateImage(QXcbWindow *win, const QSize &size);
47
48 QXcbBackingStoreImage *m_image = nullptr;
49 QStack<QRegion> m_paintRegions;
50 QImage m_rgbImage;
51};
52
53class QXcbSystemTrayBackingStore : public QXcbBackingStore
54{
55public:
56 QXcbSystemTrayBackingStore(QWindow *window);
57 ~QXcbSystemTrayBackingStore();
58
59 void beginPaint(const QRegion &) override;
60
61protected:
62 void render(xcb_window_t window, const QRegion &region, const QPoint &offset) override;
63 void recreateImage(QXcbWindow *win, const QSize &size) override;
64
65private:
66 void initXRenderMode();
67
68 xcb_pixmap_t m_xrenderPixmap = XCB_NONE;
69 xcb_render_picture_t m_xrenderPicture = XCB_NONE;
70 xcb_render_pictformat_t m_xrenderPictFormat = XCB_NONE;
71 xcb_render_picture_t m_windowPicture = XCB_NONE;
72
73 bool m_usingXRenderMode = false;
74 bool m_useGrabbedBackgound = false;
75 QPixmap m_grabbedBackground;
76};
77
78QT_END_NAMESPACE
79

source code of qtbase/src/plugins/platforms/xcb/qxcbbackingstore.h