path: root/src/plugins/platforms/cocoa
diff options
authorTor Arne Vestbø <>2018-07-18 18:35:29 +0200
committerTor Arne Vestbø <>2018-07-20 06:40:07 +0000
commit8aa14a84a91d3f8116e04cbe68bfcdb0207c2a3b (patch)
tree34bcd01046a5c74eb2f8a0f45342d08eadc57c13 /src/plugins/platforms/cocoa
parent8316131dab00a18d581e3b7627122d5e983bb213 (diff)
macOS: Correctly scale CALayer contentsRect for child NSViews
When flushing parts of a QBackingStore onto child QWindows, and we're in layer-backed mode, we need to set the contentsRect of the layer so that the layer will only show the part of the top-level-owned backingstore image that's relevant for the child window. Since the contentsRect is in unit coordinate system, we need to apply a transform, but this must be based on the top level view's size, not the image size, as the latter will be twice as big on a retina screen, giving the wrong unit rect. Change-Id: I7d6f378ed46a98272efb13406a2878ec1efe734e Reviewed-by: Simon Hausmann <> Reviewed-by: Tor Arne Vestbø <>
Diffstat (limited to 'src/plugins/platforms/cocoa')
1 files changed, 2 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/ b/src/plugins/platforms/cocoa/
index 639851e855..23a9edfa49 100644
--- a/src/plugins/platforms/cocoa/
+++ b/src/plugins/platforms/cocoa/
@@ -127,10 +127,11 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
// FIXME: Figure out if there's a way to do partial updates
view.layer.contents = (__bridge id)static_cast<CGImageRef>(cgImage);
if (view != topLevelView) {
+ const CGSize topLevelSize = topLevelView.bounds.size;
view.layer.contentsRect = CGRectApplyAffineTransform(
[view convertRect:view.bounds toView:topLevelView],
// The contentsRect is in unit coordinate system
- CGAffineTransformMakeScale(1.0 / m_image.width(), 1.0 / m_image.height()));
+ CGAffineTransformMakeScale(1.0 / topLevelSize.width, 1.0 / topLevelSize.height));
} else {
// Normally a NSView is drawn via drawRect, as part of the display cycle in the