summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-04-20 16:11:29 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-04-22 23:46:44 +0200
commit0c6b4dd4ad66d86d5a8dba998679ea53a563b685 (patch)
treeb807d4e8cf5cbbc82232667292b28b549532bf2c
parent65636ed06069fe7cc83ad159a0f48e4d3d7aba48 (diff)
macOS: Don't optimize out aggressive backingstore flushes when single-buffered
Comparing the layer contents to the backingstore surface doesn't make sense when we're single buffered since we're always using the same surface. And once Core Animation has picked up on the surface it's not enough to just keep drawing to it, we also need to tell Core Animation that the contents has changed. Change-Id: I517a0b7a3ba7e9d96033465c9bd5a192985643ac Fixes: QTBUG-81071 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index 3b9df8da3a..ba5d42e706 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -537,8 +537,10 @@ void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion &region,
flushedView.layer.contentsScale = m_buffers.back()->devicePixelRatio();
}
+ const bool isSingleBuffered = window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer;
+
id backBufferSurface = (__bridge id)m_buffers.back()->surface();
- if (flushedView.layer.contents == backBufferSurface) {
+ if (!isSingleBuffered && flushedView.layer.contents == backBufferSurface) {
// We've managed to paint to the back buffer again before Core Animation had time
// to flush the transaction and persist the layer changes to the window server, or
// we've been asked to flush without painting anything. The layer already knows about
@@ -555,7 +557,7 @@ void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion &region,
// with other pending view and layer updates.
flushedView.window.viewsNeedDisplay = YES;
- if (window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer) {
+ if (isSingleBuffered) {
// The private API [CALayer reloadValueForKeyPath:@"contents"] would be preferable,
// but barring any side effects or performance issues we opt for the hammer for now.
flushedView.layer.contents = nil;