diff options
author | Kai Uwe Broulik <kde@privat.broulik.de> | 2024-01-08 14:25:19 +0100 |
---|---|---|
committer | Kai Uwe Broulik <kde@privat.broulik.de> | 2024-02-15 18:47:45 +0100 |
commit | d0dc2bb97469a276a76311c65a54873f7caa7df8 (patch) | |
tree | ff179a23924c21f7e72bd69f022f61d86f0c3de8 /src | |
parent | cf0c0065bd0b689b3651aa50a229b0e118b19336 (diff) |
QWaylandShmBackingStore: Split buffer preparation into dedicated method
Drop "resize(QRect)" since it is ambiguous with the resize coming from
QPlatformBackingStore.
This allows to ensure a back buffer from multiple places, such as the
upcoming "scroll" support.
Change-Id: I43a5ece2d0e25e64b41335ba59b2b8c4ffcfff74
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylandshmbackingstore.cpp | 17 | ||||
-rw-r--r-- | src/client/qwaylandshmbackingstore_p.h | 3 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 6 |
3 files changed, 11 insertions, 15 deletions
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index 723b264d5..a1e9e0e4a 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -144,9 +144,9 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window, QWaylandDispla // contents from the back buffer mBuffers.clear(); mFrontBuffer = nullptr; - // resize always resets mBackBuffer + // ensureBackBuffer always resets mBackBuffer if (mRequestedSize.isValid() && waylandWindow()) - resize(mRequestedSize); + ensureBackBuffer(); qDeleteAll(copy); }); } @@ -180,7 +180,8 @@ void QWaylandShmBackingStore::updateDirtyStates(const QRegion ®ion) void QWaylandShmBackingStore::beginPaint(const QRegion ®ion) { mPainting = true; - ensureSize(); + waylandWindow()->setBackingStore(this); + ensureBackBuffer(); const QMargins margins = windowDecorationMargins(); updateDirtyStates(region.translated(margins.left(), margins.top())); @@ -201,12 +202,6 @@ void QWaylandShmBackingStore::endPaint() flush(window(), mPendingRegion, QPoint()); } -void QWaylandShmBackingStore::ensureSize() -{ - waylandWindow()->setBackingStore(this); - resize(mRequestedSize); -} - void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { // Invoked when the window is of type RasterSurface or when the window is @@ -269,11 +264,11 @@ QWaylandShmBuffer *QWaylandShmBackingStore::getBuffer(const QSize &size) return nullptr; } -void QWaylandShmBackingStore::resize(const QSize &size) +void QWaylandShmBackingStore::ensureBackBuffer() { QMargins margins = windowDecorationMargins(); qreal scale = waylandWindow()->scale(); - QSize sizeWithMargins = (size + QSize(margins.left()+margins.right(),margins.top()+margins.bottom())) * scale; + const QSize sizeWithMargins = (mRequestedSize + QSize(margins.left() + margins.right(), margins.top() + margins.bottom())) * scale; // We look for a free buffer to draw into. If the buffer is not the last buffer we used, // that is mBackBuffer, and the size is the same we copy the damaged content into the new diff --git a/src/client/qwaylandshmbackingstore_p.h b/src/client/qwaylandshmbackingstore_p.h index 8c7b83dbb..788893360 100644 --- a/src/client/qwaylandshmbackingstore_p.h +++ b/src/client/qwaylandshmbackingstore_p.h @@ -61,7 +61,6 @@ public: QPaintDevice *paintDevice() override; void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; void resize(const QSize &size, const QRegion &staticContents) override; - void resize(const QSize &size); void beginPaint(const QRegion ®ion) override; void endPaint() override; @@ -70,7 +69,7 @@ public: QMargins windowDecorationMargins() const; QImage *entireSurface() const; QImage *contentSurface() const; - void ensureSize(); + void ensureBackBuffer(); QWaylandWindow *waylandWindow() const; void iterateBuffer(); diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 7bc79eb8a..bb33a747f 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -90,8 +90,10 @@ QWaylandWindow::~QWaylandWindow() void QWaylandWindow::ensureSize() { - if (mBackingStore) - mBackingStore->ensureSize(); + if (mBackingStore) { + setBackingStore(mBackingStore); + mBackingStore->ensureBackBuffer(); + } } void QWaylandWindow::initWindow() |