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

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