Client: Avoid unnecessarily redrawing decorations
Note: QWaylandAbstractDecoration::update() doesn't actually update anything, it just sets a dirty flag, and this is done explicitly in the other cases when the decorations need to be redrawn as well (title and icon changes). Fixes: QTBUG-75377 Change-Id: I2e8bd3abd3664c741e69a3e83ebf409872ddf31a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
e3a9660499
commit
3a3f3eb924
@ -288,12 +288,15 @@ void QWaylandShmBackingStore::resize(const QSize &size)
|
|||||||
buffer = getBuffer(sizeWithMargins);
|
buffer = getBuffer(sizeWithMargins);
|
||||||
}
|
}
|
||||||
|
|
||||||
qsizetype oldSize = mBackBuffer ? mBackBuffer->image()->sizeInBytes() : 0;
|
qsizetype oldSizeInBytes = mBackBuffer ? mBackBuffer->image()->sizeInBytes() : 0;
|
||||||
|
qsizetype newSizeInBytes = buffer->image()->sizeInBytes();
|
||||||
|
|
||||||
// mBackBuffer may have been deleted here but if so it means its size was different so we wouldn't copy it anyway
|
// mBackBuffer may have been deleted here but if so it means its size was different so we wouldn't copy it anyway
|
||||||
if (mBackBuffer != buffer && oldSize == buffer->image()->sizeInBytes()) {
|
if (mBackBuffer != buffer && oldSizeInBytes == newSizeInBytes)
|
||||||
memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->sizeInBytes());
|
memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), newSizeInBytes);
|
||||||
}
|
|
||||||
mBackBuffer = buffer;
|
mBackBuffer = buffer;
|
||||||
|
|
||||||
// ensure the new buffer is at the beginning of the list so next time getBuffer() will pick
|
// ensure the new buffer is at the beginning of the list so next time getBuffer() will pick
|
||||||
// it if possible
|
// it if possible
|
||||||
if (mBuffers.first() != buffer) {
|
if (mBuffers.first() != buffer) {
|
||||||
@ -301,7 +304,7 @@ void QWaylandShmBackingStore::resize(const QSize &size)
|
|||||||
mBuffers.prepend(buffer);
|
mBuffers.prepend(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowDecoration() && window()->isVisible())
|
if (windowDecoration() && window()->isVisible() && oldSizeInBytes != newSizeInBytes)
|
||||||
windowDecoration()->update();
|
windowDecoration()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user