| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 |
|
| 5 |
#ifndef QXCBBACKINGSTORE_H |
| 6 |
#define QXCBBACKINGSTORE_H |
| 7 |
|
| 8 |
#include <qpa/qplatformbackingstore.h> |
| 9 |
#include <QtCore/QStack> |
| 10 |
|
| 11 |
#include <xcb/xcb.h> |
| 12 |
|
| 13 |
#include "qxcbobject.h" |
| 14 |
|
| 15 |
QT_BEGIN_NAMESPACE |
| 16 |
|
| 17 |
class QXcbBackingStoreImage; |
| 18 |
|
| 19 |
class QXcbBackingStore : public QXcbObject, public QPlatformBackingStore |
| 20 |
{ |
| 21 |
public: |
| 22 |
QXcbBackingStore(QWindow *window); |
| 23 |
~QXcbBackingStore(); |
| 24 |
|
| 25 |
QPaintDevice *paintDevice() override; |
| 26 |
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; |
| 27 |
#ifndef QT_NO_OPENGL |
| 28 |
void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, |
| 29 |
QPlatformTextureList *textures, |
| 30 |
bool translucentBackground) override; |
| 31 |
#endif |
| 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 |