summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-04-25 08:58:49 +0200
committerAapo Keskimolo <aapo.keskimolo@qt.io>2019-05-01 13:54:25 +0000
commit1cff2a85fd6dcf4bef8826ee13216aa6a563c236 (patch)
tree24cc2ec19a3f2664c46afb75cd0d3dbe410e159b
parent5a0670094f675b3e7f742833e03d9895b3bac2af (diff)
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>
-rw-r--r--src/client/qwaylandshmbackingstore.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp
index 34044ec9b..c16d346eb 100644
--- a/src/client/qwaylandshmbackingstore.cpp
+++ b/src/client/qwaylandshmbackingstore.cpp
@@ -288,12 +288,15 @@ void QWaylandShmBackingStore::resize(const QSize &size)
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
- if (mBackBuffer != buffer && oldSize == buffer->image()->sizeInBytes()) {
- memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->sizeInBytes());
- }
+ if (mBackBuffer != buffer && oldSizeInBytes == newSizeInBytes)
+ memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), newSizeInBytes);
+
mBackBuffer = buffer;
+
// ensure the new buffer is at the beginning of the list so next time getBuffer() will pick
// it if possible
if (mBuffers.first() != buffer) {
@@ -301,7 +304,7 @@ void QWaylandShmBackingStore::resize(const QSize &size)
mBuffers.prepend(buffer);
}
- if (windowDecoration() && window()->isVisible())
+ if (windowDecoration() && window()->isVisible() && oldSizeInBytes != newSizeInBytes)
windowDecoration()->update();
}