| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef QWAYLANDSHMBACKINGSTORE_H |
| 6 |
#define QWAYLANDSHMBACKINGSTORE_H |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <QtWaylandClient/private/qwaylandbuffer_p.h> |
| 20 |
|
| 21 |
#include <qpa/qplatformbackingstore.h> |
| 22 |
#include <QtGui/QImage> |
| 23 |
#include <qpa/qplatformwindow.h> |
| 24 |
#include <QMutex> |
| 25 |
#include <QLinkedList> |
| 26 |
|
| 27 |
QT_BEGIN_NAMESPACE |
| 28 |
|
| 29 |
namespace QtWaylandClient { |
| 30 |
|
| 31 |
class QWaylandDisplay; |
| 32 |
class QWaylandAbstractDecoration; |
| 33 |
class QWaylandWindow; |
| 34 |
|
| 35 |
class Q_WAYLAND_CLIENT_EXPORT QWaylandShmBuffer : public QWaylandBuffer { |
| 36 |
public: |
| 37 |
QWaylandShmBuffer(QWaylandDisplay *display, |
| 38 |
const QSize &size, QImage::Format format, int scale = 1); |
| 39 |
~QWaylandShmBuffer() override; |
| 40 |
QSize size() const override { return mImage.size(); } |
| 41 |
int scale() const override { return int(mImage.devicePixelRatio()); } |
| 42 |
QImage *image() { return &mImage; } |
| 43 |
|
| 44 |
QImage *imageInsideMargins(const QMargins &margins); |
| 45 |
private: |
| 46 |
QImage mImage; |
| 47 |
struct wl_shm_pool *mShmPool = nullptr; |
| 48 |
QMargins mMargins; |
| 49 |
QImage *mMarginsImage = nullptr; |
| 50 |
}; |
| 51 |
|
| 52 |
class Q_WAYLAND_CLIENT_EXPORT QWaylandShmBackingStore : public QPlatformBackingStore |
| 53 |
{ |
| 54 |
public: |
| 55 |
QWaylandShmBackingStore(QWindow *window); |
| 56 |
~QWaylandShmBackingStore() override; |
| 57 |
|
| 58 |
QPaintDevice *paintDevice() override; |
| 59 |
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; |
| 60 |
void resize(const QSize &size, const QRegion &staticContents) override; |
| 61 |
void resize(const QSize &size); |
| 62 |
void beginPaint(const QRegion ®ion) override; |
| 63 |
void endPaint() override; |
| 64 |
|
| 65 |
QWaylandAbstractDecoration *windowDecoration() const; |
| 66 |
|
| 67 |
QMargins windowDecorationMargins() const; |
| 68 |
QImage *entireSurface() const; |
| 69 |
QImage *contentSurface() const; |
| 70 |
void ensureSize(); |
| 71 |
|
| 72 |
QWaylandWindow *waylandWindow() const; |
| 73 |
void iterateBuffer(); |
| 74 |
|
| 75 |
#if QT_CONFIG(opengl) |
| 76 |
QImage toImage() const override; |
| 77 |
#endif |
| 78 |
|
| 79 |
private: |
| 80 |
void updateDecorations(); |
| 81 |
QWaylandShmBuffer *getBuffer(const QSize &size); |
| 82 |
|
| 83 |
QWaylandDisplay *mDisplay = nullptr; |
| 84 |
QLinkedList<QWaylandShmBuffer *> mBuffers; |
| 85 |
QWaylandShmBuffer *mFrontBuffer = nullptr; |
| 86 |
QWaylandShmBuffer *mBackBuffer = nullptr; |
| 87 |
bool mPainting = false; |
| 88 |
bool mPendingFlush = false; |
| 89 |
QRegion mPendingRegion; |
| 90 |
QMutex mMutex; |
| 91 |
|
| 92 |
QSize mRequestedSize; |
| 93 |
Qt::WindowFlags mCurrentWindowFlags; |
| 94 |
}; |
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
QT_END_NAMESPACE |
| 99 |
|
| 100 |
#endif |