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 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class QXcbBackingStoreImage; |
17 | |
18 | class QXcbBackingStore : public QXcbObject, public QPlatformBackingStore |
19 | { |
20 | public: |
21 | QXcbBackingStore(QWindow *window); |
22 | ~QXcbBackingStore(); |
23 | |
24 | QPaintDevice *paintDevice() override; |
25 | void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; |
26 | FlushResult rhiFlush(QWindow *window, |
27 | qreal sourceDevicePixelRatio, |
28 | const QRegion ®ion, |
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 | |
45 | protected: |
46 | virtual void render(xcb_window_t window, const QRegion ®ion, 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 | |
54 | class QXcbSystemTrayBackingStore : public QXcbBackingStore |
55 | { |
56 | public: |
57 | QXcbSystemTrayBackingStore(QWindow *window); |
58 | ~QXcbSystemTrayBackingStore(); |
59 | |
60 | void beginPaint(const QRegion &) override; |
61 | |
62 | protected: |
63 | void render(xcb_window_t window, const QRegion ®ion, const QPoint &offset) override; |
64 | void recreateImage(QXcbWindow *win, const QSize &size) override; |
65 | |
66 | private: |
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 | |
79 | QT_END_NAMESPACE |
80 | |
81 | #endif |
82 | |