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>
This commit is contained in:
parent
468e59f478
commit
a96b58798e
@ -144,9 +144,9 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window, QWaylandDispla
|
|||||||
// contents from the back buffer
|
// contents from the back buffer
|
||||||
mBuffers.clear();
|
mBuffers.clear();
|
||||||
mFrontBuffer = nullptr;
|
mFrontBuffer = nullptr;
|
||||||
// resize always resets mBackBuffer
|
// ensureBackBuffer always resets mBackBuffer
|
||||||
if (mRequestedSize.isValid() && waylandWindow())
|
if (mRequestedSize.isValid() && waylandWindow())
|
||||||
resize(mRequestedSize);
|
ensureBackBuffer();
|
||||||
qDeleteAll(copy);
|
qDeleteAll(copy);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -180,7 +180,8 @@ void QWaylandShmBackingStore::updateDirtyStates(const QRegion ®ion)
|
|||||||
void QWaylandShmBackingStore::beginPaint(const QRegion ®ion)
|
void QWaylandShmBackingStore::beginPaint(const QRegion ®ion)
|
||||||
{
|
{
|
||||||
mPainting = true;
|
mPainting = true;
|
||||||
ensureSize();
|
waylandWindow()->setBackingStore(this);
|
||||||
|
ensureBackBuffer();
|
||||||
|
|
||||||
const QMargins margins = windowDecorationMargins();
|
const QMargins margins = windowDecorationMargins();
|
||||||
updateDirtyStates(region.translated(margins.left(), margins.top()));
|
updateDirtyStates(region.translated(margins.left(), margins.top()));
|
||||||
@ -201,12 +202,6 @@ void QWaylandShmBackingStore::endPaint()
|
|||||||
flush(window(), mPendingRegion, QPoint());
|
flush(window(), mPendingRegion, QPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandShmBackingStore::ensureSize()
|
|
||||||
{
|
|
||||||
waylandWindow()->setBackingStore(this);
|
|
||||||
resize(mRequestedSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset)
|
void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset)
|
||||||
{
|
{
|
||||||
// Invoked when the window is of type RasterSurface or when the window is
|
// 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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandShmBackingStore::resize(const QSize &size)
|
void QWaylandShmBackingStore::ensureBackBuffer()
|
||||||
{
|
{
|
||||||
QMargins margins = windowDecorationMargins();
|
QMargins margins = windowDecorationMargins();
|
||||||
qreal scale = waylandWindow()->scale();
|
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,
|
// 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
|
// that is mBackBuffer, and the size is the same we copy the damaged content into the new
|
||||||
|
@ -61,7 +61,6 @@ public:
|
|||||||
QPaintDevice *paintDevice() override;
|
QPaintDevice *paintDevice() override;
|
||||||
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) 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, const QRegion &staticContents) override;
|
||||||
void resize(const QSize &size);
|
|
||||||
void beginPaint(const QRegion ®ion) override;
|
void beginPaint(const QRegion ®ion) override;
|
||||||
void endPaint() override;
|
void endPaint() override;
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ public:
|
|||||||
QMargins windowDecorationMargins() const;
|
QMargins windowDecorationMargins() const;
|
||||||
QImage *entireSurface() const;
|
QImage *entireSurface() const;
|
||||||
QImage *contentSurface() const;
|
QImage *contentSurface() const;
|
||||||
void ensureSize();
|
void ensureBackBuffer();
|
||||||
|
|
||||||
QWaylandWindow *waylandWindow() const;
|
QWaylandWindow *waylandWindow() const;
|
||||||
void iterateBuffer();
|
void iterateBuffer();
|
||||||
|
@ -90,8 +90,10 @@ QWaylandWindow::~QWaylandWindow()
|
|||||||
|
|
||||||
void QWaylandWindow::ensureSize()
|
void QWaylandWindow::ensureSize()
|
||||||
{
|
{
|
||||||
if (mBackingStore)
|
if (mBackingStore) {
|
||||||
mBackingStore->ensureSize();
|
setBackingStore(mBackingStore);
|
||||||
|
mBackingStore->ensureBackBuffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandWindow::initWindow()
|
void QWaylandWindow::initWindow()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user